narzoul / DDrawCompat

DirectDraw and Direct3D 1-7 compatibility, performance and visual enhancements for Windows Vista, 7, 8, 10 and 11
BSD Zero Clause License
969 stars 70 forks source link

Jane's IAF crashes after some time #148

Closed TMueller83 closed 1 year ago

TMueller83 commented 2 years ago

Hi, first of all thank you for your great work! I'm trying to use DDrawCompat 0.4 to run Jane's Israeli Air Force on Windows 10 (64Bit) with an ATI Radeon RX 580 (8GB). The game runs just fine for a couple of minutes and then crashes (the image gets completely stuck but the game itself seems to continue since one can hear the plane crashing to the floor after some time). I tried to change almost all the options in the DDrawCompat-IAFJets.ini file, but none of them seem to fix the crash. Also there is a minor problem with the mouse cursor in the game: Usually the mouse cursor should turn into another symbol than an arrow once the game starts in 3D, however DDrawCompat 0.4 seems to prevent this, while older versions of DDrawCompat did not have this problem and the mouse cursor behaved as intended.

EDIT: I think both problems are related. I have noticed that the mouse cursor hides after some time and if one then moves the mouse (which should make the cursor visible again) the image gets stuck immediately. Also the issue before this one reports some problems with the mouse in version 0.4.

Concerning the crash: Here is an example log file.

