From 6fb36fca8fef703da43858e2cc4d5f3471e4fb26 Mon Sep 17 00:00:00 2001 From: botanic Date: Fri, 7 Feb 2014 19:49:40 -0800 Subject: [PATCH] Add CMAKE option and NVIDIA PerfHUD support --- code/CMakeModules/nel.cmake | 1 + .../3d/driver/direct3d/driver_direct3d.cpp | 36 +++++++++++++++---- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/code/CMakeModules/nel.cmake b/code/CMakeModules/nel.cmake index ad6fbb2ae..8c0124fa2 100644 --- a/code/CMakeModules/nel.cmake +++ b/code/CMakeModules/nel.cmake @@ -236,6 +236,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS) OPTION(WITH_COVERAGE "With Code Coverage Support" OFF) OPTION(WITH_PCH "With Precompiled Headers" ON ) OPTION(FINAL_VERSION "Build in Final Version mode" ON ) + OPTION(WITH_PERFHUD "Build with NVIDIA PerfHUD support" OFF ) # Default to static building on Windows. IF(WIN32) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 13306432f..864406205 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -1464,6 +1464,24 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r return false; } + #if WITH_PERFHUD + // Look for 'NVIDIA PerfHUD' adapter + // If it is present, override default settings + for (UINT gAdapter=0;gAdapter<_D3D->GetAdapterCount();gAdapter++) + { + D3DADAPTER_IDENTIFIER9 Identifier; + HRESULT Res; + Res = _D3D->GetAdapterIdentifier(gAdapter,0,&Identifier); + + if (strstr(Identifier.Description,"PerfHUD") != 0) + { + nlinfo ("Setting up with PerfHUD"); + adapter=gAdapter; + _Rasterizer=D3DDEVTYPE_REF; + break; + } + } + #endif WITH_PERFHUD // Create the D3D device HRESULT result = _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_PUREDEVICE, ¶meters, &_DeviceInterface); if (result != D3D_OK) @@ -1487,6 +1505,8 @@ bool CDriverD3D::setDisplay(nlWindow wnd, const GfxMode& mode, bool show, bool r } } + + // _D3D->CreateDevice (adapter, _Rasterizer, _HWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, ¶meters, &_DeviceInterface); // Check some caps @@ -2635,13 +2655,15 @@ bool CDriverD3D::reset (const GfxMode& mode) #ifndef NL_NO_ASM CFpuRestorer fpuRestorer; // fpu control word is changed by "Reset" #endif - HRESULT hr = _DeviceInterface->Reset (¶meters); - if (hr != D3D_OK) - { - nlwarning("CDriverD3D::reset: Reset on _DeviceInterface error 0x%x", hr); - // tmp - nlstopex(("CDriverD3D::reset: Reset on _DeviceInterface")); - return false; + if (_Rasterizer!=D3DDEVTYPE_REF) { + HRESULT hr = _DeviceInterface->Reset (¶meters); + if (hr != D3D_OK) + { + nlwarning("CDriverD3D::reset: Reset on _DeviceInterface error 0x%x", hr); + // tmp + nlstopex(("CDriverD3D::reset: Reset on _DeviceInterface")); + return false; + } } }