Changing Graphics mode in DX9

BlitzMax Forums/BlitzMax Programming/Changing Graphics mode in DX9

Fry Crayola(Posted 2011) [#1]
I've had a search for this, but can't find much in the way of information about this particular issue.

I'm looking to implement the ability to change graphics modes whilst in the options screen of my game. My first port of call was to see if it's ending the current graphics and creating a new one had any effect, and that pretty much works.

If KeyHit(KEY_G) Then EndGraphics; GCCollect(); Graphics(800, 600)
If KeyHit(KEY_H) Then EndGraphics; GCCollect(); Graphics(1280, 720)


In DX9, switching between modes (or setting the same mode over and over) results in the memory usage reported in TaskManager increasing with each step, seemingly never being restored.

In OpenGL and DX7, there is no such increase. In all three drivers, the memory reported by GCMemAlloced does not increase.

It's not ideal behaviour, although the limited frequency of resolution changing means it's also not a major problem for me just yet, but in the meantime I wonder if anyone else has seen the same issue and has any ideas about what's causing it and whether or not it can be easily avoided?

Cheers folks.

Last edited 2011


Grey Alien(Posted 2011) [#2]
I think this is the known memory leak in the DX 9 driver: http://www.blitzbasic.com/Community/posts.php?topic=91524


Fry Crayola(Posted 2011) [#3]
That'll be it, thanks!

Looks like to be on the safe side, I'll put a counter in to restrict graphics mode changes before prompting a restart.


GfK(Posted 2011) [#4]
Looks like to be on the safe side, I'll put a counter in to restrict graphics mode changes before prompting a restart.
That's a really ugly and unprofessional way of dealing with it.

I'd try Zeke's fix for the problem (although, I didn't have much luck with it myself - probably misunderstood the instructions).


Fry Crayola(Posted 2011) [#5]
That's prompting as in suggesting that the user restarts the program for the change to take effect, not forcing the restart upon them for having the temerity to try a new resolution.

It's not ideal, it's still a little ugly, but it's not unprofessional.

This assumes, of course, that I can't get Zeke's fix or an alternative in place. :)


GfK(Posted 2011) [#6]
It's not ideal, it's still a little ugly, but it's not unprofessional.
Sure its unprofessional: "we've got a memory leak that we don't know how to fix - to make sure the game doesn't fall flat on its arse we recommend you restart it now".


DrDeath(Posted 2011) [#7]
Sure its unprofessional: "we've got a memory leak that we don't know how to fix - to make sure the game doesn't fall flat on its arse we recommend you restart it now".

There are quite a few triple-A titles that do exactly the same.


Fry Crayola(Posted 2011) [#8]
It'd be unprofessional if that's exactly how I put it to the user. :)


Corum(Posted 2011) [#9]
I remember World of Warcraft used to ask me a game restart in order to apply graphics settings changes. :-)


col(Posted 2011) [#10]
perhaps its a core DirectX issue that even M$ themselves aren't sure how to fix :o)

Last edited 2011