opengl context sharing with gstreamer
Lusine Hayrapetyan
lusinehayrapetyan1992 at gmail.com
Fri Sep 17 14:45:20 UTC 2021
Hi Matt,
1. Actually I don't use the result of
'gst_gl_display_egl_new_with_egl_display()', I only use:
*state->x_gst_display =
gst_gl_display_x11_new_with_display(state->xdisplay);*
And then use *state->**x_gst_display in *gst_gl_context_new_wrapped,
gst_gl_display_create_context
and gst_gl_display_add_context functions.
Please see create_gst_shared_context() function.
Is this wrong?
2. I'm using the following environment variables for advertising that to
GStreamer, isn't this the same?
export GST_GL_WINDOW=x11
export GST_GL_PLATFORM=egl
export GST_GL_API=gles2
3. Thanks for the info. I've changed save_gst_tga:
const GstGLFuncs *gl = state->sharedContext->gl_vtable;
gl->ReadPixels( 0, 0, 300, 300, GL_RGBA, GL_UNSIGNED_BYTE, buffer1 );
// ... Save the buffer.
4. Got it, thanks. Removed activate.
Best Regards,
Lusine
On Fri, Sep 17, 2021 at 10:21 AM Matthew Waters <ystreet00 at gmail.com> wrote:
> 1. Don't do 'gst_gl_display_egl_new_with_egl_display()' yourself
> manually. You want to use gst_gl_display_egl_from_gl_display() from the
> X11-wrapped GstGLDisplay.
> 2. You are creating an OpenGL ES 2.0 context but not advertising that to
> GStreamer with gst_gl_display_filter_gl_api(). GStreamer may be creating
> another context type. GST_DEBUG=3.gl*:7 will tell you.
> 3. You are not using the OpenGL context-specific function pointers. Each
> OpenGL context can return completely different OpenGL function pointers
> that are specific to each OpenGL context. Calling the wrong function
> pointers is undefined behaviour. This is gst_gl_context->gl_vtable for
> GStreamer.
> 4. There is no need to call gst_gl_context_activate() in save_gst_tga().
> gst_gl_context_thread_add() runs your function on the correct thread with
> the correct OpenGL context current already. If you change that, you must
> reset of course.
> 5. A gl tracing tool would also help you drill down into exactly what is
> happening. e.g. apitrace.
>
> Cheers
> -Matt
>
> On 17/9/21 2:23 am, Lusine Hayrapetyan via gstreamer-devel wrote:
>
> Hi Folks,
>
> I'm experimenting with gstreamer context sharing mechanism.
> I have *EGLContext context; *and creating gstreamer shared context from
> it with gst_gl_display_create_context()
>
> Then I want to access the texture which is created in *EGLContext* from
> gstreamer shared context.
> That is why I'm using gst_gl_context_thread_add to activate shared context
> and save the texture:
>
> gst_gl_context_thread_add(
> state->sharedContext,
> (GstGLContextThreadFunc)save_gst_tga,
> state
> );
>
> // Activate gstreamer context and save the texture to tga file.
> static bool save_gst_tga(GstGLContext * context, APP_STATE_T * state)
> {
> if (!gst_gl_context_activate(state->sharedContext, true))
> g_print("gst_gl_context_activate(true) returned error %d\n",
> eglGetError());
>
> // Gstreamer context is activated in gstreamer thread, now save the
> texture.
> // But this produces an empty file!!!
> return save_tga(state, "tga_file_gst.tga");
> }
>
> In save_gst_tga I activate gstreamer shared context and save the texture
> but it's empty. Am I missing something?
> I've posted the whole code here:
> https://github.com/LusineH/gstreamer_shared_context/blob/main/testegl.c
>
> Regards,
> Lusine
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20210917/307665fc/attachment.htm>
More information about the gstreamer-devel
mailing list