Quote:Original post by tufflax
I don't know what you are talking about, remigius. What is unmanaged resources? What is the correct way to handle them? What is ResourceManagmentMode.Manual? So basically I have no idea of what to do in order to correct this error.
In DirectX, so on the PC, you essentially have two types of memory to worry about, RAM (internal memory) and VRAM (memory on your graphics card)
1. Stuff used by the video card typically needs to be in VRAM, so your textures, vertices etc need to go from your RAM (into which it is loaded from the HD or generated by the CPU) to VRAM.
There are two common ways to go about this. One way is to use ResourceManagementMode.Automatic when loading your stuff, which will copy resources into your VRAM as needed and remove unused resources if your VRAM is filling up. Using RMM.Automatic reserves a part of your RAM to back this swapping and an advantage of that is that resources managed this way can survive device resets without any intervention from you. Another way is to use RMM.Manual, which means there's no backing RAM memory. When a device is lost (happens when minimizing, screensaver kick in, user-switch etc), Windows basically kicks your application from VRAM
2, so you'll need to recreate any RMM.Manual resources yourself once the device resets, ie when your app gets it back.
There a lots of subtleties here and I'm probably only confusing you with bits of the puzzle, so my advice is to check out the
XNA Docs for a more coherent description. Google (and the documentation in the DirectX SDK) can probably give you more info on handling lost devices and device resets.
Now, whatever you do, don't get discouraged! Over time, you'll come to know these properties and most of the time you don't need to worry about them too much. But now that you've got at least some vague idea what the ResourceManagementMode does, we can move on to our revelation. As it so happens, RenderTargets and the like only exist in VRAM (for performance reasons, VRAM > RAM), so basically they're using RMM.Manual. So you have to dispose them when the device is lost and recreate them when it resets.
Now, how does that help you? In the (Un)LoadGraphicsContent() methods of your game, you'll notice sections reserved for disposing/recreating RMM.Manual resources. As you might have guessed, taking care of the RenderTarget (and any other RMM.Manual) objects there should solve your problem.
1This may or may not hold true for XBox deployment, but my guess is that it does
2For simplicity's sake
Quote:And also, that "DX debug runitme" is for DX and XNA is not DX. Maybe, and probably since you mentioned it, I can use it somehow for XNA but I don't have that DirectX Control Panel thing in my Control Panel. And I'm not using DX so I don't know if I should install it.
As Moe said, XNA basically is a wrapper (yes, yes, a very fancy one and we all love it [wink]) around DirectX, on the PC that is. You'll probably need to download and install the
DirectX SDK later on anyway, since the only official way to get sound to work in XNA is to use the XACT utility that comes with the SDK. Anyway, using the debug runtimes will output exactly what call into DirectX caused the error, allowing you to figure out what is wrong (resource disposed/invalid, wrong setting, unsupported operation etc).
*pfew* Hope this helps :)