We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1491 - Directx3d Crash on resize
Summary: Directx3d Crash on resize
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.0
Hardware: x86 Windows 7
: P2 critical
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-12 13:28 UTC by Jeff Shanab
Modified: 2013-02-11 21:41 UTC (History)
3 users (show)

See Also:


Attachments
The cpp file (11.84 KB, text/plain)
2012-05-12 13:28 UTC, Jeff Shanab
Details
Data file needed for this test (55.00 KB, text/plain)
2012-05-12 13:29 UTC, Jeff Shanab
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Shanab 2012-05-12 13:28:46 UTC
Created attachment 856 [details]
The cpp file

Using a streaming texture and a second window crashes on resize of the window with the directx errors

Direct3D9: (ERROR) :All user created D3DPOOL_DEFAULT surfaces must be freed before ResetEx can succeed. ResetEx Fails.
Direct3D9: (ERROR) :ResetEx failed and ResetEx/TestCooperativeLevel/Release are the only legal APIs to be called subsequently
D3D9 Helper: IDirect3DDevice9::Reset failed: D3DERR_INVALIDCALL

This context is from this point unuseable.

This works fine when linked against the 1.3.0-5557 

Attached is a modified mooserun example that shows the issue when linked against sdl 2.0.0-6302

PS you will need the dat file also
Comment 1 Jeff Shanab 2012-05-12 13:29:53 UTC
Created attachment 857 [details]
Data file needed for this test
Comment 2 vctos 2012-07-26 23:58:49 UTC
This bug can be reprodused with unmodified VisualC tests from current SDL distributive: testscale, testdraw and some others runned with --resize parameter.
after window size changed or when full screen switched (Cntrl-Enter) drawing halted.

testscale and testdraw runned with '--resize --renderer opengl' parameters works fine.
Comment 3 Shane Peelar 2012-08-30 23:41:37 UTC
Was able to reproduce bug exactly as described.
Comment 4 vctos 2012-08-31 22:24:38 UTC
SDL_DestroyRenderer() and SDL_CreateRenderer() calls on SDL_WINDOWEVENT_RESIZED
SDL_WINDOWEVENT_SIZE_CHANGED events can solve this problem partially.
Comment 5 Spinduluz 2013-01-05 12:02:41 UTC
RenderTarget has to be released before a device reset is done. It's a D3DPOOL_DEFAULT surface (resides in video memory and have to be recreated).

Try this patch on SDL_render_d3d.c
@@ -361,6 +361,7 @@ D3D_Reset(SDL_Renderer * renderer)
     D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
     HRESULT result;
 
+	IDirect3DSurface9_Release(data->defaultRenderTarget);
     result = IDirect3DDevice9_Reset(data->device, &data->pparams);
     if (FAILED(result)) {
         if (result == D3DERR_DEVICELOST) {
@@ -371,6 +372,8 @@ D3D_Reset(SDL_Renderer * renderer)
             return -1;
         }
     }
+	IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget);
+	
     IDirect3DDevice9_SetVertexShader(data->device, NULL);
     IDirect3DDevice9_SetFVF(data->device,
                             D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1);
Comment 6 Sam Lantinga 2013-02-11 21:41:39 UTC
Fixed, thank you Spinduluz
http://hg.libsdl.org/SDL/rev/c16fc4e46ae5