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

Add --vulkan-debug-extension switch to provide object names to vulkan validation layer output #1102

Closed
wants to merge 16 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
27 changes: 21 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const struct option *gamescope_options = (struct option[]){
{ "synchronous-x11", no_argument, nullptr, 0 },
{ "debug-hud", no_argument, nullptr, 'v' },
{ "debug-events", no_argument, nullptr, 0 },
{ "vulkan-debug-extension", no_argument, 0},
{ "steam", no_argument, nullptr, 'e' },
{ "force-composition", no_argument, nullptr, 'c' },
{ "composite-debug", no_argument, nullptr, 0 },
Expand Down Expand Up @@ -229,7 +230,8 @@ const char usage[] =
" --disable-xres disable XRes for PID lookup\n"
" --hdr-debug-force-support forces support for HDR, etc even if the display doesn't support it. HDR clients will be outputted as SDR still in that case.\n"
" --hdr-debug-force-output forces support and output to HDR10 PQ even if the output does not support it (will look very wrong if it doesn't)\n"
" --hdr-debug-heatmap displays a heatmap-style debug view of HDR luminence across the scene in nits."
" --hdr-debug-heatmap displays a heatmap-style debug view of HDR luminence across the scene in nits.\n"
" --vulkan-debug-extension loads vulkan debug extension(s). Supplies object names to validation layer messages."
"\n"
"Reshade shader options:\n"
" --reshade-effect sets the name of a reshade shader to use in either /usr/share/gamescope/reshade/Shaders or ~/.local/share/gamescope/reshade/Shaders\n"
Expand Down Expand Up @@ -326,7 +328,7 @@ bool BIsSDLSession( void )
}


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

static std::string build_optstring(const struct option *options)
Expand Down Expand Up @@ -436,6 +438,10 @@ static void handle_signal( int sig )
}

fprintf( stderr, "gamescope: Received %s signal, attempting shutdown!\n", strsignal(sig) );

if (vulkan_run_at_exit != nullptr)
(*vulkan_run_at_exit)();

g_bRun = false;
break;
case SIGUSR1:
Expand Down Expand Up @@ -554,7 +560,7 @@ int main(int argc, char **argv)

static std::string optstring = build_optstring(gamescope_options);
gamescope_optstring = optstring.c_str();

bool vulkanDebugEXT = false;
int o;
int opt_index = -1;
while ((o = getopt_long(argc, argv, gamescope_optstring, gamescope_options, &opt_index)) != -1)
Expand Down Expand Up @@ -612,6 +618,15 @@ int main(int argc, char **argv)
g_bDebugLayers = true;
} else if (strcmp(opt_name, "disable-color-management") == 0) {
g_bForceDisableColorMgmt = true;
} else if (strcmp(opt_name, "vulkan-debug-extension") == 0) {
#ifndef NDEBUG
vulkanDebugEXT = true;
#else
fprintf(stderr, "gamescope is not compiled with --vulkan-debug-extension supported\n"
"to enable it, recompile gamescope after reconfiguring it with:\n"
"meson --reconfigure build -Db_ndebug=false\n");
exit(1);
#endif
} else if (strcmp(opt_name, "xwayland-count") == 0) {
g_nXWaylandCount = atoi( optarg );
} else if (strcmp(opt_name, "composite-debug") == 0) {
Expand Down Expand Up @@ -781,7 +796,7 @@ int main(int argc, char **argv)
}
#endif

if ( !initOutput( g_nPreferredOutputWidth, g_nPreferredOutputHeight, g_nNestedRefresh ) )
if ( !initOutput( g_nPreferredOutputWidth, g_nPreferredOutputHeight, g_nNestedRefresh, vulkanDebugEXT ) )
{
fprintf( stderr, "Failed to initialize output\n" );
return 1;
Expand Down Expand Up @@ -905,9 +920,9 @@ 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 vulkanDebugEXT )
{
VkInstance instance = vulkan_create_instance();
VkInstance instance = vulkan_create_instance(vulkanDebugEXT);

if ( BIsNested() )
{
Expand Down
Loading
Loading