From 143ab99b890e40b7395945fd6cfedb351317c928 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 19 Jun 2013 22:41:03 +0200 Subject: [PATCH] Add support for fp40 with opengl --- code/nel/include/nel/3d/driver.h | 6 +++--- .../driver/opengl/driver_opengl_extension.cpp | 17 +++++++++++++---- .../3d/driver/opengl/driver_opengl_extension.h | 4 ++++ .../opengl/driver_opengl_pixel_program.cpp | 8 +++++++- code/snowballs2/client/src/commands.cpp | 17 ++++++++++++++++- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/code/nel/include/nel/3d/driver.h b/code/nel/include/nel/3d/driver.h index 58db119c0..ee040df78 100644 --- a/code/nel/include/nel/3d/driver.h +++ b/code/nel/include/nel/3d/driver.h @@ -155,9 +155,9 @@ public: // opengl - 0x0610,bitfield arbfp1 = 0x06100001, // ARB_fragment_program - // fp20 = 0x061B0002, - fp30 = 0x06100004, // NV_fragment_program - fp40 = 0x06100008, // NV_fragment_program2 + // fp20 = 0x061B0002, // very limited and outdated, unnecessary + // fp30 = 0x06100004, // NV_fragment_program, now arbfp1, redundant + fp40 = 0x06100008, // NV_fragment_program2, arbfp1 with "OPTION NV_fragment_program2;\n" gp4fp = 0x06100010, // NV_gpu_program4 gp5fp = 0x06100020, // NV_gpu_program5 }; 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 e777d2696..3b771e1c1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.cpp @@ -1225,6 +1225,15 @@ static bool setupARBFragmentProgram(const char *glext) return true; } +// ********************************* +static bool setupNVFragmentProgram2(const char *glext) +{ + H_AUTO_OGL(setupNVFragmentProgram2); + CHECK_EXT("GL_NV_fragment_program2"); + + return true; +} + // *************************************************************************** static bool setupARBVertexBufferObject(const char *glext) { @@ -1563,13 +1572,15 @@ void registerGlExtensions(CGlExtensions &ext) // Check pixel program // Disable feature ??? - if(!ext.DisableHardwarePixelProgram) + if (!ext.DisableHardwarePixelProgram) { - ext.ARBFragmentProgram= setupARBFragmentProgram(glext); + ext.ARBFragmentProgram = setupARBFragmentProgram(glext); + ext.NVFragmentProgram2 = setupNVFragmentProgram2(glext); } else { ext.ARBFragmentProgram = false; + ext.NVFragmentProgram2 = false; } ext.OESDrawTexture = setupOESDrawTexture(glext); @@ -1582,14 +1593,12 @@ void registerGlExtensions(CGlExtensions &ext) ext.NVTextureShader = setupNVTextureShader(glext); ext.ATIEnvMapBumpMap = setupATIEnvMapBumpMap(glext); ext.ATIFragmentShader = setupATIFragmentShader(glext); - ext.ARBFragmentProgram = setupARBFragmentProgram(glext); } else { ext.ATIEnvMapBumpMap = false; ext.NVTextureShader = false; ext.ATIFragmentShader = false; - ext.ARBFragmentProgram = false; } // For now, the only way to know if emulation, is to test some extension which exist only on GeForce3. 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 d6d4974a6..fe7738fd8 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_extension.h +++ b/code/nel/src/3d/driver/opengl/driver_opengl_extension.h @@ -103,6 +103,9 @@ struct CGlExtensions bool ARBTextureNonPowerOfTwo; bool ARBMultisample; + // NV Pixel Programs + bool NVFragmentProgram2; + bool OESDrawTexture; bool OESMapBuffer; @@ -208,6 +211,7 @@ public: result += NVTextureShader ? "NVTextureShader " : ""; result += ATIFragmentShader ? "ATIFragmentShader " : ""; result += ARBFragmentProgram ? "ARBFragmentProgram " : ""; + result += NVFragmentProgram2 ? "NVFragmentProgram2 " : ""; result += ARBVertexProgram ? "ARBVertexProgram " : ""; result += NVVertexProgram ? "NVVertexProgram " : ""; result += EXTVertexShader ? "EXTVertexShader " : ""; diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp index a70fbb42d..4131c76b1 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_pixel_program.cpp @@ -71,7 +71,13 @@ bool CDriverGL::isPixelProgramSupported() const bool CDriverGL::isPixelProgramSupported(TPixelProgramProfile profile) const { H_AUTO_OGL(CPixelProgamDrvInfosGL_isPixelProgramSupported_profile) - return profile == arbfp1 && _Extensions.ARBFragmentProgram; + switch (profile) + { + case arbfp1: + return _Extensions.ARBFragmentProgram; + case fp40: + return _Extensions.NVFragmentProgram2; + } } // *************************************************************************** diff --git a/code/snowballs2/client/src/commands.cpp b/code/snowballs2/client/src/commands.cpp index e1039a1ea..5c1274472 100644 --- a/code/snowballs2/client/src/commands.cpp +++ b/code/snowballs2/client/src/commands.cpp @@ -304,6 +304,16 @@ void initCommands() "MOV result.color.xzw, c[0].xyyx;\n" "TEX result.color.y, fragment.texcoord[0], texture[0], 2D;\n" "END\n"; + static const char *program_fp40 = + "!!ARBfp1.0\n" + "OPTION NV_fragment_program2;\n" + "PARAM c[1] = { { 1, 0 } };\n" + "TEMP RC;\n" + "TEMP HC;\n" + "OUTPUT oCol = result.color;\n" + "MOVR oCol.xzw, c[0].xyyx;\n" + "TEX oCol.y, fragment.texcoord[0], texture[0], 2D;\n" + "END\n"; static const char *program_ps_1_1 = "ps.1.1\n" "def c0, 0.000000, 0.000000, 1.000000, 0.000000\n" @@ -329,7 +339,12 @@ void initCommands() "mov oC0.xzw, c0.xyyx\n" "texld oC0.y, v0, s0\n"; NL3D::IDriver *d = dynamic_cast(Driver)->getDriver(); - if (d->isPixelProgramSupported(IDriver::arbfp1)) + if (d->isPixelProgramSupported(IDriver::fp40)) + { + nldebug("fp40"); + a_DevPixelProgram = new CPixelProgram(program_fp40); + } + else if (d->isPixelProgramSupported(IDriver::arbfp1)) { nldebug("arbfp1"); a_DevPixelProgram = new CPixelProgram(program_arbfp1);