Skip to content

Commit

Permalink
Fix how reshade effects are cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
wheaney authored and misyltoad committed Sep 16, 2024
1 parent 0110109 commit a2b45e1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
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

1 comment on commit a2b45e1

@wheaney
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@misyltoad It looks like this got skipped over for jupiter-3.6. Any way it could get merged? It fixes the other gamescope-reshade commit that did make it into the release branch (assuming that's what the branch is for).

Please sign in to comment.