Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how the gamescope-reshade server clears effects #1524

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion src/reshade_effect_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
35 changes: 21 additions & 14 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/steamcompmgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/wlserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading