[vlc-commits] [Git][videolan/vlc][master] 2 commits: interop_dxva2: load extension from vlc_gl_t

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Fri Oct 29 02:55:21 UTC 2021



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
c48c0a61 by Alexandre Janniaux at 2021-10-29T03:41:04+02:00
interop_dxva2: load extension from vlc_gl_t

This will use extensions from wgl directly into interop_dxva2, instead
of using those loaded by wgl.

The only users of those extensions are interop modules, so only
interop_dxva2 for extension related to WGL integration.

By moving the loading of those extension to the interop, we can have
them working even when the OpenGL platform context is provided by the
vglmem (vgl.c) module callbacks, allowing hardware acceleration even
when using the libvlc OpenGL callbacks.

Filters would likely be using only OpenGL extensions that are already
available, but could be using the same mechanism in the worst-case
scenario.

Refs #25234, #25256

- - - - -
406ba5dd by Alexandre Janniaux at 2021-10-29T03:41:04+02:00
wgl: remove extension handling

They are not used anymore since it was moved to the interop_dxva2
module.

- - - - -


3 changed files:

- modules/video_output/Makefile.am
- modules/video_output/opengl/interop_dxva2.c
- modules/video_output/win32/wgl.c


Changes:

=====================================
modules/video_output/Makefile.am
=====================================
@@ -151,7 +151,7 @@ libdirect3d9_plugin_la_LDFLAGS = $(AM_LDFLAGS) -rpath '$(voutdir)'
 libglinterop_dxva2_plugin_la_SOURCES = video_output/opengl/interop_dxva2.c \
 	video_output/opengl/interop.h
 libglinterop_dxva2_plugin_la_CFLAGS = $(AM_CFLAGS) $(GL_CFLAGS)
-libglinterop_dxva2_plugin_la_LIBADD = libd3d9_common.la
+libglinterop_dxva2_plugin_la_LIBADD = libd3d9_common.la -lopengl32
 
 if HAVE_WIN32_DESKTOP
 vout_LTLIBRARIES += $(LTLIBdirect3d9)


=====================================
modules/video_output/opengl/interop_dxva2.c
=====================================
@@ -71,6 +71,8 @@ vlc_module_begin ()
 vlc_module_end ()
 
 struct wgl_vt {
+    PFNWGLGETEXTENSIONSSTRINGEXTPROC     GetExtensionsStringEXT;
+    PFNWGLGETEXTENSIONSSTRINGARBPROC     GetExtensionsStringARB;
     PFNWGLDXSETRESOURCESHAREHANDLENVPROC DXSetResourceShareHandleNV;
     PFNWGLDXOPENDEVICENVPROC             DXOpenDeviceNV;
     PFNWGLDXCLOSEDEVICENVPROC            DXCloseDeviceNV;
@@ -424,16 +426,12 @@ GLConvOpen(vlc_object_t *obj)
         msg_Warn(obj, "DX/GL interrop only working on d3d9x");
         return VLC_EGENERIC;
     }
-
-    if (interop->gl->ext != VLC_GL_EXT_WGL || !interop->gl->wgl.getExtensionsString)
-        return VLC_EGENERIC;
-
-    const char *wglExt = interop->gl->wgl.getExtensionsString(interop->gl);
-
-    if (wglExt == NULL || !vlc_gl_StrHasToken(wglExt, "WGL_NV_DX_interop"))
+    HGLRC hGLRC = wglGetCurrentContext();
+    if (hGLRC == NULL)
         return VLC_EGENERIC;
 
     struct wgl_vt vt;
+
 #define LOAD_EXT(name, type) do { \
     vt.name = (type) vlc_gl_GetProcAddress(interop->gl, "wgl" #name); \
     if (!vt.name) { \
@@ -442,6 +440,24 @@ GLConvOpen(vlc_object_t *obj)
     } \
 } while(0)
 
