[vlc-devel] [PATCH 1/2] vout/opengl: add direct rendering support (OpenGL 4.4)

Rémi Denis-Courmont remi at remlab.net
Tue Jan 3 18:48:20 CET 2017


Le tiistaina 3. tammikuuta 2017, 17.18.57 EET Hugo Beauzée-Luyssen a écrit :
> > diff --git a/modules/video_output/opengl/converters.c
> > b/modules/video_output/opengl/converters.c index 8b6b4b40a6..f278bb96ae
> > 100644
> > --- a/modules/video_output/opengl/converters.c
> > +++ b/modules/video_output/opengl/converters.c
> > @@ -35,6 +36,30 @@
> > 
> >  #define GL_R16 0
> >  #endif
> > 
> > +#ifdef VLCGL_HAS_PBO
> > +# ifndef GL_UNPACK_ROW_LENGTH
> > +#  error "PBO without GL_UNPACK_ROW_LENGTH"
> 
> Shouldn't this be done in opengl/internal.h to conditionally enable PBO
> support instead?
> 
> > +# endif
> > +#endif
> > +
> > +#ifndef NDEBUG
> > +static __thread bool dbg_is_glthread = false;
> 
> I'm not sure this plays well on all compilers

Yeah, this was a originally GCC ELF extension.

The standard form is _Thread_local but is only available with C11 threads.

> > @@ -53,6 +84,242 @@ struct yuv_priv
> > 
> >      GLfloat local_value[16];
> >  
> >  };
> > 
> > +#ifdef VLCGL_HAS_PBO
> > +static int
> > +pbo_map(const opengl_tex_converter_t *tc, picture_t *pic)
> > +{
> > +    picture_sys_t *picsys = pic->p_sys;
> > +
> > +    tc->api->GenBuffers(pic->i_planes, picsys->buffers);
> > +
> > +    const GLbitfield access = GL_MAP_READ_BIT | GL_MAP_WRITE_BIT |
> > +                              GL_MAP_PERSISTENT_BIT;
> > +    for (int i = 0; i < pic->i_planes; ++i)
> > +    {
> > +        tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER, picsys->buffers[i]);
> > +        tc->api->BufferStorage(GL_PIXEL_UNPACK_BUFFER, picsys->bytes[i],
> > NULL, +                               access);
> > +
> > +        pic->p[i].p_pixels =
> > +            tc->api->MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0,
> > picsys->bytes[i], +                                    access);
> > +
> > +        if (pic->p[i].p_pixels == NULL)
> > +        {
> > +            msg_Err(tc->parent, "could not map PBO buffers");
> > +            for (i = i - 1; i >= 0; --i)
> > +            {
> > +                tc->api->BindBuffer(GL_PIXEL_UNPACK_BUFFER,
> > +                                    picsys->buffers[i]);
> > +                tc->api->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
> > +            }
> > +            tc->api->DeleteBuffers(pic->i_planes, picsys->buffers);
> > +            memset(picsys->buffers, 0, PICTURE_PLANE_MAX *
> > sizeof(GLuint)); +            return VLC_EGENERIC;
> > +        }
> > +    }
> > +    return VLC_SUCCESS;
> > +}
> > +
> > +/** Find next (bit) set */
> > +static int fnsll(unsigned long long x, unsigned i)
> 
> This could be inlined

I would tend to trust the optimizing compiler better than you or me here.

Also a gratuitious 'inline' keyword would prevent a potentially useful unused 
function warning.

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list