ptitSeb / gl4es

GL4ES is a OpenGL 2.1/1.5 to GL ES 2.0/1.1 translation library, with support for Pandora, ODroid, OrangePI, CHIP, Raspberry PI, Android, Emscripten and AmigaOS4.
http://ptitseb.github.io/gl4es/
MIT License
694 stars 159 forks source link

ScummVM crash in OpenGL mode on x86/linux and AmigaOS4 #373

Closed kas1e closed 2 years ago

kas1e commented 2 years ago

After fixing GL_UNSIGNED_INT issue we go futher but then still crashes when tries to run Grim Fardango game over GL4ES, that how to reproduce:

-- build scummvm -- run it -- choose in "Global Options" : Graphics/GraphicsMode: OpenGL (that at top of options in Graphics menu) -- choose in "Game 3D Renderer": OpenGL (that option on the bottom in Graphics menu, need to scroll down window a little). -- add "Grim Fandango" game, and be sure that in local settings for game it have the same OpenGL in graphics mode and "OpenGL" in Game 3D renderer. -- run game

and we crash:

WARNING: VideoTheoraPlayer::initialize - Theora support not compiled in, video will be skipped!
INFO: OpenGL Vendor: ptitSeb
INFO: OpenGL Renderer: GL4ES wrapper
INFO: OpenGL Version: 2.1 gl4es wrapper 1.1.5
INFO: OpenGL Red bits: 8
INFO: OpenGL Green bits: 8
INFO: OpenGL Blue bits: 8
INFO: OpenGL Alpha bits: 8
INFO: OpenGL Z buffer depth bits: 24
INFO: OpenGL Double Buffer: 1
INFO: OpenGL Stencil buffer bits: 8
INFO: GLSL version: 1.20 via gl4es
INFO: OpenGL Vendor: ptitSeb
INFO: OpenGL Renderer: GL4ES wrapper
INFO: OpenGL Version: 2.1 gl4es wrapper 1.1.5
INFO: OpenGL Red bits: 8
INFO: OpenGL Green bits: 8
INFO: OpenGL Blue bits: 8
INFO: OpenGL Alpha bits: 8
INFO: OpenGL Z buffer depth bits: 24
INFO: OpenGL Double Buffer: 1
INFO: OpenGL Stencil buffer bits: 8
INFO: GLSL version: 1.20 via gl4es
INFO: OpenGL Vendor: ptitSeb
INFO: OpenGL Renderer: GL4ES wrapper
INFO: OpenGL Version: 2.1 gl4es wrapper 1.1.5
INFO: OpenGL Red bits: 8
INFO: OpenGL Green bits: 8
INFO: OpenGL Blue bits: 8
INFO: OpenGL Alpha bits: 8
INFO: OpenGL Z buffer depth bits: 24
INFO: OpenGL Double Buffer: 1
INFO: OpenGL Stencil buffer bits: 8
INFO: GLSL version: 1.20 via gl4es
WARNING: Lua_V1::SetGamma, implement opcode, level: 0.000000!
WARNING: !!!! Trying to call MakeSectorActive without a scene!
WARNING: !!!! Trying to call MakeSectorActive without a scene!
WARNING: !!!! Trying to call MakeSectorActive without a scene!
WARNING: !!!! Trying to call MakeSectorActive without a scene!
WARNING: !!!! Trying to call MakeSectorActive without a scene!
Segmentation fault (core dumped)
root@kas1e-laptop:/home/kas1e/work/scumm/scummvm-amigaos4# 

Running the same without GL4ES not crash, and game starts.

Actually, we crash not right before game starts, but we can see the first 2d image, and then crash.

kas1e commented 2 years ago

Oh, and have the same issue on AmigaOS4, too, with same kind of crash.

I just run x86/linux version over GDB, and that what it give me:

Thread 1 "scummvm" received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:299
299 ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
(gdb) bt
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:299
#1  0x00007fffe81bd016 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#2  0x00007fffe81bda54 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#3  0x00007fffe861a206 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#4  0x00007fffe81cf09c in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#5  0x00007fffe81bc55b in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#6  0x00007fffe83fe758 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#7  0x00007fffe83fe7f5 in ?? () from /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
#8  0x00007fffeaf34685 in fpe_glDrawArrays (mode=6, first=0, count=4) at /home/kas1e/work/scumm/gl4es-master_2574/src/gl/fpe.c:791
#9  0x00007fffeaf6a5e7 in draw_renderlist (list=0x5555595d2740, list@entry=0x555558143210) at /home/kas1e/work/scumm/gl4es-master_2574/src/gl/listdraw.c:782
#10 0x00007fffeaf5bb8b in gl4es_flush () at /home/kas1e/work/scumm/gl4es-master_2574/src/gl/gl4es.c:1010
#11 0x00007fffeafae7b5 in gl4es_glBindTexture (target=3553, texture=<optimized out>) at /home/kas1e/work/scumm/gl4es-master_2574/src/gl/texture_params.c:194
#12 0x00005555558e6e4e in Grim::GfxOpenGL::drawMovieFrame(int, int) ()
#13 0x0000555555864d10 in Grim::GrimEngine::updateDisplayScene() ()
#14 0x0000555555868591 in Grim::GrimEngine::mainLoop() ()
#15 0x0000555555868b1f in Grim::GrimEngine::run() ()
#16 0x000055555584710f in runGame(Plugin const*, Plugin const*, OSystem&, Common::String const&) ()
#17 0x0000555555849675 in scummvm_main ()
#18 0x00005555557f04df in main ()
(gdb) 

