From 4ad0118f359d954f9e5276ca6bf29a51e6dfa559 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 26 Jul 2023 02:31:12 +0200 Subject: High priority egl context if possible, use eglBindAPI(EGL_OPENGL_ES_API) --- TODO | 5 +---- include/egl.h | 7 +++++-- src/egl.c | 7 ++++--- src/utils.c | 13 +++++++++---- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/TODO b/TODO index 316e492..325f03c 100644 --- a/TODO +++ b/TODO @@ -37,12 +37,9 @@ Window capture doesn't work properly in _control_ game after going from pause me Fix constant framerate not working properly on amd/intel because capture framerate gets locked to the same framerate as game framerate, which doesn't work well when you need to encode multiple duplicate frames. We can skip multiple encode if we duplicate frame once and then use that same frame data as the difference between frames will be exactly the same, but hevc complains about that. Is there a way to make hevc shut up? -JPEG color range on amd seems to produce too bright video with h264 but not hevc, why? - Properly handle monitor reconfiguration (kms vaapi, nvfbc). Better configure vaapi. The file size is too large. -Better colors for vaapi. It looks a bit off when recording vscode for example. Clear vaapi surface (for focused window). @@ -87,4 +84,4 @@ Support vulkan video encoding. That might workaround forced p2 state nvidia driv Enable opus/flac again. It's broken right now when merging audio inputs. The audio gets a lot of static noise! -It may be possible to improve color conversion rgb->yuv shader for color edges by biasing colors to an edge, instead of letting color overlaying with bilinear filtering handle it. \ No newline at end of file +It may be possible to improve color conversion rgb->yuv shader for color edges by biasing colors to an edge, instead of letting color overlaying with bilinear filtering handle it. diff --git a/include/egl.h b/include/egl.h index d47fbfb..b50eee0 100644 --- a/include/egl.h +++ b/include/egl.h @@ -38,6 +38,7 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define EGL_BUFFER_SIZE 0x3020 #define EGL_RENDERABLE_TYPE 0x3040 #define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_OPENGL_ES_API 0x30A0 #define EGL_NONE 0x3038 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 #define EGL_BACK_BUFFER 0x3084 @@ -59,8 +60,10 @@ typedef void (*__eglMustCastToProperFunctionPointerType)(void); #define EGL_ALPHA_SIZE 0x3021 #define EGL_BLUE_SIZE 0x3022 #define EGL_GREEN_SIZE 0x3023 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_PBUFFER_BIT 0x0001 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 #define GL_FLOAT 0x1406 #define GL_FALSE 0 diff --git a/src/egl.c b/src/egl.c index 3892cdc..2875f88 100644 --- a/src/egl.c +++ b/src/egl.c @@ -214,12 +214,13 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) { const int32_t attr[] = { EGL_BUFFER_SIZE, 24, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NONE + EGL_NONE, EGL_NONE }; const int32_t ctxattr[] = { EGL_CONTEXT_CLIENT_VERSION, 2, - EGL_NONE + EGL_CONTEXT_PRIORITY_LEVEL_IMG, EGL_CONTEXT_PRIORITY_HIGH_IMG, + EGL_NONE, EGL_NONE }; if(wayland) { @@ -251,7 +252,7 @@ static bool gsr_egl_create_window(gsr_egl *self, bool wayland) { } } - self->eglBindAPI(EGL_OPENGL_ES2_BIT); + self->eglBindAPI(EGL_OPENGL_ES_API); self->egl_display = self->eglGetDisplay(self->wayland.dpy ? (EGLNativeDisplayType)self->wayland.dpy : (EGLNativeDisplayType)self->x11.dpy); if(!self->egl_display) { diff --git a/src/utils.c b/src/utils.c index 88893ac..16e928a 100644 --- a/src/utils.c +++ b/src/utils.c @@ -210,6 +210,7 @@ bool get_monitor_by_name(void *connection, gsr_connection_type connection_type, } bool gl_get_gpu_info(gsr_egl *egl, gsr_gpu_info *info) { + const char *software_renderers[] = { "llvmpipe", "SWR", "softpipe", NULL }; bool supported = true; const unsigned char *gl_vendor = egl->glGetString(GL_VENDOR); const unsigned char *gl_renderer = egl->glGetString(GL_RENDERER); @@ -222,10 +223,14 @@ bool gl_get_gpu_info(gsr_egl *egl, gsr_gpu_info *info) { goto end; } - if(gl_renderer && strstr((const char*)gl_renderer, "llvmpipe")) { - fprintf(stderr, "gsr error: your opengl environment is not properly setup. It's using llvmpipe (cpu fallback) for opengl instead of your graphics card\n"); - supported = false; - goto end; + if(gl_renderer) { + for(int i = 0; software_renderers[i]; ++i) { + if(strstr((const char*)gl_renderer, software_renderers[i])) { + fprintf(stderr, "gsr error: your opengl environment is not properly setup. It's using %s (software rendering) for opengl instead of your graphics card. Please make sure your graphics driver is properly installed\n", software_renderers[i]); + supported = false; + goto end; + } + } } if(strstr((const char*)gl_vendor, "AMD")) -- cgit v1.2.3