From 391fa6dcff54915e3c389d1510c62b89496a4bd1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 2 Jul 2013 19:39:05 +0200 Subject: [PATCH] Add arbfp1 and fp40 barrel fragment programs, see #43 --HG-- branch : multipass-stereo --- code/nel/src/3d/stereo_ovr.cpp | 18 ++++----- code/nel/src/3d/stereo_ovr_fp.cpp | 63 ++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 11 deletions(-) diff --git a/code/nel/src/3d/stereo_ovr.cpp b/code/nel/src/3d/stereo_ovr.cpp index 745394576..d6fc56cb9 100644 --- a/code/nel/src/3d/stereo_ovr.cpp +++ b/code/nel/src/3d/stereo_ovr.cpp @@ -67,6 +67,7 @@ using namespace std; namespace NL3D { +extern const char *g_StereoOVR_fp40; extern const char *g_StereoOVR_arbfp1; extern const char *g_StereoOVR_ps_2_0; @@ -238,17 +239,16 @@ void CStereoOVR::setDriver(NL3D::UDriver *driver) nlassert(height == m_DevicePtr->HMDInfo.VResolution); nlassert(!m_PixelProgram); - NL3D::IDriver *drvInternal = (static_cast(driver))->getDriver(); - static const char *program_arbfp1 = - "!!ARBfp1.0\n" - "PARAM c[1] = { { 1, 0 } };\n" - "MOV result.color.xzw, c[0].xyyx;\n" - "TEX result.color.y, fragment.texcoord[0], texture[0], 2D;\n" - "END\n"; - if (drvInternal->supportPixelProgram(CPixelProgram::arbfp1) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) + NL3D::IDriver *drvInternal = (static_cast(driver))->getDriver(); + if (drvInternal->supportPixelProgram(CPixelProgram::fp40) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) + { + nldebug("VR: fp40"); + m_PixelProgram = new CPixelProgram(g_StereoOVR_fp40); + } + else if (drvInternal->supportPixelProgram(CPixelProgram::arbfp1) && drvInternal->supportBloomEffect() && drvInternal->supportNonPowerOfTwoTextures()) { nldebug("VR: arbfp1"); - m_PixelProgram = new CPixelProgram(program_arbfp1); + m_PixelProgram = new CPixelProgram(g_StereoOVR_arbfp1); } else if (drvInternal->supportPixelProgram(CPixelProgram::ps_2_0)) { diff --git a/code/nel/src/3d/stereo_ovr_fp.cpp b/code/nel/src/3d/stereo_ovr_fp.cpp index d33e5fa2c..46fe1451b 100644 --- a/code/nel/src/3d/stereo_ovr_fp.cpp +++ b/code/nel/src/3d/stereo_ovr_fp.cpp @@ -21,6 +21,65 @@ limitations under the License. ************************************************************************************/ namespace NL3D { +const char *g_StereoOVR_fp40 = + "!!ARBfp1.0\n" + "OPTION NV_fragment_program2;\n" + //# cgc version 3.1.0013, build date Apr 18 2012 + //# command line args: -profile fp40 + //# source file: pp_oculus_vr.cg + //#vendor NVIDIA Corporation + //#version 3.1.0.13 + //#profile fp40 + //#program pp_oculus_vr + //#semantic pp_oculus_vr.cLensCenter + //#semantic pp_oculus_vr.cScreenCenter + //#semantic pp_oculus_vr.cScale + //#semantic pp_oculus_vr.cScaleIn + //#semantic pp_oculus_vr.cHmdWarpParam + //#semantic pp_oculus_vr.cTex0 : TEX0 + //#var float2 texCoord : $vin.TEXCOORD0 : TEX0 : 0 : 1 + //#var float2 cLensCenter : : c[0] : 1 : 1 + //#var float2 cScreenCenter : : c[1] : 2 : 1 + //#var float2 cScale : : c[2] : 3 : 1 + //#var float2 cScaleIn : : c[3] : 4 : 1 + //#var float4 cHmdWarpParam : : c[4] : 5 : 1 + //#var sampler2D cTex0 : TEX0 : texunit 0 : 6 : 1 + //#var float4 oCol : $vout.COLOR : COL : 7 : 1 + //#const c[5] = 0.25 0.5 0 + "PARAM c[6] = { program.env[0..4],\n" // program.local->program.env! + " { 0.25, 0.5, 0 } };\n" + "TEMP R0;\n" + "TEMP R1;\n" + "SHORT TEMP H0;\n" + "TEMP RC;\n" + "TEMP HC;\n" + "OUTPUT oCol = result.color;\n" + "ADDR R0.xy, fragment.texcoord[0], -c[0];\n" + "MULR R0.xy, R0, c[3];\n" + "MULR R0.z, R0.y, R0.y;\n" + "MADR R1.x, R0, R0, R0.z;\n" + "MULR R0.zw, R1.x, c[4].xywz;\n" + "MADR R1.y, R1.x, c[4], c[4].x;\n" + "MADR R0.w, R0, R1.x, R1.y;\n" + "MULR R0.z, R0, R1.x;\n" + "MADR R0.z, R0, R1.x, R0.w;\n" + "MULR R1.xy, R0, R0.z;\n" + "MOVR R0.xy, c[5];\n" + "ADDR R1.zw, R0.xyxy, c[1].xyxy;\n" + "MOVR R0.zw, c[0].xyxy;\n" + "MADR R0.zw, R1.xyxy, c[2].xyxy, R0;\n" + "MINR R1.xy, R0.zwzw, R1.zwzw;\n" + "ADDR R0.xy, -R0, c[1];\n" + "MAXR R0.xy, R0, R1;\n" + "SEQR H0.xy, R0, R0.zwzw;\n" + "MULXC HC.x, H0, H0.y;\n" + "IF EQ.x;\n" + "MOVR oCol, c[5].z;\n" + "ELSE;\n" + "TEX oCol, R0.zwzw, texture[0], 2D;\n" + "ENDIF;\n" + "END\n"; + //# 24 instructions, 2 R-regs, 1 H-regs const char *g_StereoOVR_arbfp1 = "!!ARBfp1.0\n" //# cgc version 3.1.0013, build date Apr 18 2012 @@ -45,7 +104,7 @@ const char *g_StereoOVR_arbfp1 = //#var sampler2D cTex0 : TEX0 : texunit 0 : 6 : 1 //#var float4 oCol : $vout.COLOR : COL : 7 : 1 //#const c[5] = 0.25 0.5 0 1 - "PARAM c[6] = { program.local[0..4],\n" + "PARAM c[6] = { program.env[0..4],\n" " { 0.25, 0.5, 0, 1 } };\n" "TEMP R0;\n" "TEMP R1;\n" @@ -78,8 +137,8 @@ const char *g_StereoOVR_arbfp1 = "CMP R1.x, -R1, c[5].z, c[5].w;\n" "CMP result.color, -R1.x, R0, c[5].z;\n" "END\n"; -const char *g_StereoOVR_ps_2_0 = //# 28 instructions, 2 R-regs +const char *g_StereoOVR_ps_2_0 = "ps_2_0\n" // cgc version 3.1.0013, build date Apr 18 2012 // command line args: -profile ps_2_0