And when i run the ScummVM on amigaos4 and set the same settings, and there are amigaos4's crashlog (just maybe this this crash will add some more info to the first one):

Stack trace:
    module LIBS:ogles2.library at 0x7D63453C (section 0 @ 0x8518)
    module LIBS:ogles2.library at 0x7D6361CC (section 0 @ 0xA1A8)
    scummvm_shaders_no_ifdefs:fpe_glDrawArrays()+0x8c (section 1 @ 0x100C7D8)
    scummvm_shaders_no_ifdefs:draw_renderlist()+0x850 (section 1 @ 0xF212C0)
    scummvm_shaders_no_ifdefs:gl4es_flush()+0x58 (section 1 @ 0xF1432C)
    scummvm_shaders_no_ifdefs:gl4es_glBindTexture()+0x34c (section 1 @ 0xF5850C)
    scummvm_shaders_no_ifdefs:_ZN4Grim9GfxOpenGL14drawMovieFrameEii()+0x2d0 (section 1 @ 0x21D188)
    scummvm_shaders_no_ifdefs:_ZN4Grim10GrimEngine18updateDisplaySceneEv()+0x224 (section 1 @ 0x17BD54)
    scummvm_shaders_no_ifdefs:_ZN4Grim10GrimEngine8mainLoopEv()+0x384 (section 1 @ 0x1823A0)
    scummvm_shaders_no_ifdefs:_ZN4Grim10GrimEngine3runEv()+0x520 (section 1 @ 0x182CB4)
    scummvm_shaders_no_ifdefs:_ZL7runGamePK6PluginS1_R7OSystemRKN6Common6StringE()+0x1004 (section 1 @ 0x93254)
    scummvm_shaders_no_ifdefs:scummvm_main()+0x1ec4 (section 1 @ 0x960BC)
    scummvm_shaders_no_ifdefs:main()+0x160 (section 1 @ 0x8F4A0)
    native kernel module newlib.library.kmod+0x00002614
    native kernel module newlib.library.kmod+0x00003340
    native kernel module newlib.library.kmod+0x00003864
    scummvm_shaders_no_ifdefs:_start()+0x1e0 (section 1 @ 0x1B3C)
    native kernel module dos.library.kmod+0x0002a490
    native kernel module kernel+0x0005ea84
    native kernel module kernel+0x0005eafc

PPC disassembly:
 7d634534: 7c8903a6   mtctr             r4
 7d634538: 38a50010   addi              r5,r5,16
*7d63453c: a1030000   lhz               r8,0(r3)
 7d634540: a1230002   lhz               r9,2(r3)
 7d634544: 7d485214   add               r10,r8,r10
kas1e commented 2 years ago

Some additional info in case it will help from one of ScummVM devs who helping us now with opengl stuff:

The bug occurs when we allow framebuffer support to be built and GL4ES announce support for it. But for an unknown reason, the framebuffer causes a bug when GL4ES flushes commands (especially when calling glDrawArrays) before binding the frame texture.

Not sure how correctly this are, but maybe will bring some help to find out root cause.

ptitSeb commented 2 years ago

Ok. But the crash with Framebuffer support enabled is not the same as the one you put gdb backtarce before?

kas1e commented 2 years ago

Not sure i understand what you mean - as that all about the same crash, just and on x86 and on amigaos4 when use GL4ES (but not when use Mesa or MiniGL) I.e. when we run Grim Fandango in opengl mode we crashes on both oses, because of framebuffer causes a bug when GL4ES flushes commands (especially when calling glDrawArrays). And so both stack traces imho the same and point to the same as i see it.

My post about "framebuffer" was just to help to found root cause of those crashes. At least when we disable framebuffer usage we not crash.

kas1e commented 2 years ago

Or you mean somethng else ?:)

kas1e commented 2 years ago

Btw is that crash reproducable on the Pyra too ? Probably it should as it happens on 2 different plaforms..

ptitSeb commented 2 years ago

I don't know yet. I have tobuild scummvm a few time to get all the correct option, and it rebuild everything each time, and it takes a bit of time to rebuild :( Hopefully tomorrow I'll be able to test a bit.

kas1e commented 2 years ago

i for myself build it just like this for necessary grim engine and only necessary parts need it:

./configure --disable-debug --enable-release --disable-all-engines --enable-engine=grim

and that all then just make -j4.

So that will automatically builds for 2 rendereres: OpenGL and OpenGL with shaders. Pure OpenGL mean few internal small shaders + ARB shaders in GRIM, and "OpenGL with shaders" mean GLSL shaders coming with the games.

So our problem now is exactly pure "OpenGL" . Once that one gone we will see then if we had ARB shaders issues on x86/linux / Pyra / etc.

ptitSeb commented 2 years ago

It shoudl be fixed now.

kas1e commented 2 years ago

And it is ! At least i test on x86/linux and it surely do not crash anymore.

So, i were able to test ARB shaders, and yeah, but in GL4ES, so will made a new report about.

Thanks a bunch for continued work on gl4es, will made a friendly donation for all your help soon, thanks !