From 0c5c352a785589d17e4281df75443bbec0e2732d Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 20 Dec 2010 16:43:05 +0100 Subject: [PATCH] Changed: Implement GL_NV_vertex_array_range for GLX --- .../driver/opengl/driver_opengl_extension.cpp | 10 +++++++--- .../3d/driver/opengl/driver_opengl_extension.h | 3 +++ .../driver/opengl/driver_opengl_extension_def.h | 6 ++++++ .../opengl/driver_opengl_vertex_buffer_hard.cpp | 17 ++++++++++++++++- 4 files changed, 32 insertions(+), 4 deletions(-) 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 41483b832..482740c2c 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -444,6 +444,9 @@ PFNWGLGETEXTENSIONSSTRINGARBPROC nwglGetExtensionsStringARB; #elif defined(NL_OS_MAC) #elif defined(NL_OS_UNIX) +NEL_PFNGLXLALLOCATEMEMORYNVPROC nglXAllocateMemoryNV; +NEL_PFNGLXFREEMEMORYNVPROC nglXFreeMemoryNV; + // Swap control extensions NEL_PFNGLXSWAPINTERVALEXTPROC nglXSwapIntervalEXT; @@ -562,9 +565,6 @@ static bool setupARBTextureNonPowerOfTwo(const char *glext) static bool setupNVVertexArrayRange(const char *glext) { H_AUTO_OGL(setupNVVertexArrayRange); -#ifndef NL_OS_WINDOWS - return false; -#endif // Test if VAR is present. CHECK_EXT("GL_NV_vertex_array_range"); @@ -575,9 +575,13 @@ static bool setupNVVertexArrayRange(const char *glext) // Get VAR address. CHECK_ADDRESS(NEL_PFNGLFLUSHVERTEXARRAYRANGENVPROC, glFlushVertexArrayRangeNV); CHECK_ADDRESS(NEL_PFNGLVERTEXARRAYRANGENVPROC, glVertexArrayRangeNV); + #ifdef NL_OS_WINDOWS CHECK_ADDRESS(PFNWGLALLOCATEMEMORYNVPROC, wglAllocateMemoryNV); CHECK_ADDRESS(PFNWGLFREEMEMORYNVPROC, wglFreeMemoryNV); +#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC) + CHECK_ADDRESS(NEL_PFNGLXLALLOCATEMEMORYNVPROC, glXAllocateMemoryNV); + CHECK_ADDRESS(NEL_PFNGLXFREEMEMORYNVPROC, glXFreeMemoryNV); #endif // Get fence address. 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 39df658ff..1c9cc0967 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -332,6 +332,9 @@ extern NEL_PFNGLVERTEXARRAYRANGENVPROC nglVertexArrayRangeNV; #ifdef NL_OS_WINDOWS extern PFNWGLALLOCATEMEMORYNVPROC nwglAllocateMemoryNV; extern PFNWGLFREEMEMORYNVPROC nwglFreeMemoryNV; +#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC) +extern NEL_PFNGLXLALLOCATEMEMORYNVPROC nglXAllocateMemoryNV; +extern NEL_PFNGLXFREEMEMORYNVPROC nglXFreeMemoryNV; #endif diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h b/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h index a8d46ec83..906970dae 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension_def.h @@ -403,6 +403,12 @@ typedef GLint (APIENTRY * NEL_PFNGLXGETSWAPINTERVALMESAPROC) (); #endif // NL_GLX_MESA_swap_control +#ifndef NL_GLX_NV_vertex_array_range +#define NL_GLX_NV_vertex_array_range 1 +typedef void* (APIENTRY * NEL_PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); +typedef void (APIENTRY * NEL_PFNGLXFREEMEMORYNVPROC) (void *pointer); +#endif // NL_GLX_NV_vertex_array_range + #endif // NL_OS_MAC #ifdef __cplusplus diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp index ef22eb508..0d6daae3d 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_vertex_buffer_hard.cpp @@ -116,7 +116,20 @@ bool CVertexArrayRangeNVidia::allocate(uint32 size, CVertexBuffer::TPreferredM else _VertexArrayPtr= nwglAllocateMemoryNV(size, 0, 0, 0.5f); break; - }; + } +#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC) + switch(vbType) + { + case CVertexBuffer::AGPPreferred: + _VertexArrayPtr= nglXAllocateMemoryNV(size, 0, 0, 0.5f); + break; + case CVertexBuffer::StaticPreferred: + if (_Driver->getStaticMemoryToVRAM()) + _VertexArrayPtr= nglXAllocateMemoryNV(size, 0, 0, 1.0f); + else + _VertexArrayPtr= nglXAllocateMemoryNV(size, 0, 0, 0.5f); + break; + } #endif // NL_OS_WINDOWS @@ -158,6 +171,8 @@ void CVertexArrayRangeNVidia::free() #ifdef NL_OS_WINDOWS // Free special memory. nwglFreeMemoryNV(_VertexArrayPtr); +#elif defined(NL_OS_UNIX) && !defined(NL_OS_MAC) + nglXFreeMemoryNV(_VertexArrayPtr); #endif // NL_OS_WINDOWS _VertexArrayPtr= NULL;