Skip to main content
gamedev.net
🔒 Locked

Reset() fails with unknown return code

Started by Night Elf 12 replies 6.9k views
Original Post
Night Elf
Night Elf
The DX Docs say there are four possible result codes for IDirect3DDevice8::Reset(): D3D_OK, D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, and E_OUTOFMEMORY. I call Reset() and test the result against each of those values, but it turns out it''s none of them !! Has anyone else experienced this problem? Does anyone know why this could be happening?
glassJAw
glassJAw
What''s the integer value of the return code?
Night Elf
Night Elf
The value is -2005530520 decimal.

I tried DX Error Lookup, but it was no help. This was the output:


HRESULT: 0x7789f798 (2005530520)
Name: Unknown
Description: n/a
Severity code: Success
Facility Code: Unknown (6025)
Error Code: 0xf798 (63384)
Hierophante
Hierophante
That looks so completely wrong as to not be a valid error code. If the code isn''t a human-readable number (like 10060, WSAETIMEDOUT), then something else is going on. Is the D3DDevice pointer valid? Look for memory corruption problems elsewhere. Poke at the debugger to make sure that you are looking at the right number.
ph33r
ph33r
I''ve had that happen before - it usually has something to do with a call before that call. The call didn''t even have a chance to fail because something else went totally wrong before it to find out which function is failing do this

1) Go to control panel and directX
2) switch to debug mode and bring slider bar to full
3) check all the boxes like break on recourse leak
4) Make sure you are in windowed mode when you debug because full debug isn''t that nice about returning to windows easily plus debugging in windowed is much easier rather then fullscreen.
5) Read your debug window it should tell you which function failed

Good luck
don
don
The error you posted (-2005530520) is 0x88760868 in hex. Looking up that hex value using the DX Error Lookup utility provided in the DX9 SDK reveals this:

HRESULT: 0x88760868 (2289436776)
Name: D3DERR_DEVICELOST
Description: Device lost
Severity code: Failed
Facility Code: Unknown (2166)
Error Code: 0x0868 (2152)


Dave Hunt
Dave Hunt
quote:
Original post by don
Name: D3DERR_DEVICELOST
Description: Device lost



Which is kind of funny, since about the only reason to call Reset() is when the device is lost...
don
don
It''s actually a valid return code. From the DX9 SDK docs for IDirect3DDevice9::Reset...

If the method succeeds, the return value is D3D_OK.

If the method fails, the return value can be one of the following values.


D3DERR_DEVICELOST
The device has been lost but cannot be reset at this time. Therefore, rendering is not possible.

...


The app should probably be calling TestCooperativeLevel until it says that the device can be reset (returns D3DERR_DEVICENOTRESET). Then the call to Reset should be made.
Dave Hunt
Dave Hunt
quote:
Original post by don
It''s actually a valid return code.



I didn''t doubt you. It just struck me as humorous. I guess I''m easily amused at times.

Night Elf
Night Elf
Thanks for your help... but so far I haven''t been able to solve my problem.

I''ll explain what''s happening to me with greater detail: When working in full screen mode, I ALT+TAB to exit and then re-enter my app. That''s when I receive a D3DERR_DEVICENOTRESET return code from the TestCooperativeLevel() function (not DEVICELOST). When I call Reset() it throws the code I posted earlier.

ph33r: I would use the debug runtime output if I could but I installed the SDK with release runtime and now I cannot change it, no matter how many times I reinstall choosing Debug. (You may have noticed my other thread...)

don: I looked up the code using DX Error Lookup utility as you did, but pasting the number and selecting ''decimal.'' Maybe it has problems with negative numbers, because it returned the information for the positive value (which is an unknown code). So, you may be right and It''s a D3DERR_DEVICELOST code...

I want to point out that all resources the application allocates use the D3DPOOL_MANAGED flag, so they need no restoration. There''s one exception though, the font rendering code (based on CD3DFont), but I call the appropriate functions to release the resources before Reset() and to recreate them after the Reset() call.

Can anyone figure out what the problem might be?
Night Elf
Night Elf
I managed to install the DX Debug runtime downloading the Developer Runtime form MS'' site (it should have worked before, as I was using the full SDK... who knows.)

Now I see the Reset() function is failing because there are (as the debug output shows) three D3DPOOL_DEFAULT resources still allocated - one index buffer and two vertex buffers.

However, I haven''t declared such buffers, all my buffers (and other resources) are created in the MANAGED pool. Maybe there are some DirectX objects that use DEFAULT pool resources internally. I know, for example, that I must call OnLostDevice() and OnResetDevice() for ID3DXSprite objects. Are there any other objects that have to be treated simmilarly?

Is there any way to know where in my code are those buffers the debug output refers to? It provides no memory address or anything similar.
don
don
I would suspect it is D3DX then. I don''t use that API so I can''t be of much help to you.

If you crank up the debug level to max and step through your program, maybe the debug runtime will spew out something when it creates a vertex buffer under the hood via a D3DX routine.

You could try linking your app to the debug version of the D3DX lib. Maybe it will output something to the debugger that would help make sense of things.

Other than that, there''s this spiffy new D3DSpy utility provided with the SDK that might allow you to associate a particular D3DX call with the creation of an underlying D3D resource.

Good luck.
Buster
Buster
This may be over-kill, but it works so it''s how I do it.

When you alt-tab the game, release the d3dDevice and any of the relevent D3D crap (textures, vbs, etc). When you come back, reload them.

Another option is to catch any instance where the app gets minimized and dissallow it (WM_ACTIVATE, Alt-Tab, etc).
Metzler
Metzler
I had the same problem.
For me it was a CD3DFont Object which i didnt release b4 the rest...
Took me many days to find this bug

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.