Handling GLContext in GstAggregator Element (Rust)
daniel.pendse at spiideo.com
Tue Dec 6 11:27:42 UTC 2022
Thanks for a great answer, appreciate it. We got it working by retrieving
the gl context for a specific thread per your proposals.
Right now it works because we already use glupload prior in the pipeline,
but will need to handle the context more properly i.e. create one if it
Yeah I am aware of those classes, which absolutely would have been
very helpful to use instead.
Also new to the gstreamer community but definitely would like to contribute
at some point.
On Fri, 25 Nov 2022 at 04:20, Matthew Waters <ystreet00 at gmail.com> wrote:
> In order to properly integrate with any other GStreamer OpenGL element,
> you need to retrieve the OpenGL display and context objects from
> elsewhere in the pipeline through the GstContext mechanism.
> In C, this is:
> for ensuring you have the display and the application provided context.
> for handling GstElementClass::set_context.
> for responding to queries of type GST_QUERY_CONTEXT for providing the
> display, other_context and context in use to the surrounding peers.
> for asking the surrounding elements for the GL context they are using.
> If all that fails, then there is
> for retrieving the GL context for a specific thread (NULL can be
> provided to get any GL context).
> Ultimately however, you are reimplementing what has been implemented by
> these two classes:
> and time would be better spent making those classes public API and then
> generating the appropriate Rust bindings.
> On 24/11/22 21:24, Daniel Pendse via gstreamer-devel wrote:
> > Hi!
> > Working on a project to perform GL rendering based on multiple inputs
> > in GLMemory using the gstreamer rust bindings.
> > From previous suggestions we decided to use the GstAggregator as a
> > base class for our element. (Rust impl exists)
> > (See prev thread for more context:
> > I have stumbled upon some issues with handling the GLContext when
> > creating custom shaders. When I try to create a GLSL Stage I fail with:
> > * (gst-launch-1.0:93053): GStreamer-GL-CRITICAL **: 10:10:35.633:
> > gst_gl_context_thread_add: assertion 'GST_IS_GL_CONTEXT (context)’ failed
> > It might seem that I fail to crate the context somehow or I don’t set
> > it properly. How should the GLContext be handled using the aggregator
> > as a base class?
> > I simply create the GLContext in the start method for my element and
> > intent to pass the context trough to the methods where I intend to use
> > GL calls.
> > // fn start
> > let gl_display = GLDisplay::new();
> > let gl_context = GLContext::new(&gl_display);
> > gl_context.activate(true).unwrap();
> > let shader_program = GLShader::new(gl_context);
> > let vertex_shader = GLSLStage::new_default_vertex(gl_context); // Crash
> > And also can I expect to input GLMemory and output GLMemory using this
> > baseclass by using glupload/gldownload?
> > I am guessing that there might be a performance hit if I don’t
> > input/output GLMemory, and instead handle that in the element..
> > I have previous successfully managed to get gl textures passing
> > through the element like so feels like I am not handling the context
> > correct.
> > (gst-launch-1.0 videotestsrc ! ... ! glupload ! <ELEMENT> !
> > gldownload ! ... ! autovideosink
> > Any tips and help is greatly appreciated!
> > Daniel Pendse
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gstreamer-devel