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

allow gamescope to work on gpus that don't support the present_wait extension #6

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
35 changes: 27 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ bool BIsSDLSession( void )
}


static bool initOutput(int preferredWidth, int preferredHeight, int preferredRefresh);
static bool initOutput(int preferredWidth, int preferredHeight, int preferredRefresh, bool bSupportsPresentWait);
static void steamCompMgrThreadRun(int argc, char **argv);

static std::string build_optstring(const struct option *options)
Expand Down Expand Up @@ -735,25 +735,44 @@ int main(int argc, char **argv)
g_pOriginalDisplay = getenv("DISPLAY");
g_pOriginalWaylandDisplay = getenv("WAYLAND_DISPLAY");
g_bIsNested = g_pOriginalDisplay != NULL || g_pOriginalWaylandDisplay != NULL;


const bool bSupportsPresentWait = checkForPresentWaitExt();

if ( BIsSDLSession() && g_pOriginalWaylandDisplay != NULL )
{
if (CheckWaylandPresentationTime())
const bool bCompositor_supports_present_wait = CheckWaylandPresentationTime();
if (bCompositor_supports_present_wait && bSupportsPresentWait)
{
// Default to SDL_VIDEODRIVER wayland under Wayland and force enable vk_khr_present_wait
// (not enabled by default in Mesa because instance does not know if Wayland
// compositor supports wp_presentation, but we can check that ourselves.)
setenv("vk_khr_present_wait", "true", 0);
setenv("SDL_VIDEODRIVER", "wayland", 0);
}
else
else if (bSupportsPresentWait)
{
fprintf(stderr,
"Your Wayland compositor does NOT support wp_presentation/presentation-time which is required for VK_KHR_present_wait and VK_KHR_present_id.\n"
"Please complain to your compositor vendor for support. Falling back to X11 window with less accurate present wait.\n");
setenv("SDL_VIDEODRIVER", "x11", 1);
}
else if (!bSupportsPresentWait)
{
fprintf(stderr,
"Notice: GPU device does not support present_wait extension\n"
"continuing with present_wait disabled.\n\n");
setenv("vk_khr_present_wait", "false", 1);
if (bCompositor_supports_present_wait)
setenv("SDL_VIDEODRIVER", "wayland", 0); //doing this for consistency, shouldn't cause any issues
}
}
else if (!bSupportsPresentWait)
{
fprintf(stderr,
"Notice: GPU device does not support present_wait extension\n"
"continuing with present_wait disabled.\n\n");
setenv("vk_khr_present_wait", "false", 1);
}

if ( !wlsession_init() )
{
Expand Down Expand Up @@ -786,7 +805,7 @@ int main(int argc, char **argv)
}
#endif

if ( !initOutput( g_nPreferredOutputWidth, g_nPreferredOutputHeight, g_nNestedRefresh ) )
if ( !initOutput( g_nPreferredOutputWidth, g_nPreferredOutputHeight, g_nNestedRefresh, bSupportsPresentWait ) )
{
fprintf( stderr, "Failed to initialize output\n" );
return 1;
Expand Down Expand Up @@ -910,7 +929,7 @@ static void steamCompMgrThreadRun(int argc, char **argv)
pthread_kill( g_mainThread, SIGINT );
}

static bool initOutput( int preferredWidth, int preferredHeight, int preferredRefresh )
static bool initOutput( int preferredWidth, int preferredHeight, int preferredRefresh, bool bSupportsPresentWait )
{
VkInstance instance = vulkan_create_instance();

Expand Down Expand Up @@ -960,7 +979,7 @@ static bool initOutput( int preferredWidth, int preferredHeight, int preferredRe
}
}

if ( !vulkan_init( instance, surface ) )
if ( !vulkan_init( instance, surface, bSupportsPresentWait ) )
{
fprintf( stderr, "Failed to initialize Vulkan\n" );
return false;
Expand All @@ -970,7 +989,7 @@ static bool initOutput( int preferredWidth, int preferredHeight, int preferredRe
}
else
{
if ( !vulkan_init( instance, VK_NULL_HANDLE ) )
if ( !vulkan_init( instance, VK_NULL_HANDLE, bSupportsPresentWait ) )
{
fprintf( stderr, "Failed to initialize Vulkan\n" );
return false;
Expand Down
Loading
Loading