+    LOAD_EXT(GetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC);
+    LOAD_EXT(GetExtensionsStringARB, PFNWGLGETEXTENSIONSSTRINGARBPROC);
+
+    const char *wglExt = NULL;
+    if (vt.GetExtensionsStringEXT)
+    {
+        wglExt = vt.GetExtensionsStringEXT();
+    }
+    else if (vt.GetExtensionsStringARB)
+    {
+        HDC hGLDC = wglGetCurrentDC();
+        if (hGLDC == NULL)
+            return VLC_EGENERIC;
+        wglExt = vt.GetExtensionsStringARB(hGLDC);
+    }
+
+    if (wglExt == NULL || !vlc_gl_StrHasToken(wglExt, "WGL_NV_DX_interop"))
+        return VLC_EGENERIC;
     LOAD_EXT(DXSetResourceShareHandleNV, PFNWGLDXSETRESOURCESHAREHANDLENVPROC);
     LOAD_EXT(DXOpenDeviceNV, PFNWGLDXOPENDEVICENVPROC);
     LOAD_EXT(DXCloseDeviceNV, PFNWGLDXCLOSEDEVICENVPROC);


=====================================
modules/video_output/win32/wgl.c
=====================================
@@ -65,19 +65,12 @@ typedef struct vout_display_sys_t
     HMODULE               hOpengl;
     vlc_gl_t              *gl;
     HDC                   affinityHDC; // DC for the selected GPU
-
-    struct
-    {
-        PFNWGLGETEXTENSIONSSTRINGEXTPROC GetExtensionsStringEXT;
-        PFNWGLGETEXTENSIONSSTRINGARBPROC GetExtensionsStringARB;
-    } exts;
 } vout_display_sys_t;
 
 static void          Swap(vlc_gl_t *);
 static void          *OurGetProcAddress(vlc_gl_t *, const char *);
 static int           MakeCurrent(vlc_gl_t *gl);
 static void          ReleaseCurrent(vlc_gl_t *gl);
-static const char *  GetExtensionsString(vlc_gl_t *gl);
 
 #define VLC_PFD_INITIALIZER { \
     .nSize = sizeof(PIXELFORMATDESCRIPTOR), \
@@ -224,13 +217,6 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
     }
 #endif
 
-#define LOAD_EXT(name, type) \
-    sys->exts.name = (type) wglGetProcAddress("wgl" #name )
-
-    LOAD_EXT(GetExtensionsStringEXT, PFNWGLGETEXTENSIONSSTRINGEXTPROC);
-    if (!sys->exts.GetExtensionsStringEXT)
-        LOAD_EXT(GetExtensionsStringARB, PFNWGLGETEXTENSIONSSTRINGARBPROC);
-
     wglMakeCurrent(sys->hGLDC, NULL);
 
     gl->ext = VLC_GL_EXT_WGL;
@@ -241,9 +227,6 @@ static int Open(vlc_gl_t *gl, unsigned width, unsigned height)
     gl->get_proc_address = OurGetProcAddress;
     gl->destroy = Close;
 
-    if (sys->exts.GetExtensionsStringEXT || sys->exts.GetExtensionsStringARB)
-        gl->wgl.getExtensionsString = GetExtensionsString;
-
     (void) width; (void) height;
     return VLC_SUCCESS;
 
@@ -319,11 +302,3 @@ static void ReleaseCurrent(vlc_gl_t *gl)
     vout_display_sys_t *sys = gl->sys;
     wglMakeCurrent(NULL, NULL);
 }
-
-static const char *GetExtensionsString(vlc_gl_t *gl)
-{
-    vout_display_sys_t *sys = gl->sys;
-    return sys->exts.GetExtensionsStringEXT ?
-            sys->exts.GetExtensionsStringEXT() :
-            sys->exts.GetExtensionsStringARB(sys->hGLDC);
-}



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4e2f82386a823ee1c71feade12b636ff0390e2f2...406ba5dd0016efe41e5f0630def693ef1664ff3a

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4e2f82386a823ee1c71feade12b636ff0390e2f2...406ba5dd0016efe41e5f0630def693ef1664ff3a
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list