PerfHUD enabler by Rene Rivera

git-svn-id: http://svn.code.sf.net/p/irrlicht/code/trunk@1396 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
hybrid 2008-06-24 15:32:20 +00:00
parent 6da17e04b6
commit 030213c71e
2 changed files with 33 additions and 15 deletions

View File

@ -172,6 +172,11 @@ watch registers, variables etc. This works with ASM, HLSL, and both with pixel a
Note that the engine will run in D3D REF for this, which is a lot slower than HAL. */
#define _IRR_D3D_NO_SHADER_DEBUGGING
//! Define _IRR_USE_NVIDIA_PERFHUD_ to opt-in to using the nVidia PerHUD tool
/** Enable, by opting-in, to use the nVidia PerfHUD performance analysis driver
tool <http://developer.nvidia.com/object/nvperfhud_home.html>. */
#undef _IRR_USE_NVIDIA_PERFHUD_
#ifdef _IRR_WINDOWS_API_
@ -347,3 +352,4 @@ precision will be lower but speed higher. currently X86 only
#endif // __IRR_COMPILE_CONFIG_H_INCLUDED__

View File

@ -253,9 +253,22 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
present.Windowed = TRUE;
}
UINT adapter = D3DADAPTER_DEFAULT;
D3DDEVTYPE devtype = D3DDEVTYPE_HAL;
#ifndef _IRR_D3D_NO_SHADER_DEBUGGING
devtype = D3DDEVTYPE_REF;
#elif defined(_IRR_USE_NVIDIA_PERFHUD_)
for (UINT adapter_i = 0; adapter_i < pID3D->GetAdapterCount(); ++adapter_i)
{
D3DADAPTER_IDENTIFIER9 identifier;
pID3D->GetAdapterIdentifier(adapter_i,0,&identifier);
if (strstr(identifier.Description,"PerfHUD") != 0)
{
adapter = adapter_i;
devtype = D3DDEVTYPE_REF;
break;
}
}
#endif
// enable anti alias if possible and desired
@ -263,7 +276,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
{
DWORD qualityLevels = 0;
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
devtype, present.BackBufferFormat, !fullScreen,
D3DMULTISAMPLE_4_SAMPLES, &qualityLevels)))
{
@ -273,7 +286,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
present.SwapEffect = D3DSWAPEFFECT_DISCARD;
}
else
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
devtype, present.BackBufferFormat, !fullScreen,
D3DMULTISAMPLE_2_SAMPLES, &qualityLevels)))
{
@ -283,7 +296,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
present.SwapEffect = D3DSWAPEFFECT_DISCARD;
}
else
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,
if (SUCCEEDED(pID3D->CheckDeviceMultiSampleType(adapter,
devtype, present.BackBufferFormat, !fullScreen,
D3DMULTISAMPLE_NONMASKABLE, &qualityLevels)))
{
@ -303,17 +316,17 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
if (StencilBuffer)
{
present.AutoDepthStencilFormat = D3DFMT_D24S8;
if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype,
present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, present.AutoDepthStencilFormat)))
{
present.AutoDepthStencilFormat = D3DFMT_D24X4S4;
if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype,
present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, present.AutoDepthStencilFormat)))
{
present.AutoDepthStencilFormat = D3DFMT_D15S1;
if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype,
present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, present.AutoDepthStencilFormat)))
{
@ -323,7 +336,7 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
}
}
else
if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDepthStencilMatch(adapter, devtype,
present.BackBufferFormat, present.BackBufferFormat, present.AutoDepthStencilFormat)))
{
os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING);
@ -334,17 +347,17 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
if (!StencilBuffer)
{
present.AutoDepthStencilFormat = D3DFMT_D32;
if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype,
present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, present.AutoDepthStencilFormat)))
{
present.AutoDepthStencilFormat = D3DFMT_D24X8;
if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype,
present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, present.AutoDepthStencilFormat)))
{
present.AutoDepthStencilFormat = D3DFMT_D16;
if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
if(FAILED(pID3D->CheckDeviceFormat(adapter, devtype,
present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE, present.AutoDepthStencilFormat)))
{
@ -368,15 +381,15 @@ bool CD3D9Driver::initDriver(const core::dimension2d<s32>& screenSize, HWND hwnd
}
else
{
hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd,
hr = pID3D->CreateDevice(adapter, devtype, hwnd,
fpuPrecision | D3DCREATE_HARDWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if(FAILED(hr))
hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd,
hr = pID3D->CreateDevice(adapter, devtype, hwnd,
fpuPrecision | D3DCREATE_MIXED_VERTEXPROCESSING , &present, &pID3DDevice);
if(FAILED(hr))
hr = pID3D->CreateDevice(D3DADAPTER_DEFAULT, devtype, hwnd,
hr = pID3D->CreateDevice(adapter, devtype, hwnd,
fpuPrecision | D3DCREATE_SOFTWARE_VERTEXPROCESSING, &present, &pID3DDevice);
if (FAILED(hr))
@ -1151,7 +1164,6 @@ void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
}
void CD3D9Driver::draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
video::SColor* colors, bool useAlphaChannelOfTexture)
@ -1215,7 +1227,6 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture, const core::rect<s
}
//! draws a 2d image, using a color and the alpha channel of the texture if
//! desired. The image is drawn at pos and clipped against clipRect (if != 0).
void CD3D9Driver::draw2DImage(const video::ITexture* texture,
@ -2517,3 +2528,4 @@ IVideoDriver* createDirectX9Driver(const core::dimension2d<s32>& screenSize, HWN