Restoration in DX8 Possible Bug Solution!
IodiplinI realize some have had troubles getting restoration to work in DX8. I was having the same problem. After much work in narrowing it down, the problem is quite simple: Collecting a pointer for the back buffer for the use of rendering DX8 "Surfaces" will cause DX8 to crash upon render call after Reset. Basically, I made my engine have the capability to render DX8 Surfaces (not restricted to size or shape, render easily in REF, but can only be rendered at 0,0 and without any modifications). This was my engine's bane however, because in doing so it was un able to reset (upon form resize, alt-tab, etc.). I merely remarked the line in my initialization code that collected the pointer to the back buffer (used for rendering such surfaces) and all worked beautifully. This post is merely to let others know that their days of misery are over. However, this does mean that you can't render surfaces or at least will have to find a way to "uncapture" the pointer and "recapture" it after reset. Fortunately, surfaces are pretty much useless, so doing away with them won't kill anybody. [:)] Hope this helps!
IodiplinAlso...If you're using the font rendering in the D3DX library, you must always call the font's OnLostDevice mothod before resetting and OnResetDevice after resetting, otherwise DX8 will crash (bringing your program with it) when you try to render with the font.
Eric ColemanThanks for that information, it's good to know.
Almar JolingYes, I've had this too a while back. Also stuff that is still locked can give problems.
IodiplinI've found why that happens: From the SDK: "Render target surfaces are placed in the D3DPOOL_DEFAULT memory class." Remeber, you must always release any POOL_DEFAULT memory before resetting. So there is a way to destroy the pointer and recreate it after reset so you can still use surfaces. [:)]
IodiplinIt's final. I've tested it and everything. The solution to using surfaces AND having restoration is very simple. Before resetting the device, set the pointer to nothing. For example: [code] Set ptrBackBuffer = Nothing [/code] After resetting the device, merely aquire it again. [code] Set ptrBackBuffer = Device.GetRenderTarget [/code] I tested it and it works. I did not have to reload or do anything special to my loaded surface. I believe the same goes for render target pointers and surfaces used for additional swap chains.
masterboodaJust wanted to put my two cents in... I just wanted to let people know that if you are using the DX8 sprites, you have to release those also... just something i found out with the DaBooda engine... Also surfaces are actually more important than people think because it is essential to use them to create graphics during runtime... a program with one 256x256 image to create 100's of different images is a whole lot smaller than trying to export one with 100's of individual images... This is just my opinion on the last matter.... DaBooda out...
IodiplinThanks... DX8 Sprites eh? I've never used them. Are they useful/easy to use? Ah, I didn't realize you could do that with surfaces, though it makes sense now that you mention it. [:)]