narzoul / DDrawCompat

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

Black Screen when playing GTAIV.exe #263

Closed AmrElsherbiny closed 2 months ago

AmrElsherbiny commented 7 months ago

After installing DDrawCompat ddraw.dll and starting the game, it shows a black screen. Please help!

BEENNath58 commented 7 months ago

gta iv doesn't use ddraw. It uses d3d9.

DDrawCompat can't help with this game.

narzoul commented 7 months ago

As BEENNath58 commented, Direct3D 9 is not supported. For me, the game doesn't even load ddraw.dll. How did you get it injected? Is there a secret Direct3D 7 renderer in the game that I'm not aware of?

AmrElsherbiny commented 7 months ago

As BEENNath58 commented, Direct3D 9 is not supported. For me, the game doesn't even load ddraw.dll. How did you get it injected? Is there a secret Direct3D 7 renderer in the game that I'm not aware of?

It is automatically required for the executable file to run, otherwise, it would give a bad image error.

narzoul commented 7 months ago

No, I don't think so. My game runs fine without it, and never even loads ddraw.dll, like I said. You must have installed some 3rd party mods or patches if your game requires that file to be in the game directory. A clean install works just fine without it, I just tested it.

AmrElsherbiny commented 7 months ago

I'm not currently using any kinds or sorts of 3rd party mods or patches. If you're meaning the patch version of the game then it's 1.0.8.0. I'm only using DXVK and DxWrapper with the given DLL files included and bundled with the game like xLive and xLiveless for example.

narzoul commented 7 months ago

That's exactly what I meant by 3rd party mods and patches. My guess is DxWrapper is forcing ddraw.dll to be loaded, but I'm not that familiar with that project. You can find more info about it here: https://github.com/elishacloud/dxwrapper Maybe @elishacloud can comment here too if he wants to.

I'm pretty sure if you just do a clean install without DXVK and DxWrapper, ddraw.dll should not be needed.

Unless the older (non-digital) versions of the game still use ddraw, but I only have the Steam version and I don't think I can downgrade it to 1.0.8.0. Anyway, I doubt this is the case. No game should require you to copy ddraw.dll into its directory or else throw a "bad image" error.

elishacloud commented 7 months ago

There are two different DxWrapper projects. Not sure this is mine. But my DxWrapper does not require ddraw.dll. However, DXVK and the other DxWrapper project do require ddraw.dll. Maybe try removing dxwrapper and DXVK?

Edit: I guess DXVK does not support ddraw.dll. Can you upload the settings you are using for DxWrapper?

elishacloud commented 7 months ago

Maybe they are using my DxWrapper to convert it to DX9 so that they can use DXVK to convert it to Vulkan.

@AmrElsherbiny, what are you trying to accomplish by adding DDrawCompat? This game is not a ddraw.dll game so maybe DxWrapper can help with whatever you need instead of DDrawCompat?

BTW: I think the game is a DX8 game so I suspect it is using d3d8to9 to upgrade it to DX9 and then DXVK to upgrade it to Vulkan.

narzoul commented 7 months ago

https://www.reddit.com/r/GTAIV/comments/hqbsli/how_to_fix_choppiness_and_stutters_in_gta_iv/

@elishacloud I think he is referring to your project. I've come across similar posts a while ago, but I have no idea how DDrawCompat could help with any performance issues in this game, especially the old v0.2.1 version they were using, since it didn't even have any driver hooks that might accidentally get injected to DX9 too. This is why I was curious to check out what's going on, but I can't even get the game to use ddraw.dll, even though a string search for ddraw finds a binary match in GTAIV.exe.

I was thinking that adding DDrawCompat=1 to dxwrapper.ini might be forcing ddraw.dll to be loaded. But I don't think this would magically change the renderer used by the game. Every info I could find points to it using at least DX9 and possibly something newer. On my system, it loads d3d9.dll, d3dref9.dll and d3d11.dll, nothing older.

AmrElsherbiny commented 7 months ago

https://www.reddit.com/r/GTAIV/comments/hqbsli/how_to_fix_choppiness_and_stutters_in_gta_iv/ Yes, you searched for what I was going to mention here!

What I am thinking about is doing a remix of DLL files by taking the most updated ones from more than one contributor who specializes in their project such as DXVK (Vulkan), DxWrapper, and DDrawCompat to install them directly in the game folder.

My aim here is to make sure that the game is running smoothly and with high FPS as much as possible since this is a 2009 game and I'm running my PC on a newer system.

elishacloud commented 7 months ago

@narzoul, I have used DDrawCompat code to hook into other functions (besides ddraw) to fix other performance issues. For example, with Wargames some of the screens have a delay in loading in even after upgrading them to Direct3D9, but the D3dDdi::installHooks(); fixed the issue, even though the game was running on d3d9 (System32 ddraw.dll was not even loaded into the game).

I would need to see the setting that is being used before I can figure out why it would be loading ddraw.dll from DxWrapper. DxWrapper should only load ddraw.dll if it is configured to do so.

I also found that the following lines of code in DDrawCompat v0.3.1 would cause a black screen on my Windows 11 system:

Win32::MemoryManagement::installHooks();
Win32::MsgHooks::installHooks();

@AmrElsherbiny, can you upload the dxwrapper.ini file?

AmrElsherbiny commented 7 months ago

Here is the dxwrapper.ini file content:

;;
;; For details, see: https://github.com/elishacloud/dxwrapper/wiki/Configuration
;;
[General]
RealDllPath                = AUTO
WrapperMode                = AUTO
LoadCustomDllPath          = 
ExcludeProcess             = 
IncludeProcess             = 
RunProcess                 = 
WaitForProcess             = 0
DisableLogging             = 0

