In XNA 4.0 to analyze a program with PIX you need to press the "More options" button and then check the "Disable D3DX analysis" check-box.
If you want to use futures like events and markers from your game I attached a file containing methods that give you access to those function.
Here is a download link from Microsoft SkyDrive(if you have an account and you are not logged in you might not see it):
PIX XNA C#
Status() - Determine if the profiler is connected to the program.
Disable() - Notify PIX that the target program does not give permission to be profiled.
BeginEvent(Color color,String name) - Marks the beginning of a user-defined event. PIX can use this event to trigger an action.
EndEvent() - Mark the end of a user-defined event. PIX can use this event to trigger an action.
SetMarker() -Mark an instantaneous event. PIX can use this event to trigger an action.
This functions should work under windows and give no errors on any other platform.
I always place a if Status() then Disable() in my final product on the end of all the load sequences so others can's find exploits in my games.
If you open an event close it, if you don't close an event it will be automatically closed at the end of the frame by PIX.
For more information see the PIX helper function page on MSDN, i used the same summary for the functions that they gave.
Events can be nested in other events.
I never was able to see the color of an event change,not on native Directx nor on XNA.
To use PerfHud under XNA 4.0 you need to add an event on the GraphicsDeviceManager just after you create it for it's PreparingDeviceSettings(+= new EventHandler<PreparingDeviceSettingsEventArgs>)
in that event you must go trough each available adapter, and set on the e.GraphicsDeviceInformation.Adapter
that adaptor that has "PerfHUD" in it's description,after that set the GraphicsAdapter.UseReferenceDevice to true :
public Game1()
{
graphics = new GraphicsDeviceManager(this);
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
}
void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
foreach (GraphicsAdapter adapter in GraphicsAdapter.Adapters)
{
if (adapter.Description.Contains("PerfHUD"))
{
e.GraphicsDeviceInformation.Adapter = adapter;
GraphicsAdapter.UseReferenceDevice = true;
break;
}
}
}
If you create your own device simply set the device with the description "PerfHUD" :
foreach (GraphicsAdapter adapter in GraphicsAdapter.Adapters)
{
if (adapter.Description.Contains("PerfHUD"))
{
GraphicsAdapter.UseReferenceDevice = true;
graphicsDevice = new GraphicsDevice(adapter,p, parameters);
break;
}
}
if (graphicsDevice == null)
{
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, p, parameters);
}
Now you can run PerfHud by using the send to option on the exe :
This products complement each other in many ways, PIX uses a static approach but has per vertex and per pixel debugging while PerhHud offers live information about your graphic card,driver level and cpu plus it lets you change on the fly textures,states,shaders and rendertargets and you can even playback and analyze drawcals on all levels.
If you want to make something different then the next pong you will need access to this tools.
For information on how to use PerfHUD see the nvidia site as they have a lot of documentation and vide info about it.
For PIX information see the Microsoft sites or do a Google search as there are many tutorials about the subject.


I don't have a working Nvidia card right now.
ReplyDeleteFor me the above approach always results in XNA activating software vertex processing, which gives misleading timings or on a full game just slows to 2 fps. Does it stay in hardware mode for you?
Unfortunately you need an Nvidia card to run PerfHud, but if you have an ATI card you can use Ati Perf Studio(http://developer.amd.com/gpu/PerfStudio/Pages/default.aspx)
ReplyDeleteor if you have an Intel adapter you could use Intel Graphics Performance Analyzer(http://software.intel.com/en-us/articles/intel-gpa/)