PDA

View Full Version : WGL_NVX_DX_interop extension



Aleksandar
09-19-2009, 09:52 AM
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.

elFarto
09-19-2009, 10:39 AM
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

Aleksandar
09-19-2009, 12:36 PM
Very interesting, indeed!

Thank you, elFarto!

oscarbg
09-24-2009, 12:36 PM
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!\n");
else
printf("OpenGL DirectX interop not working!\n");

close interop:
if(ret=wglDXCloseDeviceNVX((void *)dx))
printf("OpenGL DirectX interop finished!\n");
else
printf("OpenGL DirectX interop not finished!\n");*/



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<DXNAPI; i++)
{
p[i]=NULL;
p[i]=(void *)wglGetProcAddress(wgldx[i]);
if(p[i]==NULL) printf("Not found %s\n",wgldx[i]);
else printf("Found %s\n",wgldx[i]);
}
wglDXOpenDeviceNVX=(pwglDXOpenDeviceNVX *)p[0];
wglDXCloseDeviceNVX=(pwglDXCloseDeviceNVX *)p[1];
wglDXRegisterObjectNVX=(pwglDXRegisterObjectNVX*) p[2];
wglDXUnregisterObjectNVX=(pwglDXUnregisterObjectNV X *)p[3];
wglDXLockObjectsNVX=(pwglDXLockObjectsNVX *)p[4];
wglDXUnlockObjectsNVX=(pwglDXUnlockObjectsNVX *)p[5];
wglDXObjectAccessNVX=(pwglDXObjectAccessNVX *)p[6];
#undef DXNAPI

}

Aleksandar
09-25-2009, 12:42 AM
Yes, it is useful.

Thank you very much, oscarbg!

zqueezy
12-02-2010, 05:05 AM
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

mfort
12-03-2010, 11:27 AM
See slides 18-21 in this presentation: http://www.slideshare.net/Mark_Kilgard/gtc-2010-opengl

zqueezy
12-05-2010, 01:55 PM
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

Aleksandar
12-06-2010, 03:05 AM
The values are simple; just 0, 1, and 2. :)



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.

zqueezy
12-07-2010, 03:03 AM
thanks a lot
somehow I was unable to find this site...