🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Yay, performance monitoring

posted in DruinkJournal
Published September 20, 2005
Advertisement
Well it turns out that Telewest aren't coming till next Tuesday; my dad got the installation date wrong. So I got some proper sleep, then got coffee'd up, and got some coding done. And also, my bed is due to arrive on Friday. Yay!

So, I did a bit of work on the MMORPG client program for a change (not the editor). I changed my CD3DDevice class a little, so it buffers render states, and also allows you to chain up states like a stack. For example, to turn on alpha blending, draw something alpha blended, then put alpha blending back to it's original state, you use this code:
void Foo(){   RenderState theState(D3DRS_ALPHABLENDENABLE,TRUE);   // Drawing code here}
That's it. When the RenderState goes out of scope, it tells the device to put the state back to what it was. The constructor stores the current state (set by the device).

I also altered my Log() and DebugLog() function a little. Log() now gets the current directory when it's first called, so fopen() (Yes, C file I/O, I'm a horrible person) doesn't try to create "Log.txt" in a different directory if you change the current directory.
DebugLog() now checks the global variable g_bDebug, and calls Log() if it's true.

And I added real command line parsing. So a release mode app can be run with the -debug flag to enable extra logging information.

And, saving the best till last, I added a bunch of fun assembly instuctions and some Win32 functions to log the CPU speed and name, amount of RAM used and availiable and the OS. Because I intend to use sprite sheets a lot, I need to determine the best size for them. I was using the cards maximum texture size before, but I realised last night that that means my GeForce 4 with 128Mb of RAM is allocating 64MB textures. Which can't be a good thing.
So, I now check the amount of availaible texture memory, and use that as a best guess of how large to make the textures. If the ideal size is larger than the supported size, obviously it falls back to the largest supported size.
So now, when I run my app, I get all this fun stuff spewed out:
MAIN  : Application started at 20:58:26 on 20/09/2005MAIN  : Parsing comand line: ""MAIN  : Command line parsing completePERF  : CPU ID: AMD Athlon(tm) XP 2600+ (AuthenticAMD)PERF  : CPU Features: FPU MMX 3DNow! Ex3DNow! SSEPERF  : CPU speed: ~1916MHzPERF  : Physical RAM: 192MB/511MBPERF  : OS: Windows 2000 Service Pack 4RENDER: Creating D3D9 object... DoneRENDER: Listing 2 device adapters:RENDER: * Adapter index 0 is called "NVIDIA Dualview"RENDER: * Adapter index 1 is called "NVIDIA GeForce4 Ti 4400"RENDER: Requesting device caps... DoneRENDER: Maximum texture size is 4096x4096RENDER: Choosing backbuffer format... D3DFMT_X8R8G8B8RENDER: Choosing texture format... D3DFMT_A8R8G8B8RENDER: Choosing depth-stencil format... D3DFMT_D24S8RENDER: Creating device... DoneMAIN  : Render device reports ~226MB free for texturesMAIN  : Chose texture size of 2048x2048 based on availiable video memoryRENDER: Shutting down D3D device... DonePERF  : Approximate FPS: 324.90MAIN  : Application shutting down at 20:58:33 on 20/09/2005
Isn't that exciting? And here's what you get without -debug (It's hard-coded just now, just so my friends don't need to run it with -debug when they test it):
MAIN  : Application started at 20:58:26 on 20/09/2005MAIN  : Parsing comand line: ""MAIN  : Command line parsing completeMAIN  : Chose texture size of 2048x2048 based on availiable video memoryMAIN  : Application shutting down at 20:58:33 on 20/09/2005
Hooray!

I probably won't get much done tomorrow. I'm supposed to be meeting up with my friend (the one mentioned in my previous two entries). I picked her up from Rosyth (Fife) earlier tonight, and we were going to watch a bit of a [music] DVD here, then I was going to drop her off at her friends. But she had to be at her friends for 9ish, and we didn't get back to mine till 8:45, so we agreed to meet up tomorrow instead, and I dropped her of at her friends.
However, going by her track record, I might not meet her tomorrow at all, so we'll see.
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement