| Summary: | Directx3d Crash on resize | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Jeff Shanab <jshanab42> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | CC: | lookatyouhacker, spindelmannen29, vctos |
| Version: | 2.0.0 | ||
| Hardware: | x86 | ||
| OS: | Windows 7 | ||
| Attachments: |
The cpp file
Data file needed for this test |
||
Created attachment 857 [details]
Data file needed for this test
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. Was able to reproduce bug exactly as described. SDL_DestroyRenderer() and SDL_CreateRenderer() calls on SDL_WINDOWEVENT_RESIZED SDL_WINDOWEVENT_SIZE_CHANGED events can solve this problem partially. 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);
Fixed, thank you Spinduluz http://hg.libsdl.org/SDL/rev/c16fc4e46ae5 |
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