PerfHud Permissions and T3D
by Steve Acaster · in Torque 3D Professional · 02/14/2010 (12:41 pm) · 14 replies
Not being the programming type, I'm slightly confused as to where exactly I'm supposed to put the PerfHud authorization code for Dx9. I reckon it's in gfxD3D9pcgfxPCD3D9Device.cpp, but I'm not certain where.
Anyone have any ideas?
[hmmm ... I've just seen a mEnableNVPerfHUD=bool ... I wonder if ...)
[edit] no it wasn't just that simple ...
Anyone have any ideas?
[hmmm ... I've just seen a mEnableNVPerfHUD=bool ... I wonder if ...)
[edit] no it wasn't just that simple ...
About the author
One Bloke ... In His Bedroom ... Making Indie Games ...
#2
02/14/2010 (6:00 pm)
Hmmm, maybe I'm "doing it wrong" nothing but crashes using the "send to".
#3
02/14/2010 (11:22 pm)
Steve.. Good luck, I have never gotten perfHud to run good on my machine without crashing. Not sure why but I may try it again. For some reason several of the Nvidia applications just will not run on my machine, even with the latest drivers. I suspected it might be because of the fact i was running SLI.
#4
02/14/2010 (11:56 pm)
had little problem previously. sure you have the right one (in case you are on 64bit. as there are two then, the 64bit -> 64bit and the 64bit -> 32bit which would be needed for this case)
#5
I added in the LIB and INCLUDE directories in Visual Studio (not sure if that's needed?) then changed the following:
to
Re-Compiled and all I get is:

That's trying to run the re-compiled version straight from visual studio, if I drag the EXE into NVIDIA PerfHUD 6 32bit Launcher then I just get a crash...
Tried both Debug and Release version both with the same results, I played with the device creation code some and managed to kill the error when running from Visual Studio (Thought that error may be causing the crash) tried running PerfHud again = crash...
This is in 1.1B, Win7 64, GForce 9800GT
Event Log only shows an EventID of 1000, has anyone had it working with an earlier version of T3D or < v6.6 PerfHud?
02/15/2010 (4:00 pm)
Downloaded the 32 on 64 PerfHud I added in the LIB and INCLUDE directories in Visual Studio (not sure if that's needed?) then changed the following:
bool GFXPCD3D9Device::mEnableNVPerfHUD = false;
to
bool GFXPCD3D9Device::mEnableNVPerfHUD = true;
Re-Compiled and all I get is:

That's trying to run the re-compiled version straight from visual studio, if I drag the EXE into NVIDIA PerfHUD 6 32bit Launcher then I just get a crash...
Tried both Debug and Release version both with the same results, I played with the device creation code some and managed to kill the error when running from Visual Studio (Thought that error may be causing the crash) tried running PerfHud again = crash...
This is in 1.1B, Win7 64, GForce 9800GT
Event Log only shows an EventID of 1000, has anyone had it working with an earlier version of T3D or < v6.6 PerfHud?
#6
Also that's what I get if I set my DxSDK Dx Control Panel to debug rather than retail regardless of Perfhud.
02/15/2010 (4:04 pm)
Yeah, that's what I've been getting too using 32bit on a 32bit.Also that's what I get if I set my DxSDK Dx Control Panel to debug rather than retail regardless of Perfhud.
#7
02/15/2010 (4:05 pm)
*Edit* Got it (DxSDK Dx Control Panel), sorry I should look before speaking :P
#8
I modified the code in the engine in gfxPCD3D9Device.cpp, in the GFXPCD3D9Device::init() function so that if perfHUD is enabled (by any one of the several methods mentioned elsewhere in this thread), then it uses the slightly more correct method to find the PerfHUD adapter than what is currently in place. I did this as I thought this might be the root of the problem.
Alas, trying to launch via PerfHUD still causes a crash. So the problem was how to find out what was going on. If you are launching via PerfHUD, you can't really put a break point in the code as it is not launched under VS - or can you? I put in:
on line 240 of the file, just before it tests the usePerfHud boolean variable. Then I built the app, launched it via PerfHud, waited a few seconds and used the Debug->Attach To Process... command in Visual Studio to attach the dbugger to the app launch via PerfHud. I put a breakpoint on my little infinite loop, and whn it broke (instantly) I set the next statement to be the statement after the infinite loop, i.e. the
From here I was able to easily debug the problem. It turns out that CoInitialize fails when trying to initialize COM a bit later in this function, via the call to mCardProfiler->init(). A little Google-ing turns up the following link:
http://developer.nvidia.com/forums/index.php?showtopic=3563
This is as far as I've gotten so far, and it doesn't look particularly promising. Perhaps one of the GG guys has some wisdom to bestow here?
= Ed =
[Edit] I'm downloading version 6.62. According to the NVidia site:
"New in 6.62! Fix for the COM initialize bug". I'll report back what I find.
02/16/2010 (5:47 pm)
Ok, I've been trying to get this to work myself. Here is what I've done:I modified the code in the engine in gfxPCD3D9Device.cpp, in the GFXPCD3D9Device::init() function so that if perfHUD is enabled (by any one of the several methods mentioned elsewhere in this thread), then it uses the slightly more correct method to find the PerfHUD adapter than what is currently in place. I did this as I thought this might be the root of the problem.
Alas, trying to launch via PerfHUD still causes a crash. So the problem was how to find out what was going on. If you are launching via PerfHUD, you can't really put a break point in the code as it is not launched under VS - or can you? I put in:
while( 1 );
on line 240 of the file, just before it tests the usePerfHud boolean variable. Then I built the app, launched it via PerfHud, waited a few seconds and used the Debug->Attach To Process... command in Visual Studio to attach the dbugger to the app launch via PerfHud. I put a breakpoint on my little infinite loop, and whn it broke (instantly) I set the next statement to be the statement after the infinite loop, i.e. the
if ( usePerfHud )statement.
From here I was able to easily debug the problem. It turns out that CoInitialize fails when trying to initialize COM a bit later in this function, via the call to mCardProfiler->init(). A little Google-ing turns up the following link:
http://developer.nvidia.com/forums/index.php?showtopic=3563
This is as far as I've gotten so far, and it doesn't look particularly promising. Perhaps one of the GG guys has some wisdom to bestow here?
= Ed =
[Edit] I'm downloading version 6.62. According to the NVidia site:
"New in 6.62! Fix for the COM initialize bug". I'll report back what I find.
#9
However, I decided to nop the attempt to query the DxDiag stuff and see what happened next...
... and lo and behold - I have an operational PerfHUD!
To make this work I commented out 2 lines in Engine\source\platformWin32\videoInfo\wmiVideoInfo.cpp in the function WMIVideoInfo::_queryProperty(). In my copy of this file, they are located on lines 332-333. The new function looks as follows:
I'm not certain that this will break anything beyond DirectX possibly thinking that the PerfHud adapter is not DirectX compliant, but I don't so much care about that.
In any event, all the usual caveats apply: Use at your own risk, YMMV, No warranties expressed or implied, etc. I hope this helps.
= Ed =
02/16/2010 (6:47 pm)
Ok, so it still crashes. Right now it looks like it is crashing much further on, where it is trying to get DxDiag info for the device and the mDxDiagProvider that is being used call GetRootContainer() dies in this call. Since this looks like a code hook that is provided by PerfHUD's "adapter"?? via the CoCreateInstance COM call, there is no way I can debug this further.However, I decided to nop the attempt to query the DxDiag stuff and see what happened next...
... and lo and behold - I have an operational PerfHUD!
To make this work I commented out 2 lines in Engine\source\platformWin32\videoInfo\wmiVideoInfo.cpp in the function WMIVideoInfo::_queryProperty(). In my copy of this file, they are located on lines 332-333. The new function looks as follows:
bool WMIVideoInfo::_queryProperty( const PVIQueryType queryType, const U32 adapterId, String *outValue )
{
if( _queryPropertyDXGI( queryType, adapterId, outValue ) )
return true;
// else if( _queryPropertyDxDiag( queryType, adapterId, outValue ) )
// return true;
else
return _queryPropertyWMI( queryType, adapterId, outValue );
}I'm not certain that this will break anything beyond DirectX possibly thinking that the PerfHud adapter is not DirectX compliant, but I don't so much care about that.
In any event, all the usual caveats apply: Use at your own risk, YMMV, No warranties expressed or implied, etc. I hope this helps.
= Ed =
#10
02/16/2010 (6:51 pm)
Try this in Engine\source\gfx\D3D9\pc\gfxPCD3D9Device.cpp:if ( usePerfHud )
{
/*
hres = mD3D->CreateDevice( mD3D->GetAdapterCount() - 1, D3DDEVTYPE_REF,
winHwnd,
D3DCREATE_MIXED_VERTEXPROCESSING, // | D3DCREATE_MULTITHREADED,
&d3dpp, &mD3DDevice );
*/
for(UINT Adapter=0; Adapter<mD3D->GetAdapterCount(); Adapter++)
{
D3DADAPTER_IDENTIFIER9 Identifier;
hres = mD3D->GetAdapterIdentifier(Adapter, 0, &Identifier);
if (strstr(Identifier.Description, "PerfHUD") != 0)
{
hres = mD3D->CreateDevice( Adapter, D3DDEVTYPE_REF,
winHwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, // | D3DCREATE_MULTITHREADED,
&d3dpp, &mD3DDevice );
}
}
}
#11
And the $Video::useNVPerfHud = true; can be uncommented from core/main.cs
@Kerry, haven't tried your change as Ed posted first.
02/16/2010 (7:35 pm)
Excellent work there, Mr Rotberg!And the $Video::useNVPerfHud = true; can be uncommented from core/main.cs
@Kerry, haven't tried your change as Ed posted first.
#12
That is sort of the fix I mentioned near the top of my first post. There are problems with your code though. First of all, if you don't find a PerfHUD adapter, your code will fail to create any device. This is NOT what you want in case you wish to run without PerfHUD. There are other issues as well, such as creating multiple devices if there happen to be more than one adapter present with "PerfHUD" in the adapter identifier. This is what I used:
However, even if you do this, AND you are using the latest version of PerfHUD (6.62), you will still crash as I explained in my 2nd post above. I also provided a fix for that as well.
Good luck!
= Ed =
02/16/2010 (8:57 pm)
Kerry,That is sort of the fix I mentioned near the top of my first post. There are problems with your code though. First of all, if you don't find a PerfHUD adapter, your code will fail to create any device. This is NOT what you want in case you wish to run without PerfHUD. There are other issues as well, such as creating multiple devices if there happen to be more than one adapter present with "PerfHUD" in the adapter identifier. This is what I used:
if ( usePerfHud )
{
UINT AdapterToUse=D3DADAPTER_DEFAULT;
D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
for (UINT Adapter=0;Adapter<mD3D->GetAdapterCount();Adapter++)
{
D3DADAPTER_IDENTIFIER9 Identifier;
HRESULT Res;
Res = mD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
if (strstr(Identifier.Description,"PerfHUD") != 0)
{
Con::printf( "Found PerfHud adaptern" );
AdapterToUse=Adapter;
DeviceType=D3DDEVTYPE_REF;
break;
}
}
hres = mD3D->CreateDevice( AdapterToUse, DeviceType,
winHwnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING, // | D3DCREATE_MULTITHREADED,
&d3dpp, &mD3DDevice );
}However, even if you do this, AND you are using the latest version of PerfHUD (6.62), you will still crash as I explained in my 2nd post above. I also provided a fix for that as well.
Good luck!
= Ed =
#13
02/17/2010 (2:42 pm)
There is an "else" statement below my code in case there is no PerfHUD found. The "break" command is definitely needed in my example, though. Thanks for the comment.
#14
The log ends with: Using Direct3D9Ex: No
Has anyone got it working recently?
08/07/2013 (11:36 pm)
Using T3D 3.0 and PerfHUD 6.72 (32bit) on Win7 (64bit) and can't get it to run. I tried @Edward's solution for gfxPCD3D9Device.cpp and wmiVideoInfo.cpp and enabled it in main.cs. Still no luck!The log ends with: Using Direct3D9Ex: No
Has anyone got it working recently?
Associate Manoel Neto
Default Studio Name
...to my root main.cs file. Then you run T3D by right-clicking the EXE, selecting "Send to..." and then "NVPerfHUD" (you'll not be able to start up the EXE without going through perfHUD unless you comment/remove that script line).