views:

142

answers:

1

I'm using EasyHook and SlimDX to overlay some graphics using SlimDX's Sprite and Texture classes. When I resize windows some programs fine, but others will crash - Winamp's MilkDrop 2 gives me an ambiguous memory error for example.

I expect this is due to the after market Texture I created. The question is what VTable function should I hook and/or how/when do I dispose and recreate the Texture? Reset perhaps?

If it isn't obvious I don't know much about DirectX.

edit/ps: I paint the texture inside an EndScene hook, but I haven't created any other hooks yet...

+1  A: 

You shouldn't have to recreate texture at all if it was created in D3DPOOL_MANAGED (D3DPOOL parameter of IDirect3DDevice9::CreateTexture).

If you absolutely have to use D3DPOOL_DEFAULT and need to kill off lost textures, then, the simplest way would be to destroy all "perishable" objects before call to IDirect3DDevice9::Reset, and restore then after the call, but only if it was succesfull.

YOu could also track functions that may return D3DERR_DEVICELOST (there are two of them), but hooking only Reset() will be easier.

SigTerm
+1 Good answer. I'd definitely wager its a pool choice issue. Dunno why this question is Community Wiki though ...
Goz
I'm doing what SigTerm said on IDirect3DDevice9::Reset. Before then I did try managed and default pool, but it threw the same either way.
Ben