icculus / Serious-Engine

An open source version of a game engine developed by Croteam for the classic Serious Sam games.
GNU General Public License v2.0
164 stars 21 forks source link

Rendering Bugs (when using -DUSE_I386_ASM=FALSE) #48

Open DanielGibson opened 8 years ago

DanielGibson commented 8 years ago

Sometimes the viewport is screwed up, like the camera is rotated by 90°, but only for part of the screen. It usually goes back to normal soon, and screws up again later. I don't really know how to reproduce it, in TSE it happens sometimes early in the first level (on the path between the pond and the first building), sometimes a bit later (shortly after receiving the flamethrower) - but more often than not I can play for a long time and it doesn't happen at all. If it has happened once it tends to happen again and again.

So far I have observed this with both 32 and 64bit builds on both Linux and OSX, but only when using USE_PORTABLE_C instead of x86 ASM - however this may even be coincidence as I didn't test with ASM as much.

I have seen this bug since I started toying with the Serious Engine on Linux (i.e. before my 64bit fixes), but only now I've been able to create screenshots:

sesam-gfxbug1 sesam-gfxbug2

yamgent commented 8 years ago

Hmm, I have heard of this bug before, but I have never been able to reproduce this on my side.(I jinxed it, now I am getting this pretty frequently, and I don't know why.)

Someone reported the same thing for the vanilla source version on the forums (url), which indicates that the bug might be non-port related (it is hard to say though, since there's no reliable way of reproducing this).

ptitSeb commented 8 years ago

I have also this kind of things on the Pandora port. I have linked this behavor to slow frame rate, as it seems to happen (on the Pandora) only when framerate gets pretty low (sub 10fps).

yamgent commented 8 years ago

Interesting... does it happens every time the frame rate drops below 10fps? Does it recover when the frame rate return back to normal?

DanielGibson commented 8 years ago

I think that it happened to me (on PC) without frame rate drops.

Also: Are you sure the frame rate drops and then the errors happen - or maybe the framerate drops because of the errors?

ptitSeb commented 8 years ago

It's not systematic, but happens mosty always around the same pot (like the one in the screenshot, which is the beggining of the game). On the Pandora, once wrong, it doesn't recover.

icculus commented 8 years ago

There was a similar bug in the Linux port before source release, where the framebuffer would invert, and it came down to an epsilon issue. Bug was also in the Windows version, but Visual C 6 just happened to generate slightly different code and avoid it...I guess that's why this other bug happens in the vanilla sources when built with a newer Visual Studio? I always assumed it was my bug.

That why there's the EPS() function in Engine/Math/Quaternion.h ... we might need that elsewhere, too?

The framebuffer flipping sideways like that definitely happened in the original Linux port of the The Second Encounter (and I don't think I ever saw it in The First Encounter, but I could be wrong), and I never figured out why.

ptitSeb commented 8 years ago

On the Pandora port, I have changed a bit the Eps() function to be even less sensitve:

#ifdef PLATFORM_PANDORA
    if ((orig <= 1e-4f) && (orig >= -1e-4f))
#else
      if ((orig <= 10e-6f) && (orig >= -10e-6f))
#endif

I don't have reproduce the issue since, but the performances had improve too, so it may just be luck.

Manuel-K commented 8 years ago

I've encountered the same bug several times in the room after you get the flamethrower with the 64 bits build.

(I don't know about the 32 bits one with asm, because that one segfaults on startup.)