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

DRMBackend: Add libliftoff log handler #1584

Merged
Merged
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
27 changes: 25 additions & 2 deletions src/Backends/DRMBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ extern GamescopePanelOrientation g_DesiredInternalOrientation;
extern bool g_bForceDisableColorMgmt;

static LogScope drm_log( "drm" );
static LogScope liftoff_log_scope( "liftoff" );

static std::unordered_map< std::string, std::string > pnps = {};

Expand Down Expand Up @@ -1094,6 +1095,27 @@ extern bool env_to_bool(const char *env);
uint32_t g_uAlwaysSignalledSyncobj = 0;
int g_nAlwaysSignalledSyncFile = -1;

static void
gamescope_liftoff_log_handler(enum liftoff_log_priority liftoff_priority, const char *fmt, va_list args)
{
enum LogPriority priority = LOG_DEBUG;

switch ( liftoff_priority )
{
case LIFTOFF_ERROR:
priority = LOG_ERROR;
break;
case LIFTOFF_DEBUG:
priority = LOG_DEBUG;
break;
case LIFTOFF_SILENT:
priority = LOG_SILENT;
break;
}

liftoff_log_scope.vlogf(priority, fmt, args);
}

bool init_drm(struct drm_t *drm, int width, int height, int refresh)
{
load_pnps();
Expand Down Expand Up @@ -1267,8 +1289,9 @@ bool init_drm(struct drm_t *drm, int width, int height, int refresh)
std::thread flip_handler_thread( flip_handler_thread_run );
flip_handler_thread.detach();

if ( drm->bUseLiftoff )
liftoff_log_set_priority(g_bDebugLayers ? LIFTOFF_DEBUG : LIFTOFF_ERROR);
// Set log priority to the max, liftoff_log_scope will filter for us.
liftoff_log_set_priority(LIFTOFF_DEBUG);
liftoff_log_set_handler(gamescope_liftoff_log_handler);

hdr_output_metadata sdr_metadata;
memset(&sdr_metadata, 0, sizeof(sdr_metadata));
Expand Down