Over a million developers have joined DZone.

Using PerfHUD with XNA

DZone's Guide to

Using PerfHUD with XNA

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

I am definitely a fan of ATI cards. Had a few Geforces but didn’t liked them very much. I actually noticed image quality decrease when switching from an old Radeon 9800 to a Geforce 8k something. I’m very happy with my Radeon 4890, now for the downside, PerfHUD, a very handy tool for Game Developers is only available for NVIDIA chipsets and although ATI has it’s own GPUPerfStudio it’s not the same thing.
Anyway for those who have one and are developing for XNA you may have noticed that it doesn’t run PerfHUD out of the box.
You will get an error, something like:
“This applications is not configured for using PerfHUD. Consult the User’s Guide for more information”


Luckily there’s a little trick we can use to fix this, first we create a new class:

// class that inherits from GraphicsDeviceManager
public class PerfHUDGraphicDeviceManager : GraphicsDeviceManager
        public PerfHUDGraphicDeviceManager(Game game)
            : base(game) // Pass game to base class
        // We override the RankDevices to search for a PerfHUD
        protected override void RankDevices(List foundDevices)
            bool has_perfHud = false;
            foreach (var device in foundDevices)
                if (device.Adapter.Description.Contains("PerfHUD"))
                    has_perfHud = true;
            // Found PerfHUD
            if (has_perfHud)
                var temp = foundDevices.OrderBy(
                    (gdi) => !(gdi.Adapter.Description.Contains("PerfHUD"))
                foreach (var dev in foundDevices)
                    dev.DeviceType = DeviceType.Reference;

This class basically searches for PerfHUD, so when you open it with it this class detects that the software exists and allows it’s usage. If not found, the regular GraphicDeviceManager is used. Now instead of creating a new GraphicsDeviceManager() on your Game class just do something like:

public class Game1 : Game
		public Game1()
                    new PerfHUDGraphicDeviceManager(this);


I hope this helps.

Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.


Published at DZone with permission of David Amador, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.


Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.


{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}