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
700 stars 159 forks source link

Using box86 + gl4es causes Shovelknight to seg fault when attempting to run #118

Open ITotalJustice opened 5 years ago

ITotalJustice commented 5 years ago

Using the command LIBGL_ES=2 LIBGL_GL=21 LIBGL_DIBGL_FBOFORCETEX=1 LD_LIBRARY_PATH=~/monolibs BOX86_LD_LIBRARY_PATH=lib:./lib:fmod/lib/:/lib:x86:lib32:/usr/i686-linux-gnu/lib:/usr/lib/arm-linux-gnueabihf box86 ShovelKnight results in a seg fault and the game failing to boot. The game can boot fine when not using gl4es.

the bt full is:

Program received signal SIGSEGV, Segmentation fault.
0xb6fb9bec in memcpy () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
(gdb) bt full
#0  0xb6fb9bec in memcpy () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
No symbol table info available.
#1  0x3ff00000 in ?? ()
No symbol table info available.
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Let me know if you need more information.

ptitSeb commented 5 years ago

Mmmm, that backtrace is useless unfortunatly. It will be difficult to track down the issue :(

Maybe run it with valgrind, if you can? It may gives a bit more detail on what is going wrong.

ptitSeb commented 5 years ago

In fact, I think it would be easier to use BOX86_LOG=DEBUG to have the function beeing called. That would probably be enough to understand in what function it crash.

ITotalJustice commented 5 years ago
8776|0x883f75b: Calling strlen(0x88a102a("ycshaders/anim2d_glsl_vsh39")) => return 0x0000001B
8776|0x883f782: Calling strlen(0x88a1046("ycshaders/anim2d_glsl_psh1")) => return 0x0000001A
8776|0x883fa35: Calling glCreateProgram (B63C933E, 00000003, B6B639AC...) => return 0x00000001
8776|0x883fa4b: Calling glCreateShader (00008B31, 00000003, B6B639AC...) => return 0x00000002
8776|0x883fa74: Calling glShaderSource (00000002, 00000001, 089E6BCC...) =>Segmentation fault
ptitSeb commented 5 years ago

Ah, glShaderSource? Damn, that's a simple function. Strange. In the gl4es sources, can you un comment line 11 of src/gl/shader.c to have debug info on shader operations, and launch again (no Box86 log needed this time) ?

ITotalJustice commented 5 years ago

So i uncommented the define debug, re-compiled however the output is the same. I checked the usage page, in case i was supposed to pass args when running but i couldn't see anything there either.

ptitSeb commented 5 years ago

That's strange, it should printf each glShader function used, with parameters. Maybe the game is redirecting output somewhere? For box86 trace, did you used BOX86_TRACE_FILE=XXX ?

ITotalJustice commented 5 years ago

I didn't use BOX86_TRACE_FILE= though i did just try it and its the same output (only now in a file). For getting the trace i was just using > log.txt to save it to a file.

ptitSeb commented 5 years ago

Ok. Still strange, it should printf the glCreateShader(...) and glShaderSource(...) details.

ITotalJustice commented 5 years ago

Yeah. It does work for many other games that i have been testing, it prints out all the information, just not with shovelknight hmm.

ptitSeb commented 5 years ago

I guess it redirect stdout to some log file then. Maybe I should rewrite the printf to fprintf(stderr, ...) then?

ITotalJustice commented 5 years ago

Sorry i've been away past few days. Here's the log:

LIBGL: Error while compiling shader 462. Original source is:
#version 120
vec4 ps_r0;
vec4 ps_t0 = gl_TexCoord[0];
uniform sampler2D ps_s0;
#define ps_v0 gl_Color
#define ps_oC0 gl_FragColor

void main()
{
    ps_t0 = texture2D(ps_s0, ps_t0.xy);
    ps_r0 = ps_v0 * ps_t0;
    ps_oC0 = ps_r0;
}

=======
ShaderConv Source is:
#version 100
precision highp float;
precision highp int;
varying lowp vec4 _gl4es_FrontColor;
varying mediump vec4 _gl4es_TexCoord[1];
vec4 ps_r0;
vec4 ps_t0 = _gl4es_TexCoord[0];
uniform sampler2D ps_s0;
#define ps_v0 _gl4es_FrontColor
#define ps_oC0 gl_FragColor

void main()
{
    ps_t0 = texture2D(ps_s0, ps_t0.xy);
    ps_r0 = ps_v0 * ps_t0;
    ps_oC0 = ps_r0;
}

=======
Compiler message is
0:7(14): error: initializer of global variable `ps_t0' must be a constant expression

LIBGL: End of Error log
Failed to compile a pixel shader!
  '0:7(14): error: initializer of global variable `ps_t0' must be a constant expression
'
Wrote shader in question to badshader.bin
ERROR: Assert in /home/icculus/projects/psychonauts/Source/CommonLibs/DFGraphics/OpenGLGraphics.cpp, line 2127
pD3DShader != NULL

Encountered Error:
  Psychonauts has encountered an error

/home/icculus/projects/psychonauts/Source/CommonLibs/DFGraphics/OpenGLGraphics.cpp, line 2127
pD3DShader != NULL

 Please contact technical support at http://www.doublefine.com.

Unsupported Int 3 call
LIBGL: Shuting down

Did you want me to upload the full log output?

ptitSeb commented 5 years ago

No, it's ok, I can see the hack is not triggering here for some reason. I'll find why.