15:42:54.085 Process path: C:\Janes\IAF\IAFJets.exe
15:42:54.085 Loading DDrawCompat statically from C:\Janes\IAF\DDRAW.dll
15:42:54.085 Environment variable __COMPAT_LAYER = "DWM8And16BitMitigation RunAsAdmin PerProcessSystemDPIForceOn HighDpiAware Installer"
15:42:54.085 Loading global config file: C:\ProgramData\DDrawCompat\DDrawCompat.ini
15:42:54.085   File not found, skipping
15:42:54.085 Loading user config file: C:\Users\Tobias\AppData\Local\DDrawCompat\DDrawCompat.ini
15:42:54.085   File not found, skipping
15:42:54.085 Loading directory config file: C:\Janes\IAF\DDrawCompat.ini
15:42:54.085   File not found, skipping
15:42:54.085 Loading process config file: C:\Janes\IAF\DDrawCompat-IAFJets.ini
15:42:54.085 Loading overlay config file: C:\Janes\IAF\DDrawCompatOverlay-IAFJets.ini
15:42:54.085   File not found, skipping
15:42:54.085 Final configuration:
15:42:54.085   [default] AlignSysMemSurfaces   = on
15:42:54.085   [default] AltTabFix             = off
15:42:54.085   [process] AlternatePixelCenter  = on
15:42:54.085   [process] Antialiasing          = msaa2x(7)
15:42:54.085   [default] BltFilter             = point
15:42:54.085   [default] ConfigHotKey          = shift+f11
15:42:54.085   [process] CpuAffinity           = all
15:42:54.085   [default] DesktopColorDepth     = initial
15:42:54.085   [default] DisplayFilter         = bilinear(0)
15:42:54.085   [default] DisplayRefreshRate    = app
15:42:54.085   [default] DisplayResolution     = desktop
15:42:54.085   [default] DpiAwareness          = permonitor
15:42:54.085   [default] FontAntialiasing      = app
15:42:54.085   [process] ForceD3D9On12         = on
15:42:54.085   [default] FpsLimiter            = off
15:42:54.085   [default] FullscreenMode        = borderless
15:42:54.085   [default] LogLevel              = info
15:42:54.085   [default] PalettizedTextures    = on
15:42:54.085   [default] RemoveBorders         = off
15:42:54.085   [default] RenderColorDepth      = app
15:42:54.085   [process] ResolutionScale       = app(4)
15:42:54.085   [process] ResolutionScaleFilter = bilinear
15:42:54.085   [default] SoftwareDevice        = rgb
15:42:54.085   [default] SpriteDetection       = off
15:42:54.085   [default] SpriteFilter          = app
15:42:54.085   [default] SpriteTexCoord        = app
15:42:54.085   [default] SupportedResolutions  = native, 640x480, 800x600, 1024x768
15:42:54.085   [default] TextureFilter         = app
15:42:54.085   [default] ThreadPriorityBoost   = off
15:42:54.085   [process] VSync                 = on(1)
15:42:54.085   [default] WinVersionLie         = off
15:42:54.104 Failed to change process DPI awareness to "permonitor" via SetProcessDpiAwarenessContext
15:42:54.104 DDrawCompat loaded successfully
15:42:54.196 Installing display mode hooks
15:42:54.201 Installing registry hooks
15:42:54.201 Installing Direct3D driver hooks
15:42:54.206 Hooking user mode display driver: C:\WINDOWS\SYSTEM32\D3D9on12.dll+0x108b0
15:42:54.310 Dynamic vertex buffers are available
15:42:54.310 Dynamic index buffers are available
15:42:54.311 Supported z-buffer bit depths: 16
15:42:54.311 Supported MSAA modes: msaa(2), msaa2x(0), msaa4x(0), msaa8x(0)
15:42:54.311 Supported resource formats:
15:42:54.311   {D3DDDIFMT_A8R8G8B8,0xdae09f,0x8b,0x8b,0}
15:42:54.311   {D3DDDIFMT_X8R8G8B8,0xdaec9f,0x8b,0x8b,0}
15:42:54.311   {D3DDDIFMT_R5G6B5,0xca6c9f,0x8b,0x8b,0}
15:42:54.311   {D3DDDIFMT_X1R5G5B5,0xca609f,0x8b,0x8b,0}
15:42:54.311   {D3DDDIFMT_A1R5G5B5,0xca609f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A4R4G4B4,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A8,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_X4R4G4B4,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A2B10G10R10,0xca609f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A8B8G8R8,0xdae09f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_G16R16,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A2R10G10B10,0x8a609f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A16B16G16R16,0xca609f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_L8,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A8L8,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_V8U8,0xc30007,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_Q8W8V8U8,0xc30007,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_V16U16,0xc30007,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_D24S8,0x8200c5,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_D24X8,0x8200c5,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_D16,0x8200c7,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_L16,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_D24FS8,0x8200c5,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_Q16W16V16U16,0xc30007,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_R16F,0xc2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_G16R16F,0xe2409f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_A16B16G16R16F,0xca609f,0x8b,0x8b,0}
15:42:54.312   {D3DDDIFMT_R32F,0xe2409f,0x0,0x0,0}
15:42:54.312   {D3DDDIFMT_G32R32F,0xe2409f,0x0,0x0,0}
15:42:54.312   {D3DDDIFMT_A32B32G32R32F,0xe2409f,0x0,0x0,0}
15:42:54.312   {FOURCC(P010),0x7000,0x0,0x0,32}
15:42:54.312   {FOURCC(ATI1),0x829007,0x0,0x0,8}
15:42:54.312   {FOURCC(DXT1),0x828007,0x0,0x0,0}
15:42:54.312   {FOURCC(NV12),0x7000,0x0,0x0,16}
15:42:54.312   {FOURCC(YV12),0x7000,0x0,0x0,16}
15:42:54.312   {FOURCC(ATI2),0x829007,0x0,0x0,8}
15:42:54.312   {FOURCC(DXT2),0x828007,0x0,0x0,0}
15:42:54.312   {FOURCC(YUY2),0x7000,0x0,0x0,16}
15:42:54.312   {FOURCC(DXT3),0x828007,0x0,0x0,0}
15:42:54.312   {FOURCC(DF24),0x8200c5,0x8b,0x8b,0}
15:42:54.312   {FOURCC(DXT4),0x828007,0x0,0x0,0}
15:42:54.312   {FOURCC(DXT5),0x828007,0x0,0x0,0}
15:42:54.312   {FOURCC(DF16),0x8200c7,0x8b,0x8b,0}
15:42:54.312   {FOURCC(ATOC),0x4000,0x0,0x0,0}
15:42:54.312   {FOURCC(NULL),0x83401f,0x8b,0x8b,0}
15:42:54.312   {FOURCC(RESZ),0x0,0x0,0x0,0}
15:42:54.312   {FOURCC(INTZ),0x8200c5,0x8b,0x8b,0}
15:42:54.314 Installing DirectDraw hooks
15:42:54.316 Installing Direct3D hooks
15:42:54.319 Installing GDI hooks
15:42:54.328 Finished installing hooks
15:42:56.447 Using Direct3D device type: IID_IDirect3DHALDevice
15:42:56.519 ERROR: Resource::copySubResourceRegion failed: 0x80070057
15:43:05.482 ERROR: Failed to create repository surface: 0x80004001 {0x1007,256,256,0,0,0,0,0,null,{0x60,0x0,8,0x0,0x0,0x0,0x0},{0x4040,0x0,0x0,0x0},0}
narzoul commented 2 years ago

