From 429042fb705ef81fb8b1958c1de7655d5d915f55 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Mon, 22 Jul 2024 18:08:10 +0200 Subject: [PATCH] gstqsg6material: create OESExternal RhiTexture if necessary The RhiTexture must be created with the OESExternal flag, if the gl_mem is a OESExternal buffer. Otherwise, Qt will create a Texture 2D texture and ignore the previously negotiated texture target. Part-of: --- subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc b/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc index 0c6b4fa3b9..a652b8d979 100644 --- a/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc +++ b/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc @@ -561,6 +561,7 @@ GstQSGMaterial::bind(GstQSGMaterialShader *shader, QRhi * rhi, QRhiResourceUpdat GstQSGTexture *ret; QRhiTexture *rhi_tex; QSize tex_size; + QRhiTexture::Flags flags = {}; qt_context = GST_GL_CONTEXT (g_weak_ref_get (&this->qt_context_ref_)); if (!qt_context) @@ -585,7 +586,10 @@ GstQSGMaterial::bind(GstQSGMaterialShader *shader, QRhi * rhi, QRhiResourceUpdat tex_size = QSize(gst_gl_memory_get_texture_width(gl_mem), gst_gl_memory_get_texture_height (gl_mem)); - rhi_tex = rhi->newTexture (video_format_to_rhi_format (v_format, plane), tex_size, 1, {}); + if (gl_mem->tex_target == GST_GL_TEXTURE_TARGET_EXTERNAL_OES) + flags |= QRhiTexture::ExternalOES; + + rhi_tex = rhi->newTexture (video_format_to_rhi_format (v_format, plane), tex_size, 1, flags); rhi_tex->createFrom({(guint64) tex_id, 0}); sync_meta = gst_buffer_get_gl_sync_meta (this->sync_buffer_); @@ -596,7 +600,8 @@ GstQSGMaterial::bind(GstQSGMaterialShader *shader, QRhi * rhi, QRhiResourceUpdat gst_gl_sync_meta_wait (sync_meta, qt_context); - GST_LOG ("%p binding GL texture %u for plane %d", this, tex_id, plane); + GST_LOG ("%p binding GL texture %u (%s) for plane %d", + this, tex_id, gst_gl_texture_target_to_string(gl_mem->tex_target), plane); out: if (G_UNLIKELY (use_dummy_tex)) {