narzoul / DDrawCompat

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

[Helbreath] Fps Drops #64

Closed X4N1 closed 4 years ago

X4N1 commented 4 years ago

Hello, at the beginning I would like to thanks and congratulate you on the great work with this project. I have a Problem with droping fps in old game maked on directx7. When player open any box from game ui, fps still dropping,no matter what system u using.(but in windows 7 fps average are higher)

example: https://images92.fotosik.pl/348/48fb389b9283b66amed.jpg i opened 2 dialog boxes, fps drop to 175 where average is 1k+ (windows 7) in windows 8/10 even droping to ~10 fps< and it's tragedy for gaming. Resolution of game = 640x800

Kind Regard's X4N1

narzoul commented 4 years ago

175 fps is perfectly fine. It probably drops because of lots of text drawing in those dialogs. I don't know how you even get such high FPS, since I can't find an option to turn v-sync off. Forcing it off in AMD drivers doesn't work. Are you using Nvidia?

I've tested both my AMD and Intel GPU on Windows 10 and I get steady 60 fps even with all dialogs open, in the starting area of the game. Do you have to be in some other area to get such low performance?

Are you using the experimental version of DDrawCompat, or some older release?

X4N1 commented 4 years ago

Hi,thanks for answer ;) We off v-sync only in source's.

USING THE DDrawCompat v0.2.1 VERSION,the graphic looks like that : 96111945-556701191933084-2726851410263015424-n FPS: ~41

USING THE DDrawCompat experimentaltest release VERSION the graphic looks like that : 96101343-330211127941060-9030417478575980544-n Fps: ~21 Tested on Windows 10 We think that the text causes declines, but how to fix it? : / (we can't reduce the text too much) Kind Reegards! ;)

narzoul commented 4 years ago

Which version of Helbreath are you playing? I've tried the one from helbreath.net, but it looks like there is at least one other version (helbreathnemesis.com), and who knows how many more... maybe there is a performance difference between them.

I still don't know what kind of graphics card you're using. If you can attach the ddraw.log file created with the Release version of DDrawCompat, I can at least identify the driver vendor from that (AMD/Nvidia/Intel).

Technically, it would be much better if you could attach the logs using the ReleaseWithDebugLogs version in ddraw-debug.zip, but that is risky as it could expose your username/password (basically the logs might contain your key presses and whatever text is displayed in the game). So if you want to do this, please use a throwaway account with some dummy password. Or at least change your password to something that you don't mind making public, and then change it back after you reproduced the issue and before you upload the logs.

X4N1 commented 4 years ago

We have our version of helbreath :P This problem we testing with 3 people on 3 different graphics cards (AMD,Nvidia,Intel)

I am convinced that the problem is related to the text, more specifically to the function TextOut. in attachement one log file: https://ufile.io/u0lsagi9

narzoul commented 4 years ago

Well, without seeing debug logs or the source code, I can only guess at what the root cause of your problems might be.

Assuming you use TextOut with IDirectDrawSurface::GetDC, I noticed that e.g. Helbreath Olympia sets the DDSCAPS_OWNDC capability when it creates its surfaces. This can improve the performance of GetDC significantly, since it won't create a new DC each time, just returns a single cached DC. I actually tested Olympia by force-removing this flag via DDrawCompat, and it gives <20 fps as a result for me too (with the flag it's 60+).

If you're creating surfaces in video memory, you should consider creating them in system memory instead, especially if you're locking them frequently (e.g. by GetDC or Lock). Locking video memory surfaces frequently can be another performance bottleneck. DDrawCompat already tries to optimize this case somewhat, but it's better to fix this at the root if you can. (Edit: upon further testing, it seems that DDSCAPS_OWNDC doesn't work without DDSCAPS_SYSTEMMEMORY anyway. I also cannot reproduce the performance difference without DDSCAPS_OWNDC anymore, so I might have done something wrong during last test...).

If neither of the above helps and you're sure TextOut is your main bottleneck, then you should optimize that. I assume it's getting called at each frame over and over, even when the text doesn't change. So cache the results somewhere. E.g. cache the rendered text of those popups (or the entire window even) in off-screen surfaces, and update it only when it changes. This isn't something I can do from DDrawCompat.

X4N1 commented 4 years ago

Uderstand, in attachement 2 code files responsible for directdraws. Would you be able to help to optimize it? If I shared the source, would you fix it or guide it?

Thank you soo much and Kind Regards ;) dxcddraw.zip

narzoul commented 4 years ago

Between my regular job and DDrawCompat, I have more than enough work. I can't take on another project like this, sorry.

Have you tried the DDSCAPS_OWNDC suggestion yet? It looks like DDSCAPS_SYSTEMMEMORY is already used in pCreateOffScreenSurface, so you just have to add this flag there too and see if it makes any difference.

If not, and you still think TextOut is the problem, have you tried disabling it already to see if it makes things significantly faster?

You say the game is several times faster on Windows 7. Are you talking about the exact same client build, or are the clients also different? What is the FPS with and without the latest experimental DDrawCompat on Windows 7 and Windows 10, with the same build?