PCem crashes or closes * without any warning * if Direct3D/DirectDraw HW acceleration is disabled

Discussion of development and patch submission.
Post Reply
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

PCem crashes or closes * without any warning * if Direct3D/DirectDraw HW acceleration is disabled

Post by ruben_balea »

If for any reason* you have HW acceleration disabled for D3D and/or DD PCem main window won't load. (At least on my computer :roll:)
Perhaps nobody else out there has HW acceleration disabled but may prevent crashing due to other reasons... Prevention is always better.
With DirectDraw output enabled PCem will exit and leave an entry in the log (CreateSurface back failed)
With Direct3D output enabled PCem will CRASH abruptly with no log at all. This is due to some D3D initialising functions not being handled in 'win-d3d.cc' so it's really easy to fix, done with copy and paste, no keyboard required:

Code: Select all

***win-d3d.cc***
@@ -72,7 +72,8 @@
         d3dpp.BackBufferWidth        = 0;
         d3dpp.BackBufferHeight       = 0;
 
-        d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
+        if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev)))
+                   fatal("CreateDevice failed\n");
         
         d3d_init_objects();
         
@@ -99,14 +100,16 @@
         int y;
         RECT r;
 
-        d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
+        if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
                                    0,
                                    D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
                                    D3DPOOL_MANAGED,
                                    &v_buffer,
-                                   NULL);
+                                   NULL)))
+                   fatal("CreateVertexBuffer failed\n");;
 
-        d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL);
+        if (FAILED(d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL)))
+                   fatal("CreateTexture failed\n");;
      
         r.top    = r.left  = 0;
         r.bottom = r.right = 2047;
:?: Will be better to display also a message on fatal errors to tell the user what happened? many end users won't know that a log file exists or even what a log file is... I'm not sure to be able to do that, I don't know too much about C/C++ :oops:

* Last Sunday I was playing Runaway 2: The Dream of the Turtle and it's one of those games with problems with new video cards, drivers, x64, Windows 8/10 and so on,
in that case there is a problem on some scenes with snowing effect which makes the game insanely slow, only happens on recent NVIDIA cards according to some forums,
seems that most people is using D3DWindower or dxwnd to play it windowed but I don't like to play a fullscreen game in a window...
I was using the dxcpl.exe applet from DirectX SDK to disable HW acceleration for D3D and/or DD as needed, but those are system wide settings and quite easy to forget to reactivate, as happened to me.
And the settings can be changed while PCem is running, this won't affect previously opened DX devices, but then if you change video output or want to change to other settings or machine type PCem will dead.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: PCem crashes or closes * without any warning * if Direct3D/DirectDraw HW acceleration is disabled

Post by SarahWalker »

Rev 758 should make DirectDraw fall back on system memory backbuffers, which should allow it to work with hardware acceleration disabled (though there will probably be a performance hit). Rev 759/760 adds the Direct3D error checking.
User avatar
ruben_balea
Posts: 191
Joined: Mon 08 May, 2017 11:24 pm
Location: Spain

Re: PCem crashes or closes * without any warning * if Direct3D/DirectDraw HW acceleration is disabled

Post by ruben_balea »

Yes, it works now with DirectDraw hardware acceleration disabled with "dxcpl.exe" from the latest DX SDK.
It's fine even in Windows XP running in VirtualBox so I should say TEST PASSED

(For those not already aware "dxcpl.exe" from DX SDK is a lot more customizable than default "%WINDIR%\System32\DXCpl.exe")
basic2004
Posts: 124
Joined: Sun 08 Jan, 2017 5:59 pm

Re: PCem crashes or closes * without any warning * if Direct3D/DirectDraw HW acceleration is disabled

Post by basic2004 »

Thanks for patching!

I ran "8088MPH" with D3D, PCem crashes after showing Intel inside logo.
But now this works well both, D3D and DDraw since applied this patch.
Post Reply