Skip to content

Commit

Permalink
drm: Collection of DRM refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Jan 2, 2024
1 parent 8f3f5c5 commit 1658b2f
Show file tree
Hide file tree
Showing 11 changed files with 1,398 additions and 1,292 deletions.
2,136 changes: 1,008 additions & 1,128 deletions src/drm.cpp

Large diffs are not rendered by default.

377 changes: 284 additions & 93 deletions src/drm.hpp

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions src/gamescope_shared.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

namespace gamescope
{
enum GamescopeKnownDisplays
{
GAMESCOPE_KNOWN_DISPLAY_UNKNOWN,
GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_LCD, // Jupiter
GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_OLED_SDC, // Galileo SDC
GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_OLED_BOE, // Galileo BOE
};

enum GamescopeModeGeneration
{
GAMESCOPE_MODE_GENERATE_CVT,
GAMESCOPE_MODE_GENERATE_FIXED,
};

enum GamescopeScreenType
{
GAMESCOPE_SCREEN_TYPE_INTERNAL,
GAMESCOPE_SCREEN_TYPE_EXTERNAL,

GAMESCOPE_SCREEN_TYPE_COUNT
};
}

21 changes: 12 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,18 @@ static std::string build_optstring(const struct option *options)
return optstring;
}

static enum drm_mode_generation parse_drm_mode_generation(const char *str)
static gamescope::GamescopeModeGeneration parse_gamescope_mode_generation( const char *str )
{
if (strcmp(str, "cvt") == 0) {
return DRM_MODE_GENERATE_CVT;
} else if (strcmp(str, "fixed") == 0) {
return DRM_MODE_GENERATE_FIXED;
} else {
if ( str == "cvt"sv )
{
return gamescope::GAMESCOPE_MODE_GENERATE_CVT;
}
else if ( str == "fixed"sv )
{
return gamescope::GAMESCOPE_MODE_GENERATE_FIXED;
}
else
{
fprintf( stderr, "gamescope: invalid value for --generate-drm-mode\n" );
exit(1);
}
Expand Down Expand Up @@ -594,8 +599,6 @@ int main(int argc, char **argv)
if (strcmp(opt_name, "help") == 0) {
fprintf(stderr, "%s", usage);
return 0;
} else if (strcmp(opt_name, "disable-layers") == 0) {
g_bUseLayers = false;
} else if (strcmp(opt_name, "debug-layers") == 0) {
g_bDebugLayers = true;
} else if (strcmp(opt_name, "disable-color-management") == 0) {
Expand All @@ -611,7 +614,7 @@ int main(int argc, char **argv)
g_nDefaultTouchClickMode = (enum wlserver_touch_click_mode) atoi( optarg );
g_nTouchClickMode = g_nDefaultTouchClickMode;
} else if (strcmp(opt_name, "generate-drm-mode") == 0) {
g_drmModeGeneration = parse_drm_mode_generation( optarg );
g_eGamescopeModeGeneration = parse_gamescope_mode_generation( optarg );
} else if (strcmp(opt_name, "force-orientation") == 0) {
g_drmModeOrientation = force_orientation( optarg );
} else if (strcmp(opt_name, "sharpness") == 0 ||
Expand Down
17 changes: 9 additions & 8 deletions src/modegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,16 @@ unsigned int get_galileo_vfp( int vrefresh, unsigned int * vfp_array, unsigned i
return 0;
}

void generate_fixed_mode(drmModeModeInfo *mode, const drmModeModeInfo *base, int vrefresh,
bool use_tuned_clocks, unsigned int use_vfp )
void generate_fixed_mode(drmModeModeInfo *mode, const drmModeModeInfo *base, int vrefresh, gamescope::GamescopeKnownDisplays eKnownDisplay )
{
*mode = *base;
if (!vrefresh)
vrefresh = 60;
if ( use_vfp ) {
unsigned int vfp, vsync, vbp = 0;
if (GALILEO_SDC_PID == use_vfp) {
if ( eKnownDisplay == gamescope::GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_OLED_SDC ||
eKnownDisplay == gamescope::GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_OLED_BOE ) {
unsigned int vfp = 0, vsync = 0, vbp = 0;
if ( eKnownDisplay == gamescope::GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_OLED_SDC )
{
vfp = get_galileo_vfp( vrefresh, galileo_sdc_vfp, ARRAY_SIZE(galileo_sdc_vfp) );
// if we did not find a matching rate then we default to 60 Hz
if ( !vfp ) {
Expand All @@ -329,7 +330,7 @@ void generate_fixed_mode(drmModeModeInfo *mode, const drmModeModeInfo *base, int
}
vsync = GALILEO_SDC_VSYNC;
vbp = GALILEO_SDC_VBP;
} else { // BOE Panel
} else if ( eKnownDisplay == gamescope::GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_OLED_BOE ) { // BOE Panel
vfp = get_galileo_vfp( vrefresh, galileo_boe_vfp, ARRAY_SIZE(galileo_boe_vfp) );
// if we did not find a matching rate then we default to 60 Hz
if ( !vfp ) {
Expand All @@ -338,12 +339,12 @@ void generate_fixed_mode(drmModeModeInfo *mode, const drmModeModeInfo *base, int
}
vsync = GALILEO_BOE_VSYNC;
vbp = GALILEO_BOE_VBP;
}
}
mode->vsync_start = mode->vdisplay + vfp;
mode->vsync_end = mode->vsync_start + vsync;
mode->vtotal = mode->vsync_end + vbp;
} else {
if ( use_tuned_clocks )
if ( eKnownDisplay == gamescope::GAMESCOPE_KNOWN_DISPLAY_STEAM_DECK_LCD )
{
mode->hdisplay = 800;
mode->hsync_start = 840;
Expand Down
3 changes: 2 additions & 1 deletion src/modegen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include <stdint.h>
#include <stdio.h>
#include <xf86drmMode.h>
#include "gamescope_shared.h"

void generate_cvt_mode(drmModeModeInfo *mode, int hdisplay, int vdisplay,
float vrefresh, bool reduced, bool interlaced);
void generate_fixed_mode(drmModeModeInfo *mode, const drmModeModeInfo *base,
int vrefresh, bool use_tuned_clocks, unsigned int use_vfp);
int vrefresh, gamescope::GamescopeKnownDisplays eKnownDisplay);
85 changes: 44 additions & 41 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ int g_nAsyncFlipsEnabled = 0;
int g_nSteamMaxHeight = 0;
bool g_bVRRCapable_CachedValue = false;
bool g_bVRRInUse_CachedValue = false;
bool g_bSupportsST2084_CachedValue = false;
bool g_bSupportsHDR_CachedValue = false;
bool g_bForceHDR10OutputDebug = false;
bool g_bHDREnabled = false;
bool g_bHDRItmEnable = false;
Expand Down Expand Up @@ -505,8 +505,8 @@ bool set_color_mgmt_enabled( bool bEnabled )
return true;
}

static std::shared_ptr<CVulkanTexture> s_MuraCorrectionImage[DRM_SCREEN_TYPE_COUNT];
static std::shared_ptr<wlserver_ctm> s_MuraCTMBlob[DRM_SCREEN_TYPE_COUNT];
static std::shared_ptr<CVulkanTexture> s_MuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT];
static std::shared_ptr<wlserver_ctm> s_MuraCTMBlob[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT];
static float g_flMuraScale = 1.0f;
static bool g_bMuraCompensationDisabled = false;

Expand All @@ -517,8 +517,8 @@ bool is_mura_correction_enabled()

void update_mura_ctm()
{
s_MuraCTMBlob[DRM_SCREEN_TYPE_INTERNAL] = nullptr;
if (s_MuraCorrectionImage[DRM_SCREEN_TYPE_INTERNAL] == nullptr)
s_MuraCTMBlob[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = nullptr;
if (s_MuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] == nullptr)
return;

static constexpr float kMuraMapScale = 0.0625f;
Expand All @@ -533,15 +533,15 @@ void update_mura_ctm()
0, flScale, 0, kMuraOffset * flScale,
0, 0, 0, 0, // No mura comp for blue channel.
};
s_MuraCTMBlob[DRM_SCREEN_TYPE_INTERNAL] = drm_create_ctm(&g_DRM, mura_scale_offset);
s_MuraCTMBlob[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = drm_create_ctm(&g_DRM, mura_scale_offset);
}

bool g_bMuraDebugFullColor = false;

bool set_mura_overlay( const char *path )
{
xwm_log.infof("[josh mura correction] Setting mura correction image to: %s", path);
s_MuraCorrectionImage[DRM_SCREEN_TYPE_INTERNAL] = nullptr;
s_MuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = nullptr;
update_mura_ctm();

std::string red_path = std::string(path) + "_red.png";
Expand Down Expand Up @@ -577,7 +577,7 @@ bool set_mura_overlay( const char *path )
CVulkanTexture::createFlags texCreateFlags;
texCreateFlags.bFlippable = !BIsNested();
texCreateFlags.bSampled = true;
s_MuraCorrectionImage[DRM_SCREEN_TYPE_INTERNAL] = vulkan_create_texture_from_bits(w, h, w, h, DRM_FORMAT_ABGR8888, texCreateFlags, (void*)data);
s_MuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = vulkan_create_texture_from_bits(w, h, w, h, DRM_FORMAT_ABGR8888, texCreateFlags, (void*)data);
free(data);

xwm_log.infof("[josh mura correction] Loaded new mura correction image!");
Expand Down Expand Up @@ -912,26 +912,26 @@ bool g_bCurrentBasePlaneIsFifo = false;

static int g_nSteamCompMgrTargetFPS = 0;
static uint64_t g_uDynamicRefreshEqualityTime = 0;
static int g_nDynamicRefreshRate[DRM_SCREEN_TYPE_COUNT] = { 0, 0 };
static int g_nDynamicRefreshRate[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT] = { 0, 0 };
// Delay to stop modes flickering back and forth.
static const uint64_t g_uDynamicRefreshDelay = 600'000'000; // 600ms

static int g_nCombinedAppRefreshCycleOverride[DRM_SCREEN_TYPE_COUNT] = { 0, 0 };
static int g_nCombinedAppRefreshCycleOverride[gamescope::GAMESCOPE_SCREEN_TYPE_COUNT] = { 0, 0 };

static void _update_app_target_refresh_cycle()
{
if ( BIsNested() )
{
g_nDynamicRefreshRate[ DRM_SCREEN_TYPE_INTERNAL ] = 0;
g_nSteamCompMgrTargetFPS = g_nCombinedAppRefreshCycleOverride[ DRM_SCREEN_TYPE_INTERNAL ];
g_nDynamicRefreshRate[ gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL ] = 0;
g_nSteamCompMgrTargetFPS = g_nCombinedAppRefreshCycleOverride[ gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL ];
return;
}

static drm_screen_type last_type;
static gamescope::GamescopeScreenType last_type;
static int last_target_fps;
static bool first = true;

drm_screen_type type = drm_get_screen_type( &g_DRM );
gamescope::GamescopeScreenType type = drm_get_screen_type( &g_DRM );
int target_fps = g_nCombinedAppRefreshCycleOverride[type];

if ( !first && type == last_type && last_target_fps == target_fps )
Expand Down Expand Up @@ -975,7 +975,7 @@ static void update_app_target_refresh_cycle()
update_runtime_info();
}

void steamcompmgr_set_app_refresh_cycle_override( drm_screen_type type, int override_fps )
void steamcompmgr_set_app_refresh_cycle_override( gamescope::GamescopeScreenType type, int override_fps )
{
g_nCombinedAppRefreshCycleOverride[ type ] = override_fps;
update_app_target_refresh_cycle();
Expand Down Expand Up @@ -2950,8 +2950,6 @@ paint_all(bool async)

xwm_log.errorf("Failed to prepare 1-layer flip (%s), trying again with previous mode if modeset needed", strerror( -ret ));

drm_rollback( &g_DRM );

// Try once again to in case we need to fall back to another mode.
ret = drm_prepare( &g_DRM, async, &compositeFrameInfo );

Expand Down Expand Up @@ -3144,7 +3142,7 @@ paint_all(bool async)

if ( !maxCLLNits && !maxFALLNits )
{
drm_supports_st2084( &g_DRM, &maxCLLNits, &maxFALLNits );
drm_supports_hdr( &g_DRM, &maxCLLNits, &maxFALLNits );
}

if ( !maxCLLNits && !maxFALLNits )
Expand Down Expand Up @@ -5832,7 +5830,7 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
g_nSteamCompMgrTargetFPS = get_prop( ctx, ctx->root, ctx->atoms.gamescopeFPSLimit, 0 );
update_runtime_info();
}
for (int i = 0; i < DRM_SCREEN_TYPE_COUNT; i++)
for (int i = 0; i < gamescope::GAMESCOPE_SCREEN_TYPE_COUNT; i++)
{
if ( ev->atom == ctx->atoms.gamescopeDynamicRefresh[i] )
{
Expand Down Expand Up @@ -6131,24 +6129,24 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
g_ColorMgmt.pending.chromaticAdaptationMode = ( EChromaticAdaptationMethod ) val;
}
// TODO: Hook up gamescopeColorMuraCorrectionImage for external.
if ( ev->atom == ctx->atoms.gamescopeColorMuraCorrectionImage[DRM_SCREEN_TYPE_INTERNAL] )
if ( ev->atom == ctx->atoms.gamescopeColorMuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] )
{
std::string path = get_string_prop( ctx, ctx->root, ctx->atoms.gamescopeColorMuraCorrectionImage[DRM_SCREEN_TYPE_INTERNAL] );
std::string path = get_string_prop( ctx, ctx->root, ctx->atoms.gamescopeColorMuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] );
if ( set_mura_overlay( path.c_str() ) )
hasRepaint = true;
}
// TODO: Hook up gamescopeColorMuraScale for external.
if ( ev->atom == ctx->atoms.gamescopeColorMuraScale[DRM_SCREEN_TYPE_INTERNAL] )
if ( ev->atom == ctx->atoms.gamescopeColorMuraScale[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] )
{
uint32_t val = get_prop(ctx, ctx->root, ctx->atoms.gamescopeColorMuraScale[DRM_SCREEN_TYPE_INTERNAL], 0);
uint32_t val = get_prop(ctx, ctx->root, ctx->atoms.gamescopeColorMuraScale[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL], 0);
float new_scale = bit_cast<float>(val);
if ( set_mura_scale( new_scale ) )
hasRepaint = true;
}
// TODO: Hook up gamescopeColorMuraCorrectionDisabled for external.
if ( ev->atom == ctx->atoms.gamescopeColorMuraCorrectionDisabled[DRM_SCREEN_TYPE_INTERNAL] )
if ( ev->atom == ctx->atoms.gamescopeColorMuraCorrectionDisabled[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] )
{
bool disabled = !!get_prop(ctx, ctx->root, ctx->atoms.gamescopeColorMuraCorrectionDisabled[DRM_SCREEN_TYPE_INTERNAL], 0);
bool disabled = !!get_prop(ctx, ctx->root, ctx->atoms.gamescopeColorMuraCorrectionDisabled[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL], 0);
if ( g_bMuraCompensationDisabled != disabled ) {
g_bMuraCompensationDisabled = disabled;
hasRepaint = true;
Expand Down Expand Up @@ -7425,8 +7423,8 @@ void init_xwayland_ctx(uint32_t serverId, gamescope_xwayland_server_t *xwayland_

ctx->atoms.gamescopeXWaylandModeControl = XInternAtom( ctx->dpy, "GAMESCOPE_XWAYLAND_MODE_CONTROL", false );
ctx->atoms.gamescopeFPSLimit = XInternAtom( ctx->dpy, "GAMESCOPE_FPS_LIMIT", false );
ctx->atoms.gamescopeDynamicRefresh[DRM_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_DYNAMIC_REFRESH", false );
ctx->atoms.gamescopeDynamicRefresh[DRM_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_DYNAMIC_REFRESH_EXTERNAL", false );
ctx->atoms.gamescopeDynamicRefresh[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_DYNAMIC_REFRESH", false );
ctx->atoms.gamescopeDynamicRefresh[gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_DYNAMIC_REFRESH_EXTERNAL", false );
ctx->atoms.gamescopeLowLatency = XInternAtom( ctx->dpy, "GAMESCOPE_LOW_LATENCY", false );

ctx->atoms.gamescopeFSRFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_FSR_FEEDBACK", false );
Expand Down Expand Up @@ -7490,12 +7488,12 @@ void init_xwayland_ctx(uint32_t serverId, gamescope_xwayland_server_t *xwayland_
ctx->atoms.gamescopeColorAppHDRMetadataFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_APP_HDR_METADATA_FEEDBACK", false );
ctx->atoms.gamescopeColorSliderInUse = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MANAGEMENT_CHANGING_HINT", false );
ctx->atoms.gamescopeColorChromaticAdaptationMode = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_CHROMATIC_ADAPTATION_MODE", false );
ctx->atoms.gamescopeColorMuraCorrectionImage[DRM_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_IMAGE", false );
ctx->atoms.gamescopeColorMuraCorrectionImage[DRM_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_IMAGE_EXTERNAL", false );
ctx->atoms.gamescopeColorMuraScale[DRM_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_SCALE", false );
ctx->atoms.gamescopeColorMuraScale[DRM_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_SCALE_EXTERNAL", false );
ctx->atoms.gamescopeColorMuraCorrectionDisabled[DRM_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_DISABLED", false );
ctx->atoms.gamescopeColorMuraCorrectionDisabled[DRM_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_DISABLED_EXTERNAL", false );
ctx->atoms.gamescopeColorMuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_IMAGE", false );
ctx->atoms.gamescopeColorMuraCorrectionImage[gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_IMAGE_EXTERNAL", false );
ctx->atoms.gamescopeColorMuraScale[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_SCALE", false );
ctx->atoms.gamescopeColorMuraScale[gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_SCALE_EXTERNAL", false );
ctx->atoms.gamescopeColorMuraCorrectionDisabled[gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_DISABLED", false );
ctx->atoms.gamescopeColorMuraCorrectionDisabled[gamescope::GAMESCOPE_SCREEN_TYPE_EXTERNAL] = XInternAtom( ctx->dpy, "GAMESCOPE_COLOR_MURA_CORRECTION_DISABLED_EXTERNAL", false );

ctx->atoms.gamescopeCreateXWaylandServer = XInternAtom( ctx->dpy, "GAMESCOPE_CREATE_XWAYLAND_SERVER", false );
ctx->atoms.gamescopeCreateXWaylandServerFeedback = XInternAtom( ctx->dpy, "GAMESCOPE_CREATE_XWAYLAND_SERVER_FEEDBACK", false );
Expand Down Expand Up @@ -7597,13 +7595,13 @@ void update_vrr_atoms(xwayland_ctx_t *root_ctx, bool force, bool* needs_flush =
*needs_flush = true;
}

bool st2084 = BIsNested() ? vulkan_supports_hdr10() : drm_supports_st2084( &g_DRM );
if ( st2084 != g_bSupportsST2084_CachedValue || force )
bool HDR = BIsNested() ? vulkan_supports_hdr10() : drm_supports_hdr( &g_DRM );
if ( HDR != g_bSupportsHDR_CachedValue || force )
{
uint32_t hdr_value = st2084 ? 1 : 0;
uint32_t hdr_value = HDR ? 1 : 0;
XChangeProperty(root_ctx->dpy, root_ctx->root, root_ctx->atoms.gamescopeDisplaySupportsHDR, XA_CARDINAL, 32, PropModeReplace,
(unsigned char *)&hdr_value, 1 );
g_bSupportsST2084_CachedValue = st2084;
g_bSupportsHDR_CachedValue = HDR;
if (needs_flush)
*needs_flush = true;
}
Expand Down Expand Up @@ -7646,7 +7644,7 @@ void update_mode_atoms(xwayland_ctx_t *root_ctx, bool* needs_flush = nullptr)
if (needs_flush)
*needs_flush = true;

if ( drm_get_screen_type(&g_DRM) == DRM_SCREEN_TYPE_INTERNAL )
if ( drm_get_screen_type(&g_DRM) == gamescope::GAMESCOPE_SCREEN_TYPE_INTERNAL )
{
XDeleteProperty(root_ctx->dpy, root_ctx->root, root_ctx->atoms.gamescopeDisplayModeListExternal);

Expand All @@ -7656,12 +7654,17 @@ void update_mode_atoms(xwayland_ctx_t *root_ctx, bool* needs_flush = nullptr)
return;
}

if ( !g_DRM.pConnector || !g_DRM.pConnector->GetModeConnector() )
{
return;
}

char modes[4096] = "";
int remaining_size = sizeof(modes) - 1;
int len = 0;
for (int i = 0; remaining_size > 0 && i < g_DRM.connector->connector->count_modes; i++)
for (int i = 0; remaining_size > 0 && i < g_DRM.pConnector->GetModeConnector()->count_modes; i++)
{
const auto& mode = g_DRM.connector->connector->modes[i];
const auto& mode = g_DRM.pConnector->GetModeConnector()->modes[i];
int mode_len = snprintf(&modes[len], remaining_size, "%s%dx%d@%d",
i == 0 ? "" : " ",
int(mode.hdisplay), int(mode.vdisplay), int(mode.vrefresh));
Expand Down Expand Up @@ -7974,7 +7977,7 @@ steamcompmgr_main(int argc, char **argv)
}
}

g_bOutputHDREnabled = (g_bSupportsST2084_CachedValue || g_bForceHDR10OutputDebug) && g_bHDREnabled;
g_bOutputHDREnabled = (g_bSupportsHDR_CachedValue || g_bForceHDR10OutputDebug) && g_bHDREnabled;

// Pick our width/height for this potential frame, regardless of how it might change later
// At some point we might even add proper locking so we get real updates atomically instead
Expand Down
2 changes: 1 addition & 1 deletion src/steamcompmgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ MouseCursor *steamcompmgr_get_server_cursor(uint32_t serverId);

extern int g_nAsyncFlipsEnabled;

extern void steamcompmgr_set_app_refresh_cycle_override( drm_screen_type type, int override_fps );
extern void steamcompmgr_set_app_refresh_cycle_override( gamescope::GamescopeScreenType type, int override_fps );
4 changes: 2 additions & 2 deletions src/vblankmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ namespace gamescope

VBlankScheduleTime CVBlankTimer::CalcNextWakeupTime( bool bPreemptive )
{
const drm_screen_type eScreenType = drm_get_screen_type( &g_DRM );
const GamescopeScreenType eScreenType = drm_get_screen_type( &g_DRM );

const int nRefreshRate = GetRefresh();
const uint64_t ulRefreshInterval = kSecInNanoSecs / nRefreshRate;
Expand All @@ -125,7 +125,7 @@ namespace gamescope
// to not account for vertical front porch when dealing with the vblank
// drm_commit is going to target?
// Need to re-test that.
const uint64_t ulRedZone = eScreenType == DRM_SCREEN_TYPE_INTERNAL
const uint64_t ulRedZone = eScreenType == GAMESCOPE_SCREEN_TYPE_INTERNAL
? m_ulVBlankDrawBufferRedZone
: ( m_ulVBlankDrawBufferRedZone * 60 * kSecInNanoSecs ) / ( nRefreshRate * kSecInNanoSecs );

Expand Down
Loading

0 comments on commit 1658b2f

Please sign in to comment.