aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/egl.c37
-rw-r--r--src/main.cpp26
2 files changed, 38 insertions, 25 deletions
diff --git a/src/egl.c b/src/egl.c
index 249fe53..682810d 100644
--- a/src/egl.c
+++ b/src/egl.c
@@ -344,25 +344,18 @@ static bool gsr_egl_load_gl(gsr_egl *self, void *library) {
return true;
}
-// #define GL_DEBUG_TYPE_ERROR 0x824C
-// static void debug_callback( unsigned int source,
-// unsigned int type,
-// unsigned int id,
-// unsigned int severity,
-// int length,
-// const char* message,
-// const void* userParam )
-// {
-// (void)source;
-// (void)id;
-// (void)length;
-// (void)userParam;
-// fprintf( stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
-// ( type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : "" ),
-// type, severity, message );
-// }
-
-bool gsr_egl_load(gsr_egl *self, gsr_window *window, bool is_monitor_capture) {
+#define GL_DEBUG_TYPE_ERROR 0x824C
+#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
+static void debug_callback(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, int length, const char* message, const void* userParam) {
+ (void)source;
+ (void)id;
+ (void)length;
+ (void)userParam;
+ if(severity != GL_DEBUG_SEVERITY_NOTIFICATION)
+ fprintf(stderr, "gsr info: gl callback: %s type = 0x%x, severity = 0x%x, message = %s\n", type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : "", type, severity, message);
+}
+
+bool gsr_egl_load(gsr_egl *self, gsr_window *window, bool is_monitor_capture, bool enable_debug) {
memset(self, 0, sizeof(gsr_egl));
self->context_type = GSR_GL_CONTEXT_TYPE_EGL;
self->window = window;
@@ -418,8 +411,10 @@ bool gsr_egl_load(gsr_egl *self, gsr_window *window, bool is_monitor_capture) {
self->glEnable(GL_BLEND);
self->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- //self->glEnable(GL_DEBUG_OUTPUT);
- //self->glDebugMessageCallback(debug_callback, NULL);
+ if(enable_debug) {
+ self->glEnable(GL_DEBUG_OUTPUT);
+ self->glDebugMessageCallback(debug_callback, NULL);
+ }
return true;
diff --git a/src/main.cpp b/src/main.cpp
index 6b07a76..058ca69 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1069,7 +1069,7 @@ static void open_video_hardware(AVCodecContext *codec_context, VideoQuality vide
static void usage_header() {
const bool inside_flatpak = getenv("FLATPAK_ID") != NULL;
const char *program_name = inside_flatpak ? "flatpak run --command=gpu-screen-recorder com.dec05eba.gpu_screen_recorder" : "gpu-screen-recorder";
- printf("usage: %s -w <window_id|monitor|focused|portal> [-c <container_format>] [-s WxH] -f <fps> [-a <audio_input>] [-q <quality>] [-r <replay_buffer_size_sec>] [-k h264|hevc|av1|vp8|vp9|hevc_hdr|av1_hdr|hevc_10bit|av1_10bit] [-ac aac|opus|flac] [-ab <bitrate>] [-oc yes|no] [-fm cfr|vfr|content] [-bm auto|qp|vbr|cbr] [-cr limited|full] [-df yes|no] [-sc <script_path>] [-cursor yes|no] [-keyint <value>] [-restore-portal-session yes|no] [-portal-session-token-filepath filepath] [-encoder gpu|cpu] [-o <output_file>] [--list-capture-options [card_path] [vendor]] [--list-audio-devices] [--list-application-audio] [-v yes|no] [--version] [-h|--help]\n", program_name);
+ printf("usage: %s -w <window_id|monitor|focused|portal> [-c <container_format>] [-s WxH] -f <fps> [-a <audio_input>] [-q <quality>] [-r <replay_buffer_size_sec>] [-k h264|hevc|av1|vp8|vp9|hevc_hdr|av1_hdr|hevc_10bit|av1_10bit] [-ac aac|opus|flac] [-ab <bitrate>] [-oc yes|no] [-fm cfr|vfr|content] [-bm auto|qp|vbr|cbr] [-cr limited|full] [-df yes|no] [-sc <script_path>] [-cursor yes|no] [-keyint <value>] [-restore-portal-session yes|no] [-portal-session-token-filepath filepath] [-encoder gpu|cpu] [-o <output_file>] [--list-capture-options [card_path] [vendor]] [--list-audio-devices] [--list-application-audio] [-v yes|no] [-gl-debug yes|no] [--version] [-h|--help]\n", program_name);
fflush(stdout);
}
@@ -1229,6 +1229,9 @@ static void usage_full() {
printf("\n");
printf(" -v Prints fps and damage info once per second. Optional, set to 'yes' by default.\n");
printf("\n");
+ printf(" -gl-debug\n");
+ printf(" Print opengl debug output. Optional, set to 'no' by default.\n");
+ printf("\n");
printf(" -h, --help\n");
printf(" Show this help.\n");
printf("\n");
@@ -2122,7 +2125,7 @@ static void info_command() {
}
gsr_egl egl;
- if(!gsr_egl_load(&egl, window, false)) {
+ if(!gsr_egl_load(&egl, window, false, false)) {
fprintf(stderr, "gsr error: failed to load opengl\n");
_exit(22);
}
@@ -2234,7 +2237,7 @@ static void list_capture_options_command(const char *card_path, gsr_gpu_vendor v
list_supported_capture_options(window, card_path, true);
} else {
gsr_egl egl;
- if(!gsr_egl_load(&egl, window, false)) {
+ if(!gsr_egl_load(&egl, window, false, false)) {
fprintf(stderr, "gsr error: failed to load opengl\n");
_exit(1);
}
@@ -3060,6 +3063,7 @@ int main(int argc, char **argv) {
{ "-bm", Arg { {}, true, false } },
{ "-pixfmt", Arg { {}, true, false } },
{ "-v", Arg { {}, true, false } },
+ { "-gl-debug", Arg { {}, true, false } },
{ "-df", Arg { {}, true, false } },
{ "-sc", Arg { {}, true, false } },
{ "-cr", Arg { {}, true, false } },
@@ -3227,6 +3231,20 @@ int main(int argc, char **argv) {
usage();
}
+ bool gl_debug = false;
+ const char *gl_debug_str = args["-gl-debug"].value();
+ if(!gl_debug_str)
+ gl_debug_str = "no";
+
+ if(strcmp(gl_debug_str, "yes") == 0) {
+ gl_debug = true;
+ } else if(strcmp(gl_debug_str, "no") == 0) {
+ gl_debug = false;
+ } else {
+ fprintf(stderr, "Error: -gl-debug should either be either 'yes' or 'no', got: '%s'\n", gl_debug_str);
+ usage();
+ }
+
bool record_cursor = true;
const char *record_cursor_str = args["-cursor"].value();
if(!record_cursor_str)
@@ -3409,7 +3427,7 @@ int main(int argc, char **argv) {
const bool is_monitor_capture = strcmp(window_str.c_str(), "focused") != 0 && !is_portal_capture && contains_non_hex_number(window_str.c_str());
gsr_egl egl;
- if(!gsr_egl_load(&egl, window, is_monitor_capture)) {
+ if(!gsr_egl_load(&egl, window, is_monitor_capture, gl_debug)) {
fprintf(stderr, "gsr error: failed to load opengl\n");
_exit(1);
}