From 3d12312806e7d54e7bb6b4b2a5981999735f6233 Mon Sep 17 00:00:00 2001 From: James Ross-Gowan Date: Tue, 1 Dec 2015 00:56:02 +1100 Subject: vo_opengl: add dxinterop backend WGL_NV_DX_interop is widely supported by Nvidia and AMD drivers. It allows a texture to be shared between Direct3D and WGL, so that rendering can be done with WGL and presentation can be done with Direct3D. This should allow us to work around some persistent WGL issues, such as dropped frames with some driver/OS combos, drivers that buffer frames to increase performance at the cost of latency, and the inability to disable exclusive fullscreen mode when using WGL to render to a fullscreen window. The addition of a DX_interop backend might also enable some cool Direct3D-specific enhancements in the future, such as using the GetPresentStatistics API to get accurate frame presentation timestamps. Note that due to a driver bug, this backend is currently broken on Intel. It will appear to work as long as the window is not resized too often, but after a few changes of size it will be unable to share the newly created renderbuffer with GL. See: https://software.intel.com/en-us/forums/graphics-driver-bug-reporting/topic/562051 --- video/out/opengl/common.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'video/out/opengl/common.h') diff --git a/video/out/opengl/common.h b/video/out/opengl/common.h index 8d5bbdbb6d..537e785e3b 100644 --- a/video/out/opengl/common.h +++ b/video/out/opengl/common.h @@ -63,6 +63,7 @@ enum { MPGL_CAP_1D_TEX = (1 << 14), MPGL_CAP_3D_TEX = (1 << 15), MPGL_CAP_DEBUG = (1 << 16), + MPGL_CAP_DXINTEROP = (1 << 17), // WGL_NV_DX_interop MPGL_CAP_SW = (1 << 30), // indirect or sw renderer }; @@ -128,6 +129,9 @@ typedef struct MPGLContext { // Windows-specific hack. See vo_opengl dwmflush suboption. int dwm_flush_opt; + // Flip the rendered image vertically. This is useful for dxinterop. + bool flip_v; + // For free use by the mpgl_driver. void *priv; } MPGLContext; @@ -261,6 +265,21 @@ struct GL { void (GLAPIENTRY *VDPAUMapSurfacesNV)(GLsizei, const GLvdpauSurfaceNV *); void (GLAPIENTRY *VDPAUUnmapSurfacesNV)(GLsizei, const GLvdpauSurfaceNV *); +#if HAVE_GL_WIN32 + // The HANDLE type might not be present on non-Win32 + BOOL (GLAPIENTRY *DXSetResourceShareHandleNV)(void *dxObject, + HANDLE shareHandle); + HANDLE (GLAPIENTRY *DXOpenDeviceNV)(void *dxDevice); + BOOL (GLAPIENTRY *DXCloseDeviceNV)(HANDLE hDevice); + HANDLE (GLAPIENTRY *DXRegisterObjectNV)(HANDLE hDevice, void *dxObject, + GLuint name, GLenum type, GLenum access); + BOOL (GLAPIENTRY *DXUnregisterObjectNV)(HANDLE hDevice, HANDLE hObject); + BOOL (GLAPIENTRY *DXLockObjectsNV)(HANDLE hDevice, GLint count, + HANDLE *hObjects); + BOOL (GLAPIENTRY *DXUnlockObjectsNV)(HANDLE hDevice, GLint count, + HANDLE *hObjects); +#endif + GLint (GLAPIENTRY *GetVideoSync)(GLuint *); GLint (GLAPIENTRY *WaitVideoSync)(GLint, GLint, unsigned int *); -- cgit v1.2.3