From 8da853f5082b4a633ba78431d1c07a13e77dd7c1 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 9 Nov 2015 10:00:05 +0100 Subject: [PATCH] Changed: Support for WGL_NV_gpu_affinity extension --- .../driver/opengl/driver_opengl_extension.cpp | 51 ++++++++++++++++++- .../driver/opengl/driver_opengl_extension.h | 10 ++++ 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp index ba755b958..5563a4fcf 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -519,6 +519,14 @@ PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC nwglMakeAssociatedContextCurrentAMD; PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC nwglGetCurrentAssociatedContextAMD; PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC nwglBlitContextFramebufferAMD; +// WGL_NV_gpu_affinity +//==================== +PFNWGLENUMGPUSNVPROC nwglEnumGpusNV; +PFNWGLENUMGPUDEVICESNVPROC nwglEnumGpuDevicesNV; +PFNWGLCREATEAFFINITYDCNVPROC nwglCreateAffinityDCNV; +PFNWGLENUMGPUSFROMAFFINITYDCNVPROC nwglEnumGpusFromAffinityDCNV; +PFNWGLDELETEDCNVPROC nwglDeleteDCNV; + #elif defined(NL_OS_MAC) #elif defined(NL_OS_UNIX) @@ -1846,7 +1854,23 @@ static bool setupWGLAMDGPUAssociation(const char *glext) return true; } -// ********************************* +// *************************************************************************** +static bool setupWGLNVGPUAssociation(const char *glext) +{ + H_AUTO_OGL(setupWGLNVGPUAssociation); + CHECK_EXT("WGL_NV_gpu_affinity"); + +#if !defined(USE_OPENGLES) && defined(NL_OS_WINDOWS) + CHECK_ADDRESS(PFNWGLENUMGPUSNVPROC, wglEnumGpusNV); + CHECK_ADDRESS(PFNWGLENUMGPUDEVICESNVPROC, wglEnumGpuDevicesNV); + CHECK_ADDRESS(PFNWGLCREATEAFFINITYDCNVPROC, wglCreateAffinityDCNV); + CHECK_ADDRESS(PFNWGLENUMGPUSFROMAFFINITYDCNVPROC, wglEnumGpusFromAffinityDCNV); + CHECK_ADDRESS(PFNWGLDELETEDCNVPROC, wglDeleteDCNV); +#endif + + return true; +} + static bool setupGLXEXTSwapControl(const char *glext) { H_AUTO_OGL(setupGLXEXTSwapControl); @@ -1972,6 +1996,31 @@ bool registerWGlExtensions(CGlExtensions &ext, HDC hDC) delete [] uGPUIDs; } + ext.WGLNVGPUAffinity = setupWGLNVGPUAssociation(glext); + + if (ext.WGLNVGPUAffinity) + { + uint i = 0; + + HGPUNV hGPU; + + while(nwglEnumGpusNV(i, &hGPU)) + { + uint j = 0; + + PGPU_DEVICE lpGpuDevice = NULL; + + while(nwglEnumGpuDevicesNV(hGPU, j, lpGpuDevice)) + { + nlinfo("Device: %s - %s - flags: %u", lpGpuDevice->DeviceName, lpGpuDevice->DeviceString, lpGpuDevice->Flags); + + ++j; + } + + ++i; + } + } + return true; } #elif defined(NL_OS_MAC) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h index 868a0eaf4..d5556ef64 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -123,6 +123,9 @@ struct CGlExtensions // WGL_AMD_gpu_association bool WGLAMDGPUAssociation; + // WGL_NV_gpu_affinity + bool WGLNVGPUAffinity; + public: /// \name Disable Hardware feature. False by default. setuped by IDriver @@ -793,6 +796,13 @@ extern PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC nwglMakeAssociatedContextCurren extern PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC nwglGetCurrentAssociatedContextAMD; extern PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC nwglBlitContextFramebufferAMD; +// WGL_NV_gpu_affinity +//==================== +extern PFNWGLENUMGPUSNVPROC nwglEnumGpusNV; +extern PFNWGLENUMGPUDEVICESNVPROC nwglEnumGpuDevicesNV; +extern PFNWGLCREATEAFFINITYDCNVPROC nwglCreateAffinityDCNV; +extern PFNWGLENUMGPUSFROMAFFINITYDCNVPROC nwglEnumGpusFromAffinityDCNV; +extern PFNWGLDELETEDCNVPROC nwglDeleteDCNV; #elif defined(NL_OS_MAC) #elif defined(NL_OS_UNIX)