From a2b45e15009f80ca1ad346840f2574bbe060fa94 Mon Sep 17 00:00:00 2001 From: wheaney <42350981+wheaney@users.noreply.github.com> Date: Fri, 13 Sep 2024 23:42:15 -0700 Subject: [PATCH] Fix how reshade effects are cleared --- README.md | 2 +- src/reshade_effect_manager.cpp | 2 +- src/steamcompmgr.cpp | 35 ++++++++++++++++++++-------------- src/steamcompmgr.hpp | 1 + src/wlserver.cpp | 1 - 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a56075a91b..8aa0227bf8 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Gamescope supports a subset of Reshade effects/shaders using the `--reshade-effe This provides an easy way to do shader effects (ie. CRT shader, film grain, debugging HDR with histograms, etc) on top of whatever is being displayed in Gamescope without having to hook into the underlying process. -There is currently no way to set the value of uniforms/options, they will just be their initializer values currently. +Uniform/shader options can be modified programmatically via the `gamescope-reshade` wayland interface. Otherwise, they will just use their initializer values. Using Reshade effects will increase latency as there will be work performed on the general gfx + compute queue as opposed to only using the realtime async compute queue which can run in tandem with the game's gfx work. diff --git a/src/reshade_effect_manager.cpp b/src/reshade_effect_manager.cpp index 87f886b140..0ba5985dba 100644 --- a/src/reshade_effect_manager.cpp +++ b/src/reshade_effect_manager.cpp @@ -1949,5 +1949,5 @@ void reshade_effect_manager_enable_effect() void reshade_effect_manager_disable_effect() { - gamescope_set_reshade_effect(nullptr); + gamescope_clear_reshade_effect(); } \ No newline at end of file diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 8c9920e315..376770b9f3 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -2955,20 +2955,22 @@ std::string get_string_prop( xwayland_ctx_t *ctx, Window win, Atom prop ) return value; } -void set_string_prop( xwayland_ctx_t *ctx, Window win, Atom prop, const std::string &value ) +void set_string_prop( xwayland_ctx_t *ctx, Atom prop, const std::string &value ) { - if ( value.empty() ) - XDeleteProperty( ctx->dpy, win, prop ); - else { - XTextProperty text_property = - { - .value = ( unsigned char * )value.c_str(), - .encoding = ctx->atoms.utf8StringAtom, - .format = 8, - .nitems = strlen( value.c_str() ) - }; - XSetTextProperty( ctx->dpy, ctx->root, &text_property, prop); - } + XTextProperty text_property = + { + .value = ( unsigned char * )value.c_str(), + .encoding = ctx->atoms.utf8StringAtom, + .format = 8, + .nitems = strlen( value.c_str() ) + }; + XSetTextProperty( ctx->dpy, ctx->root, &text_property, prop); + XFlush( ctx->dpy ); +} + +void clear_prop( xwayland_ctx_t *ctx, Atom prop ) +{ + XDeleteProperty( ctx->dpy, ctx->root, prop ); XFlush( ctx->dpy ); } @@ -4896,7 +4898,12 @@ void gamescope_set_selection(std::string contents, GamescopeSelection eSelection void gamescope_set_reshade_effect(std::string effect_path) { gamescope_xwayland_server_t *server = wlserver_get_xwayland_server(0); - set_string_prop(server->ctx.get(), server->ctx->ourWindow, server->ctx->atoms.gamescopeReshadeEffect, effect_path); + set_string_prop(server->ctx.get(), server->ctx->atoms.gamescopeReshadeEffect, effect_path); +} + +void gamescope_clear_reshade_effect() { + gamescope_xwayland_server_t *server = wlserver_get_xwayland_server(0); + clear_prop(server->ctx.get(), server->ctx->atoms.gamescopeReshadeEffect); } static void diff --git a/src/steamcompmgr.hpp b/src/steamcompmgr.hpp index 8c76db90a8..9f384c461c 100644 --- a/src/steamcompmgr.hpp +++ b/src/steamcompmgr.hpp @@ -148,6 +148,7 @@ extern pid_t focusWindow_pid; void init_xwayland_ctx(uint32_t serverId, gamescope_xwayland_server_t *xwayland_server); void gamescope_set_selection(std::string contents, GamescopeSelection eSelection); void gamescope_set_reshade_effect(std::string effect_path); +void gamescope_clear_reshade_effect(); MouseCursor *steamcompmgr_get_current_cursor(); MouseCursor *steamcompmgr_get_server_cursor(uint32_t serverId); diff --git a/src/wlserver.cpp b/src/wlserver.cpp index 670cf6896d..8cd58dd6a0 100644 --- a/src/wlserver.cpp +++ b/src/wlserver.cpp @@ -58,7 +58,6 @@ #include "steamcompmgr.hpp" #include "log.hpp" #include "ime.hpp" -#include "reshade_effect_manager.hpp" #include "xwayland_ctx.hpp" #include "refresh_rate.h" #include "InputEmulation.h"