Game Development Community

Animation choppiness due to VRAM getting full?

by Vern Jensen · in Torque Game Builder · 03/26/2008 (12:13 pm) · 0 replies

I've noticed recently that my game's animation is starting to stutter pretty noticeably. As the game progresses, I continue to add more ImageMaps to the game. (I make sure to uncheck "preload" for the big ones.) The thing is, even on levels in which only a few ImageMaps are used, and barely anything is happening, the animation still stutters. This didn't used to happen.

I believe the problem is due to *VRAM* getting "too full" -- I'm guessing textures are having to be uploaded to the graphics card mid-animation, which is slowing things down. Here are reasons why I believe this is the likely culprit:

1) I'm running on a 20" display, which is 1680x1050 resolution. I have my game use whatever resolution the computer is already at, and just go full-screen. It looks very nice of course. :-) In any case, while the animation has begun to stutter at this resolution, if I change the game to switch to 800x600 (internally, scaling upward to fit) then it runs perfectly smooth.

BTW, this is *not* a fillrate problem. The game stutters even when there is only a single 1024x1024 image on the screen as a background, and just one small (64x64 or smaller) sprite on the screen.

2) If I *quit* the TGB editor before running my game, then this also causes my game to run perfectly smoothly. This again would seem to confirm my theory: since TGB's editor is now not taking up VRAM on my computer's graphics card, my game has much more VRAM to work with itself.

3) My game used to run perfectly fine, full-resolution, and even with the TGB editor running in the background, until fairly recently. Since I've been continuing to add art assets to the game, this again confirms my suspicion that VRAM is getting "full", causing texture-swapping, hence animation choppiness.


Now for the questions:

1) Is there any way I can confirm that VRAM is indeed the problem here? And if so, how should I go about fixing it, other than telling customers to quit other programs before running my game, in case one of them is also taking up VRAM on the graphics card?

2) I'd really like to know a lot more about what goes on behind the scenes in Torque. When an image is marked as "preload' does that mean it's preloaded into main memory, VRAM, or both? When it's marked "Allow unload" does this refer to being unloaded from VRAM, main memory, or both? And will it *always* be unloaded when you load a new level, or only if memory gets tight and the need is there to unload it?

3) I forget where I saw it, but I remember reading on these forums about how Torque adds 1/3 the memory to your project because it creates copies of your texture in all smaller powers of 2. For instance, if you load a 512x512 texture, it also creates 256x256, 128x128, 64x64, 32x32, 16x16, and so on powers of that texture, I guess for the purpose of optimizing fillrate if your object is scaled down. If I were to disable this feature (major engine modifications), could this save VRAM at all? In other words, when Torque creates all these smaller textures, are they *all* loaded into VRAM, or is only one size typically loaded into VRAM, and the others kept only in main memory?

4) Is there some way upon my game's startup to "take over" the graphics card, so if other programs are already running and taking up VRAM on it, that I can somehow request they release the memory they're taking on the card, and give it to my program? Or do I just need to tell customers to quit those programs first, or buy a card with more VRAM?

Any other suggestions/tips appreciated...

-Vern

P.S. I'm aware of this article below, but some of it seems outdated? It seems for instance that ChunkedBitmap doesn't exist anymore, or if so, it's certainly not documented, so I don't know how to use it. I *do* use large (1024x1024) backgrounds for my levels at times, so if there is a better way than just putting it in an imageMap, I'm open to other ways.

http://tdn.garagegames.com/wiki/2D_Art_Tips:_Learn_From_My_Mistakes