DXGL r549 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r548‎ | r549 | r550 >
Date:22:59, 11 October 2014
Author:admin
Status:new
Tags:
Comment:
Fix DDraw initialization deadlock.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -274,6 +274,36 @@
275275 TRACE_EXIT(23,ret);
276276 return ret;
277277 }
 278+
 279+void FixCapsTexture(D3DDEVICEDESC7 *d3ddesc, D3DDEVICEDESC *d3ddesc3, glRenderer *renderer)
 280+{
 281+ if (!d3ddesc->dwMaxTextureWidth)
 282+ {
 283+ if (!renderer)
 284+ {
 285+ HWND hGLWnd = CreateWindow(_T("Test"), NULL, WS_POPUP, 0, 0, 16, 16, NULL, NULL, NULL, NULL);
 286+ glRenderer *tmprenderer = (glRenderer*)malloc(sizeof(glRenderer));
 287+ DEVMODE mode;
 288+ mode.dmSize = sizeof(DEVMODE);
 289+ EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode);
 290+ glRenderer_Init(tmprenderer, 16, 16, mode.dmBitsPerPel, false, mode.dmDisplayFrequency, hGLWnd, NULL, FALSE);
 291+ d3ddesc->dwMaxTextureWidth = d3ddesc->dwMaxTextureHeight =
 292+ d3ddesc->dwMaxTextureRepeat = d3ddesc->dwMaxTextureAspectRatio = tmprenderer->gl_caps.TextureMax;
 293+ d3ddesc3->dwMaxTextureWidth = d3ddesc3->dwMaxTextureHeight =
 294+ d3ddesc3->dwMaxTextureRepeat = d3ddesc3->dwMaxTextureAspectRatio = tmprenderer->gl_caps.TextureMax;
 295+ glRenderer_Delete(tmprenderer);
 296+ free(tmprenderer);
 297+ }
 298+ else
 299+ {
 300+ d3ddesc->dwMaxTextureWidth = d3ddesc->dwMaxTextureHeight =
 301+ d3ddesc->dwMaxTextureRepeat = d3ddesc->dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
 302+ d3ddesc3->dwMaxTextureWidth = d3ddesc3->dwMaxTextureHeight =
 303+ d3ddesc3->dwMaxTextureRepeat = d3ddesc3->dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
 304+ }
 305+ }
 306+}
 307+
278308 HRESULT WINAPI glDirect3D7::EnumDevices(LPD3DENUMDEVICESCALLBACK7 lpEnumDevicesCallback, LPVOID lpUserArg)
279309 {
280310 TRACE_ENTER(3,14,this,14,lpEnumDevicesCallback,14,lpUserArg);
@@ -280,6 +310,7 @@
281311 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
282312 if(!lpEnumDevicesCallback) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
283313 HRESULT result;
 314+ FixCapsTexture(&glDD7->d3ddesc, &glDD7->d3ddesc3, glDD7->renderer);
284315 D3DDEVICEDESC7 desc = glDD7->d3ddesc;
285316 for(int i = 0; i < 3; i++)
286317 {
@@ -310,6 +341,7 @@
311342 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
312343 if(!lpEnumDevicesCallback) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
313344 HRESULT result;
 345+ FixCapsTexture(&glDD7->d3ddesc, &glDD7->d3ddesc3, glDD7->renderer);
314346 D3DDEVICEDESC desc = glDD7->d3ddesc3;
315347 GUID guid = IID_IDirect3DRGBDevice;
316348 result = lpEnumDevicesCallback(&guid,glDD7->stored_devices[0].name,glDD7->stored_devices[0].devname,&desc,&desc,lpUserArg);
@@ -369,6 +401,7 @@
370402 if(!lpD3DFDR) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
371403 if(lpD3DFDR->dwSize < sizeof(D3DFINDDEVICERESULT)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
372404 if(lpD3DFDS->dwSize < sizeof(D3DFINDDEVICESEARCH)) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 405+ FixCapsTexture(&glDD7->d3ddesc, &glDD7->d3ddesc3, glDD7->renderer);
373406 bool found = true;
374407 GUID guid = IID_IDirect3DHALDevice;
375408 if((lpD3DFDS->dwFlags & D3DFDS_LINES) || (lpD3DFDS->dwFlags & D3DFDS_TRIANGLES))
Index: ddraw/glDirectDraw.cpp
@@ -1403,29 +1403,6 @@
14041404 }
14051405 d3ddesc = d3ddesc_default;
14061406 d3ddesc3 = d3ddesc3_default;
1407 - if (!renderer)
1408 - {
1409 - HWND hGLWnd = CreateWindow(_T("Test"), NULL, WS_POPUP, 0, 0, 16, 16, NULL, NULL, NULL, NULL);
1410 - glRenderer *tmprenderer = (glRenderer*)malloc(sizeof(glRenderer));
1411 - DEVMODE mode;
1412 - mode.dmSize = sizeof(DEVMODE);
1413 - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode);
1414 - glRenderer_Init(tmprenderer, 16, 16, mode.dmBitsPerPel, false, mode.dmDisplayFrequency, hGLWnd, NULL, FALSE);
1415 - d3ddesc.dwMaxTextureWidth = d3ddesc.dwMaxTextureHeight =
1416 - d3ddesc.dwMaxTextureRepeat = d3ddesc.dwMaxTextureAspectRatio = tmprenderer->gl_caps.TextureMax;
1417 - d3ddesc3.dwMaxTextureWidth = d3ddesc3.dwMaxTextureHeight =
1418 - d3ddesc3.dwMaxTextureRepeat = d3ddesc3.dwMaxTextureAspectRatio = tmprenderer->gl_caps.TextureMax;
1419 - glRenderer_Delete(tmprenderer);
1420 - free(tmprenderer);
1421 - }
1422 - else
1423 - {
1424 - d3ddesc.dwMaxTextureWidth = d3ddesc.dwMaxTextureHeight =
1425 - d3ddesc.dwMaxTextureRepeat = d3ddesc.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
1426 - d3ddesc3.dwMaxTextureWidth = d3ddesc3.dwMaxTextureHeight =
1427 - d3ddesc3.dwMaxTextureRepeat = d3ddesc3.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
1428 - }
1429 -
14301407 memcpy(stored_devices, d3ddevices, 3 * sizeof(D3DDevice));
14311408 winstyle = winstyleex = 0;
14321409 initialized = true;