WGL_NVX_DX_interop extension

Does anybody know the purpose of WGL_NVX_DX_interop extension?

It is obviously some NVidia’s eXperimental extension, which appears in 190.56 GeForce drivers, and, according to my laptop, disappears in 190.89 (although JeGX claims that it is still present).

As its name implies, GL_NVX_DX_interop probably exposes some kind of interface to DirectX. If it is not a top secret, I beg Mr. Barthold Lichtenbelt to give us some insight into this extension.

After a quick look around, I found these entry points:


edit and some more interesting stuff:



Very interesting, indeed!

Thank you, elFarto!

can be useful

  1. Opengl player and video GPU decoding via dxva.

what i know

1.create opengl.
2. call initdxg()
3.Create direct3d context g_pD3D->CreateDevice

int handle=wglDXOpenDeviceNVX(g_pd3dDevice)) takes direct3d device
return handle >0
0 error

wglDXCloseDeviceNVX(handle) takes handle
return >0 ok
0 error

open interop:

int dx;
int ret;
printf("OpenGL DirectX interop is working!
printf("OpenGL DirectX interop not working!

close interop:
if(ret=wglDXCloseDeviceNVX((void )dx))
printf("OpenGL DirectX interop finished!
printf("OpenGL DirectX interop not finished!

wglDXRegisterObjectNVX takes 5 parameters first is handle should also take opengl and object directx object and also object usage read_only,etc…
should be similar to cudaGLRegisterBufferObject
returns 0 error
cutilSafeCall(cudaGLSetBufferObjectMapFlags (*pbo, cudaGLMapFlagsReadOnly));

DXLockObjectsNVX equivalent to cuda cudaGLMapBufferObject

#ifndef gldxinterop_h
#define gldxinterop_h

#include <windows.h>
#include <d3d9.h>
#include <GL/glew.h>
#include <GL/glut.h>
#include <GL/glext.h>

#if defined(__cplusplus)
extern “C” {
#endif /* __cplusplus */

extern int dx;
typedef int (__stdcall pwglDXOpenDeviceNVX)(IDirect3DDevice9 *ppDxDevice);//(int device);
typedef int (__stdcall pwglDXCloseDeviceNVX )(void *);//(int device);
typedef int (__stdcall pwglDXRegisterObjectNVX)(void *,void *,void *,void *,int);//(IDirect3DResource9 *pResource unsigned int flags)
typedef int (__stdcall pwglDXUnregisterObjectNVX)(GLuint bufObj);
typedef int (__stdcall pwglDXLockObjectsNVX)(void **dev_ptr,GLuint bufObj);
typedef int (__stdcall pwglDXUnlockObjectsNVX)(void **dev_ptr,GLuint bufObj);
typedef int (__stdcall pwglDXObjectAccessNVX)(GLuint bufObj);

extern pwglDXOpenDeviceNVX *wglDXOpenDeviceNVX;
extern pwglDXCloseDeviceNVX  *wglDXCloseDeviceNVX;
extern pwglDXRegisterObjectNVX  *wglDXRegisterObjectNVX;
extern pwglDXUnregisterObjectNVX  *wglDXUnregisterObjectNVX;
extern pwglDXLockObjectsNVX  *wglDXLockObjectsNVX;
extern pwglDXUnlockObjectsNVX  *wglDXUnlockObjectsNVX;
extern pwglDXObjectAccessNVX  *wglDXObjectAccessNVX;

void initdxgl();

#if defined(__cplusplus)
#endif /* __cplusplus */

#include “gldxinterop.h”

#include <stdio.h>

pwglDXOpenDeviceNVX  *wglDXOpenDeviceNVX;
pwglDXCloseDeviceNVX  *wglDXCloseDeviceNVX;
pwglDXRegisterObjectNVX  *wglDXRegisterObjectNVX;
pwglDXUnregisterObjectNVX  *wglDXUnregisterObjectNVX;
pwglDXLockObjectsNVX *wglDXLockObjectsNVX;
pwglDXUnlockObjectsNVX  *wglDXUnlockObjectsNVX;
pwglDXObjectAccessNVX  *wglDXObjectAccessNVX;
int dx;
void initdxgl()
	#define DXNAPI 7
	void *p[DXNAPI];
	int i;
	char wgldx[DXNAPI][100]={"wglDXOpenDeviceNVX","wglDXCloseDeviceNVX","wglDXRegisterObjectNVX","wglDXUnregisterObjectNVX","wglDXLockObjectsNVX","wglDXUnlockObjectsNVX","wglDXObjectAccessNVX"};
	for(i=0; i&lt;DXNAPI; i++)
		p[i]=(void *)wglGetProcAddress(wgldx[i]);
		if(p[i]==NULL) printf("Not found %s

else printf("Found %s
wglDXOpenDeviceNVX=(pwglDXOpenDeviceNVX *)p[0];
wglDXCloseDeviceNVX=(pwglDXCloseDeviceNVX )p[1];
) p[2];
wglDXUnregisterObjectNVX=(pwglDXUnregisterObjectNVX *)p[3];
wglDXLockObjectsNVX=(pwglDXLockObjectsNVX *)p[4];
wglDXUnlockObjectsNVX=(pwglDXUnlockObjectsNVX *)p[5];
wglDXObjectAccessNVX=(pwglDXObjectAccessNVX *)p[6];
#undef DXNAPI


Yes, it is useful.

Thank you very much, oscarbg!

I know the thread has been opened (and closed??) a long time. but I would like to ask some questions anyways:

WGL_ACCESS_READ_WRITE_NVX where did you find the values for these constants? can you please post them?

thanks a lot in advance

See slides 18-21 in this presentation: http://www.slideshare.net/Mark_Kilgard/gtc-2010-opengl

yes, I know this presentation. but let me ask differently:
What is the hex/dec-value of the WGL_ACCESS_READ_WRITE_NVX constant (and others). Or in which header (.h-file) did you find them? Do I need a special driver version

The values are simple; just 0, 1, and 2. :slight_smile:

WGL_ACCESS_READ_ONLY_NV             0x0000
WGL_ACCESS_READ_WRITE_NV            0x0001

As it is NV extension, and further more experimental, you’ll find specification only on NV site. Spec can be found here:

Yes, you do need special version of drivers. The latest one (265.90), for example, supports DX_interop. You have to check if your version supports it. The first support is added a year ago, but from time to time this extension disappears from the drivers implementation.

thanks a lot
somehow I was unable to find this site…