[vlc-devel] [PATCH] opengl: enables shaders for macos opengl.

Laurent Aimar fenrir at elivagar.org
Wed Sep 14 21:15:51 CEST 2011


Hi,

On Wed, Sep 14, 2011 at 01:34:30AM +0200, Sebastien Zwickert wrote:
> A new patch in attachment that enables shaders for macos opengl and cleans a lot of specific macos part.
> I've not removed the macos case for defining texture parameters. According to apple's doc it uses recommended data format and type combination[1].

> diff --git a/modules/video_output/opengl.c b/modules/video_output/opengl.c
> index 236b0d2..ff45e66 100644
> --- a/modules/video_output/opengl.c
> +++ b/modules/video_output/opengl.c
> @@ -166,12 +166,19 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
>      /* Load extensions */
>      bool supports_fp = false;
>      if (HasExtension(extensions, "GL_ARB_fragment_program")) {
> +#if !defined(MACOS_OPENGL)
>          vgl->GenProgramsARB    = (PFNGLGENPROGRAMSARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glGenProgramsARB");
>          vgl->BindProgramARB    = (PFNGLBINDPROGRAMARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glBindProgramARB");
>          vgl->ProgramStringARB  = (PFNGLPROGRAMSTRINGARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glProgramStringARB");
>          vgl->DeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glDeleteProgramsARB");
>          vgl->ProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glProgramLocalParameter4fvARB");
> -
> +#else
> +        vgl->GenProgramsARB = glGenProgramsARB;
> +        vgl->BindProgramARB = glBindProgramARB;
> +        vgl->ProgramStringARB = glProgramStringARB;
> +        vgl->DeleteProgramsARB = glDeleteProgramsARB;
> +        vgl->ProgramLocalParameter4fvARB = glProgramLocalParameter4fvARB;
> +#endif
>          supports_fp = vgl->GenProgramsARB &&
>                        vgl->BindProgramARB &&
>                        vgl->ProgramStringARB &&
> @@ -182,9 +189,13 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
>      bool supports_multitexture = false;
>      GLint max_texture_units = 0;
>      if (HasExtension(extensions, "GL_ARB_multitexture")) {
> +#if !defined(MACOS_OPENGL)
>          vgl->ActiveTextureARB   = (PFNGLACTIVETEXTUREARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glActiveTextureARB");
>          vgl->MultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)vlc_gl_GetProcAddress(vgl->gl, "glMultiTexCoord2fARB");
> -
> +#else
> +        vgl->ActiveTextureARB = glActiveTextureARB;
> +        vgl->MultiTexCoord2fARB = glMultiTexCoord2fARB;
> +#endif
 Does anyone knows how to implement something like glXGetProcAddressARB() for
MACOSX ?


>  #elif defined(MACOS_OPENGL)
> -#   if defined(WORDS_BIGENDIAN)
> -    vgl->fmt.i_chroma = VLC_CODEC_YUYV;
> -#   else
> -    vgl->fmt.i_chroma = VLC_CODEC_UYVY;
> -#   endif
> -    vgl->tex_target   = GL_TEXTURE_RECTANGLE_EXT;
> -    vgl->tex_format   = GL_YCBCR_422_APPLE;
> +    vgl->fmt.i_chroma = VLC_CODEC_RGB32;
> +    vgl->tex_target   = GL_TEXTURE_2D;
> +    vgl->tex_format   = GL_BGRA;
>      vgl->tex_internal = GL_RGBA;
> -    vgl->tex_type     = GL_UNSIGNED_SHORT_8_8_APPLE;
> +    vgl->tex_type     = GL_UNSIGNED_INT_8_8_8_8_REV;
>  #else

 It's incomplete: you need to define the RGB masks as done for the non
MACOS_OPENGL case. You can probably share part of the initialization
code (vgl->fmt.i_chroma, vgl->tex_target, vgl->tex_internal, masks at
least). Also if you haven't done so yet, could you test the RGB mode by
disabling the shader code?

Otherwise, great news and thanks for testing :)

-- 
fenrir




More information about the vlc-devel mailing list