From b529bba53a71007185ce6ad694486a0801fbe309 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Wed, 5 Apr 2023 19:28:07 +0100 Subject: [PATCH] steamcompmgr: Add GAMESCOPE_COLOR_APP_WANTS_HDR_FEEDBACK Tell Steam whether this app is wanting HDR or not. (Whether it's submitting HDR buffers) --- src/drm.hpp | 6 ++++++ src/steamcompmgr.cpp | 21 +++++++++++++++++++++ src/xwayland_ctx.hpp | 1 + 3 files changed, 28 insertions(+) diff --git a/src/drm.hpp b/src/drm.hpp index 8242ac8..850dad7 100644 --- a/src/drm.hpp +++ b/src/drm.hpp @@ -42,6 +42,12 @@ enum GamescopeAppTextureColorspace { }; const uint32_t GamescopeAppTextureColorspace_Bits = 2; +inline bool ColorspaceIsHDR( GamescopeAppTextureColorspace colorspace ) +{ + return colorspace == GAMESCOPE_APP_TEXTURE_COLORSPACE_SCRGB || + colorspace == GAMESCOPE_APP_TEXTURE_COLORSPACE_HDR10_PQ; +} + extern struct drm_t g_DRM; void drm_destroy_hdr_metadata_blob(struct drm_t *drm, uint32_t blob); diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 598e326..6f1dff5 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -6100,6 +6100,7 @@ void init_xwayland_ctx(uint32_t serverId, gamescope_xwayland_server_t *xwayland_ ctx->atoms.gamescopeColorSDRGamutWideness = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_SDR_GAMUT_WIDENESS", false ); ctx->atoms.gamescopeColorNightMode = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_NIGHT_MODE", false ); ctx->atoms.gamescopeColorManagementDisable = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MANAGEMENT_DISABLE", false ); + ctx->atoms.gamescopeColorAppWantsHDRFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_APP_WANTS_HDR_FEEDBACK", false ); ctx->atoms.gamescopeCreateXWaylandServer = XInternAtom( ctx->dpy, "GAMESCOPE_CREATE_XWAYLAND_SERVER", false ); ctx->atoms.gamescopeCreateXWaylandServerFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_CREATE_XWAYLAND_SERVER_FEEDBACK", false ); @@ -6606,6 +6607,26 @@ steamcompmgr_main(int argc, char **argv) } } + { + GamescopeAppTextureColorspace current_app_colorspace = GAMESCOPE_APP_TEXTURE_COLORSPACE_SRGB; + if ( g_HeldCommits[HELD_COMMIT_BASE] ) + current_app_colorspace = g_HeldCommits[HELD_COMMIT_BASE]->colorspace(); + + bool app_wants_hdr = ColorspaceIsHDR( current_app_colorspace ); + + static bool s_bAppWantsHDRCached = false; + + if ( app_wants_hdr != s_bAppWantsHDRCached ) + { + uint32_t app_wants_hdr_prop = app_wants_hdr ? 1 : 0; + + XChangeProperty(root_ctx->dpy, root_ctx->root, root_ctx->atoms.gamescopeColorAppWantsHDRFeedback, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&app_wants_hdr_prop, 1 ); + + s_bAppWantsHDRCached = app_wants_hdr; + } + } + currentOutputWidth = g_nOutputWidth; currentOutputHeight = g_nOutputHeight; currentHDROutput = g_bOutputHDREnabled; diff --git a/src/xwayland_ctx.hpp b/src/xwayland_ctx.hpp index b21944c..7b3dcf1 100644 --- a/src/xwayland_ctx.hpp +++ b/src/xwayland_ctx.hpp @@ -191,6 +191,7 @@ struct xwayland_ctx_t Atom gamescopeColorSDRGamutWideness; Atom gamescopeColorNightMode; // amount, hue, saturation Atom gamescopeColorManagementDisable; + Atom gamescopeColorAppWantsHDRFeedback; Atom gamescopeCreateXWaylandServer; Atom gamescopeCreateXWaylandServerFeedback;