[Plugins]
LoadPlugins                = 0
LoadFromScriptsOnly        = 0

[Compatibility]
Dd7to9                     = 0
D3d8to9                    = 0
DDrawCompat                = 1
Dinputto8                  = 0
DisableGameUX              = 0
DxWnd                      = 0
EnableDdrawWrapper         = 1
EnableD3d9Wrapper          = 0
EnableDinput8Wrapper       = 1
EnableDsoundWrapper        = 1
HandleExceptions           = 0
SingleProcAffinity         = 0

[DDrawCompat]
DDrawCompat20              = 0
DDrawCompat21              = 1
DDrawCompat31              = 0
DDrawCompatDisableGDIHook  = 0
DDrawCompatNoProcAffinity  = 1

[ddraw]
ConvertToDirectDraw7       = 1
ConvertToDirect3D7         = 1
DdrawOverrideBitMode       = 1

[Dd7to9]
DdrawAutoFrameSkip         = 0
DdrawEmulateSurface        = 0
DdrawFixByteAlignment      = 0
DdrawRemoveScanlines       = 0
DdrawRemoveInterlacing     = 0
DdrawReadFromGDI           = 0
DdrawWriteToGDI            = 0
DdrawCreateDeviceEarly     = 0
DdrawDisableDirect3DCaps   = 0
DdrawLimitDisplayModeCount = 0
DdrawUseNativeResolution   = 0
DdrawOverrideWidth         = 0
DdrawOverrideHeight        = 0
DdrawIntegerScalingClamp   = 0
DdrawMaintainAspectRatio   = 0

[d3d9]
AnisotropicFiltering       = 0
AntiAliasing               = 0
EnableVSync                = 0
ForceVsyncMode             = 0
OverrideRefreshRate        = 0
LimitPerFrameFPS           = 0
EnableWindowMode           = 0
WindowModeBorder           = 0
SetInitialWindowPosition   = 0
InitialWindowPositionLeft  = 0
InitialWindowPositionTop   = 0
FullscreenWindowMode       = 0
ForceExclusiveFullscreen   = 0
ForceMixedVertexProcessing = 0
ForceSystemMemVertexCache  = 0
ForceDirect3D9On12         = 0
GraphicsHybridAdapter      = 0

[FullScreen]
FullScreen                 = 1
ForceWindowResize          = 0
WaitForWindowChanges       = 1

[dinput8]
FilterNonActiveInput       = 1

[dsound]
Num2DBuffers               = 0
Num3DBuffers               = 0
ForceCertification         = 0
ForceExclusiveMode         = 1
ForceSoftwareMixing        = 0
ForceHardwareMixing        = 0
ForceHQ3DSoftMixing        = 0
ForceNonStaticBuffers      = 0
ForceVoiceManagement       = 0
ForcePrimaryBufferFormat   = 0
PrimaryBufferBits          = 16
PrimaryBufferSamples       = 44100
PrimaryBufferChannels      = 2
AudioClipDetection         = 0

The only way to prevent the black screen from occurring is to enable the DDrawCompat21 check.

elishacloud commented 7 months ago

I would recommend disabling the following settings:

[Compatibility]
DDrawCompat                = 1
EnableDdrawWrapper         = 1

[DDrawCompat]
DDrawCompat21              = 1
DDrawCompatNoProcAffinity  = 1

[ddraw]
ConvertToDirectDraw7       = 1
ConvertToDirect3D7         = 1
DdrawOverrideBitMode       = 1

This game does not use ddraw, so these settings are not usefull. Also, unless there is a reason to use DDrawCompat, I would recommend removing it from the game.

elishacloud commented 7 months ago

BTW: I should mention that I have customized DDrawCompat for use in DxWrapper. You cannot just drop the latest ddraw.dll file from DDrawCompat into the game to replace what is done in DxWrapper. I would need to integrate a newer version of DDrawCompat into DxWrapper.

narzoul commented 7 months ago

I have used DDrawCompat code to hook into other functions (besides ddraw) to fix other performance issues. For example, with Wargames some of the screens have a delay in loading in even after upgrading them to Direct3D9, but the D3dDdi::installHooks(); fixed the issue, even though the game was running on d3d9 (System32 ddraw.dll was not even loaded into the game).

Yes, this is what I meant by accidental injection. But D3DDDI hooks were not used in v0.2.1, which is what the original guide recommends, if I understand correctly. See the blog post referenced at the end of that reddit post: https://ant-sh.blogspot.com/2020/07/gta-4-stutter-choppiness-fix.html

I fixed this somewhere between v0.3.2 and v0.4.0 so that the driver hooks are no longer installed for DX8/9: https://github.com/narzoul/DDrawCompat/commit/726f2377249360f0044d06da3ae248fe8fea88fc I guess it may have worked in a few simple cases, but it's not officially supported yet, and probably won't be in the near future. In the long term, maybe, eventually...

elishacloud commented 7 months ago

Yes, this is what I meant by accidental injection.

I did it on purpose. LOL. This is the only game I have tested (out of 140 games) that need this. I am still not quite sure what is done in D3DDDI that fixes the slow transition issue. The issue also only happens at one point in the game. I just have not had time to troubleshoot it yet.

I guess it may have worked in a few simple cases, but it's not officially supported yet, and probably won't be in the near future.

Keep in mind I am only using it for ddraw games that are converted to Direct3D9. I am not sure if that makes a difference, but it is not actually a DX8/9 game. I am just loading the d3d9.dll and converting the functions one-by-one from ddraw to d3d9. I am NOT using this for any native DX8/9 games.