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:

wglDXCloseDeviceNVX
wglDXLockObjectsNVX
wglDXObjectAccessNVX
wglDXOpenDeviceNVX
wglDXRegisterObjectsNVX
wglDXUnlockObjectsNVX
wglDXUnregisterObjectNVX

edit and some more interesting stuff:

gl_TessLevelInner=gl_TessLevelInnerIn
gl_TessLevelOuter=gl_TessLevelOuterIn

Regards
elFarto

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;
if((dx=wglDXOpenDeviceNVX(g_pd3dDevice))!=NULL)
printf("OpenGL DirectX interop is working!
");
else
printf("OpenGL DirectX interop not working!
");

close interop:
if(ret=wglDXCloseDeviceNVX((void )dx))
printf("OpenGL DirectX interop finished!
");
else
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(cudaGLRegisterBufferObject(*pbo));
cutilSafeCall(cudaGLSetBufferObjectMapFlags (*pbo, cudaGLMapFlagsReadOnly));

also
DXLockObjectsNVX equivalent to cuda cudaGLMapBufferObject

gldxinterop
#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 */
#endif

gldxinterop.c
#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]=NULL;
		p[i]=(void *)wglGetProcAddress(wgldx[i]);
		if(p[i]==NULL) printf("Not found %s

",wgldx[i]);
else printf("Found %s
",wgldx[i]);
}
wglDXOpenDeviceNVX=(pwglDXOpenDeviceNVX *)p[0];
wglDXCloseDeviceNVX=(pwglDXCloseDeviceNVX )p[1];
wglDXRegisterObjectNVX=(pwglDXRegisterObjectNVX
) 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!

heyhey,
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
WGL_ACCESS_WRITE_DISCARD_NV         0x0002

As it is NV extension, and further more experimental, you’ll find specification only on NV site. Spec can be found here:
http://developer.download.nvidia.com/opengl/specs/WGL_NV_DX_interop.txt

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…