Skip to content

Commit

Permalink
drm: Check DRM_SYNC_OBJ_CAP and hook up SupportsExplicitSync()
Browse files Browse the repository at this point in the history
  • Loading branch information
brainantifreeze authored and misyltoad committed Apr 4, 2024
1 parent 2db9f4e commit d7aace1
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/drm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ struct drm_color_ctm2 {
};

bool g_bSupportsAsyncFlips = false;
bool g_bSupportsSyncObjs = false;

extern gamescope::GamescopeModeGeneration g_eGamescopeModeGeneration;
extern GamescopePanelOrientation g_DesiredInternalOrientation;
Expand Down Expand Up @@ -1120,18 +1121,23 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh)
drm->cursor_height = 64;
}

int err = drmSyncobjCreate(drm->fd, DRM_SYNCOBJ_CREATE_SIGNALED, &g_uAlwaysSignalledSyncobj);
if (err < 0) {
drm_log.errorf("Failed to create dummy signalled syncobj");
return false;
}
err = drmSyncobjExportSyncFile(drm->fd, g_uAlwaysSignalledSyncobj, &g_nAlwaysSignalledSyncFile);
if (err < 0) {
drm_log.errorf("Failed to create dummy signalled sync file");
return false;
uint64_t cap;
g_bSupportsSyncObjs = drmGetCap(drm->fd, DRM_CAP_SYNCOBJ, &cap) == 0 && cap != 0;
if ( g_bSupportsSyncObjs ) {
int err = drmSyncobjCreate(drm->fd, DRM_SYNCOBJ_CREATE_SIGNALED, &g_uAlwaysSignalledSyncobj);
if (err < 0) {
drm_log.errorf("Failed to create dummy signalled syncobj");
return false;
}
err = drmSyncobjExportSyncFile(drm->fd, g_uAlwaysSignalledSyncobj, &g_nAlwaysSignalledSyncFile);
if (err < 0) {
drm_log.errorf("Failed to create dummy signalled sync file");
return false;
}
} else {
drm_log.errorf("Syncobjs are not supported by the KMS driver");
}

uint64_t cap;
if (drmGetCap(drm->fd, DRM_CAP_ADDFB2_MODIFIERS, &cap) == 0 && cap != 0) {
drm->allow_modifiers = true;
}
Expand Down Expand Up @@ -3410,7 +3416,7 @@ namespace gamescope

virtual bool SupportsExplicitSync() const override
{
return true;
return g_bSupportsSyncObjs;
}

virtual bool IsVisible() const override
Expand Down

0 comments on commit d7aace1

Please sign in to comment.