From 5f6f755f5bb04841579a98e68e5c9b9c8d537c37 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Wed, 24 Jul 2024 10:58:30 +0200 Subject: [PATCH] gstqsg6material: pass the texture-target from caps to shader The Material has to select the correct Shader depending on the negotiated texture target. Pass the texture target from the caps to the shader creation as it is already done for the pixel format. Part-of: --- .../ext/qt6/gstqsg6material.cc | 18 +++++++++++++++--- .../gst-plugins-good/ext/qt6/gstqsg6material.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc b/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc index a652b8d979..60ef42edba 100644 --- a/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc +++ b/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.cc @@ -258,7 +258,7 @@ GstQSGTexture::rhiTexture() const class GstQSGMaterialShader : public QSGMaterialShader { public: - GstQSGMaterialShader(GstVideoFormat v_format); + GstQSGMaterialShader(GstVideoFormat v_format, GstGLTextureTarget target); ~GstQSGMaterialShader(); bool updateUniformData(RenderState &state, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override; @@ -269,7 +269,8 @@ private: QSGTexture *m_textures[GST_VIDEO_MAX_PLANES]; }; -GstQSGMaterialShader::GstQSGMaterialShader(GstVideoFormat v_format) +GstQSGMaterialShader::GstQSGMaterialShader(GstVideoFormat v_format, + GstGLTextureTarget target) : v_format(v_format) { const gchar *frag_shader; @@ -441,17 +442,28 @@ QSGMaterialShader * GstQSGMaterial::createShader(QSGRendererInterface::RenderMode renderMode) const { GstVideoFormat v_format = GST_VIDEO_INFO_FORMAT (&this->v_info); + GstGLTextureTarget target = this->tex_target; - return new GstQSGMaterialShader(v_format); + return new GstQSGMaterialShader(v_format, target); } /* only called from the streaming thread with scene graph thread blocked */ void GstQSGMaterial::setCaps (GstCaps * caps) { + GstStructure *s; + const gchar *target_str; + GST_LOG ("%p setCaps %" GST_PTR_FORMAT, this, caps); gst_video_info_from_caps (&this->v_info, caps); + + s = gst_caps_get_structure (caps, 0); + target_str = gst_structure_get_string (s, "texture-target"); + if (!target_str) + target_str = GST_GL_TEXTURE_TARGET_2D_STR; + + this->tex_target = gst_gl_texture_target_from_string(target_str); } /* only called from the streaming thread with scene graph thread blocked */ diff --git a/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.h b/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.h index 42a2a87768..a2c703ef78 100644 --- a/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.h +++ b/subprojects/gst-plugins-good/ext/qt6/gstqsg6material.h @@ -68,6 +68,7 @@ private: GstBuffer * sync_buffer_; GstMemory * mem_; GstVideoInfo v_info; + GstGLTextureTarget tex_target; GstVideoFrame v_frame; QSGTexture::Filtering m_filtering; };