narzoul / DDrawCompat

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

Black Screen with Solaris 1.0.4, ddraw v0.5.1 #293

Closed rafael-57 closed 2 months ago

rafael-57 commented 2 months ago

Hi,

the latest version doesn't work properly for this game.

I've tested version 0.2.1 and it works, the game doesn't lag anymore and it displays correctly.

Any idea on what could cause this issue?

Thank you

image

ddraw_0.5.1_solaris_output.zip

narzoul commented 2 months ago

I don't fully understand the problem (not really an expert on floating point arithmetic myself), but I guess the game does something to mess up the FPU state (x87 stack overflow?), which causes the std::ceil function call in DDrawCompat from the display filter shader setup code to return -nan at some point. It's then cast to int, which becomes INT_MIN, then 1 is subtracted, so it rolls over to INT_MAX, and this is passed into the shader as a loop count. I assume this is what causes the subsequent TDR (Timeout Detection & Recovery), which resets the display driver.

Replacing std::ceil with ceilf seems to work around the problem. Please try this fix: ddraw.zip (diff.txt)

narzoul commented 2 months ago

Fixed in v0.5.2.

rafael-57 commented 2 months ago

Sorry for getting back late, I only saw the message now so I couldn't test the workaround.

Thank you for fixing it!!!!!