I haven't had time to check this game yet, but if the issue is with the mouse cursor, I assume the game uses a hardware cursor for that. DDrawCompat emulates it with shaders when display scaling is used. Can you try setting DisplayResolution=app for testing? This should disable the emulation. I also don't recommend using ForceD3D9On12, it possibly makes things worse, and I really haven't tested it much.

TMueller83 commented 2 years ago

Hi @narzoul thank you very much for your fast response! You are right, setting DisplayResolution=app fixes the problem, i.e., with this setting the game runs stable. Only the shape of the mouse cursor does not change, as it would be intended by the game, but it stays an arrow. However, this is not really a problem. By the way, I tested the game with and without ForceD3D9On12 and I can say that at least this game (Jane's IAF) runs quite fine with it. All issues that I observed was also present if ForceD3D9On12=off was set, so I think the problems in Jane's IAF are not related to this setting, but maybe I have to test more. So, thank you again very much for your help on how to fix this problem!

narzoul commented 2 years ago

Thanks for the feedback! I'll see if I can fix those cursor issues properly when I have some time.

TMueller83 commented 2 years ago

That would be great if you could fix these issues at some point! Thank you very much in advance!

narzoul commented 1 year ago

Reopening for the cursor investigations. Apparently there is a GDI resource leak causing the issues, I just have to find it now.

narzoul commented 1 year ago

Well, I found it. There was also a slight issue with the cursor getting unnecessarily reloaded each time it was drawn, which made the resource leak worse. The game still leaks some GDI handles when alt-tabbing, but that happens without DDrawCompat too, so I assume it's a game bug. Anyway, here is a quick fix for the leak in DDrawCompat until the next release: ddraw.zip (diff.txt compared to v0.4.0)

Also there is a minor problem with the mouse cursor in the game: Usually the mouse cursor should turn into another symbol than an arrow once the game starts in 3D, however DDrawCompat 0.4 seems to prevent this, while older versions of DDrawCompat did not have this problem and the mouse cursor behaved as intended.

I guess this is the only remaining issue then. It does look like the cursor changes very briefly when mousing over some of the controls, but it immediately changes back to an arrow. I have some ideas where to look for this bug...

narzoul commented 1 year ago

Ok, I found some problems with the WM_SETCURSOR handling too, which should resolve the cursor issues in the 3D parts now. Combining it with the previous fix: ddraw.zip (diff.txt compared to v0.4.0)

TMueller83 commented 1 year ago

Hi @narzoul thank you very much for these great fixes! I just tested the newest fix and it works great! No crashes and the mouse cursor behaves as it should. Thank you very much once again!

EDIT: I have also tried the ForceD3D9On12 = on option just for testing and it works very well with the newest fix, however the mouse cursor is invisible altogether inside the cockpit.

narzoul commented 1 year ago

All mentioned fixes are now part of DDrawCompat v0.5.0.