From 041fee048467dfd57b3c5fe604fdf603092aca33 Mon Sep 17 00:00:00 2001 From: Kurt Kartaltepe Date: Sat, 11 Feb 2023 13:52:03 -0800 Subject: [PATCH] libobs-opengl: Accelerate dmabuf import Previously we would actually initialize a texture memory that would then also have to be deleted when we bound the EGLImage to the texture during dmabuf import. Instead simply do not create the dummy texture memory. One odd thing is that we must still query the texture to ensure its initialized or binding the EGLImage will not work. So we leave the TEXTURE_MAX_LEVEL check. This makes screencapture up to 100x faster on discrete intel cards and likely has some performance benefit for amd/integrated cards. Without this dmabufs are actually slower than shared memory for these intel cards. --- libobs-opengl/gl-egl-common.c | 2 +- libobs-opengl/gl-texture2d.c | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/libobs-opengl/gl-egl-common.c b/libobs-opengl/gl-egl-common.c index fb8a6b9df..f06cd1901 100644 --- a/libobs-opengl/gl-egl-common.c +++ b/libobs-opengl/gl-egl-common.c @@ -186,7 +186,7 @@ struct gs_texture *gl_egl_create_texture_from_eglimage( struct gs_texture *texture = NULL; texture = gs_texture_create(width, height, color_format, 1, NULL, - GS_DYNAMIC); + GS_GL_DUMMYTEX); const GLuint gltex = *(GLuint *)gs_texture_get_obj(texture); gl_bind_texture(GL_TEXTURE_2D, gltex); diff --git a/libobs-opengl/gl-texture2d.c b/libobs-opengl/gl-texture2d.c index eec3534cd..6c4aafb6f 100644 --- a/libobs-opengl/gl-texture2d.c +++ b/libobs-opengl/gl-texture2d.c @@ -110,16 +110,7 @@ gs_texture_t *device_texture_create(gs_device_t *device, uint32_t width, if (!gl_bind_texture(GL_TEXTURE_2D, tex->base.texture)) goto fail; - uint32_t row_size = - tex->width * gs_get_format_bpp(tex->base.format); - uint32_t tex_size = tex->height * row_size / 8; - bool compressed = gs_is_compressed_format(tex->base.format); - bool did_init = gl_init_face(GL_TEXTURE_2D, tex->base.gl_type, - 1, tex->base.gl_format, - tex->base.gl_internal_format, - compressed, tex->width, - tex->height, tex_size, NULL); - did_init = + bool did_init = gl_tex_param_i(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); bool did_unbind = gl_bind_texture(GL_TEXTURE_2D, 0);