hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
10.83k stars 2.13k forks source link

Can't Compile on Amlogic s905 after last commits #10626

Closed shantigilbert closed 6 years ago

shantigilbert commented 6 years ago

What happens? Compile ends in error Using these options PPSSPP used to compile with no problem

                       -DUSING_FBDEV=1  \
                       -DUSING_GLES2=1  \
                       -DUSE_FFMPEG=1  \
                       -DARMV7=1  \
               -DSHARED_LIBZIP=1 \
                       -DARM_NEON=1"

But now I get this error

/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp: In member function 'int SDLGLGraphicsContext::Init(SDL_Window*&, int, int, int, std::string*)':
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp:87:11: error: 'EGL_Init' was not declared in this scope
  EGL_Init();
           ^
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp: In lambda function:
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp:121:18: error: 'g_eglDisplay' was not declared in this scope
   eglSwapBuffers(g_eglDisplay, g_eglSurface);
                  ^~~~~~~~~~~~
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp:121:32: error: 'g_eglSurface' was not declared in this scope
   eglSwapBuffers(g_eglDisplay, g_eglSurface);
                                ^~~~~~~~~~~~
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp:121:44: error: 'eglSwapBuffers' was not declared in this scope
   eglSwapBuffers(g_eglDisplay, g_eglSurface);
                                            ^
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp: In member function 'int SDLGLGraphicsContext::Init(SDL_Window*&, int, int, int, std::string*)':
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp:117:7: warning: unused variable 'success' [-Wunused-variable]
  bool success = draw_->CreatePresets();
       ^~~~~~~
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp: In member function 'virtual void SDLGLGraphicsContext::ShutdownFromRenderThread()':
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.2/PPSSPPSDL-78449ce/SDL/SDLGLGraphicsContext.cpp:138:12: error: 'EGL_Close' was not declared in this scope
  EGL_Close();
            ^
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-deprecated-register'
make[3]: *** [CMakeFiles/native.dir/build.make:111: CMakeFiles/native.dir/SDL/SDLGLGraphicsContext.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....

Last commit I was using was https://github.com/hrydgard/ppsspp/commit/5eba689 so a lot has changed since then, do I need to change my compiler options?

What should happen? Finish Compiling

What hardware and operating system are you running PPSSPP on? GPU might matter if it's a graphical issue. Amlogic S905 using Libreelec

unknownbrackets commented 6 years ago

What if you add here:

https://github.com/hrydgard/ppsspp/blob/99386da01e155fb5b15a7da7cdc893d1b40a263a/SDL/SDLGLGraphicsContext.cpp#L8

The following:

#if defined(USING_EGL)
#include "EGL/egl.h"
#endif

-[Unknown]

shantigilbert commented 6 years ago

Thanks for the reply but unfortunately I get the same error :(

shantigilbert commented 6 years ago

after trying one by one, last compiling Commit is c27d64f273c231241e84498eb9392fbc05635780 but it won't work on the device itself, it just shows a black screen.

shantigilbert commented 6 years ago

Any idea on how can I fix this?

unknownbrackets commented 6 years ago

From that it sounds like the Vulkan changes brought this on. But this error:

error: 'EGL_Init' was not declared in this scope

Really should be solved by including EGL.h in that c file. If that's not helping, I'm a bit perplexed.

-[Unknown]

shantigilbert commented 6 years ago

Thank you for the reply, Is there a way to pass an option to skip vulkan, for systems that don't support it? I am going to compile each commit and see exactly where the error started showing.

suzuke commented 6 years ago

Hi, here is a patch for skiping vulkan for -DARMV7=1 patch

We will still have the error due to it is defined at SDL/SDLMain.cpp and not being referenced in SDL/SDLGLGraphicsContext.cpp

error: 'EGL_Init' was not declared in this scope

with this above patch, below commit build fine c27d6

shantigilbert commented 6 years ago

Thanks @suzuke I will try that and report back :)

shantigilbert commented 6 years ago

Unfortunately it didn't work :( that commit compiles fine with or without the patch, but it does not work on the device itself (SDL_CreateWindow failed: Could not initialize OpenGL / GLES library ). after that commit no other one compiles :(

I think using -DNO_VULKAN has the same effect, but the main problem is I am not sure why its not finding egl.h.

This is the info I have gathered:

The SDL create window error starts on this commit: e3eb6d36b16506f8c7cc5c6de613cf246499c4d6

It seems to me (but I could be very wrong) like the commits to fix Raspberry Pi GLES2 compilation broke other devices, since the egl.h problems seem to start around those commits, unfortunately this is something out of my league to even debug much less even for me to confirm :(

Last good commit that I tried and worked on the S905 is this one 9a732fe52eb25ce92f0289f08d86bd4ca648fdd2

Thanks for all the help.

suzuke commented 6 years ago

EGL_Init is a function defined in SDLMain.cpp (but after the separation of SDLGLGraphicsContext, , SDLGLGraphicsContext using it but didn't reference it 85446d) It doesn't come from egl.h, so the compile issue is not related to egl.h not being found.

unknownbrackets commented 6 years ago

Oh, oops, I assumed it was actual EGL without thinking.

In that case, we should really just move EGL_Init over to the new file too, looks like it's only used there. As a temporary workaround, you can put int8_t EGL_Init(); after all the #include lines in SDLGLGraphicsContext.cpp.

Disabling Vulkan on all arm64 devices is not a good idea, since it works quite well on Android arm64 devices.

Anyway, the SDL create window issue may be a problem with the driver when requesting a specific version - try replacing this line:

for (size_t i = 0; i < ARRAY_SIZE(attemptVersions); ++i) {

With:

if (false) {

Does it work again (this is just a hack), or does it still error?

-[Unknown]

suzuke commented 6 years ago

There is not only EGL_Init() but also g_eglDisplay, g_eglSurface, eglSwapBuffers, EGL_Close() all has the same issue. For example, CheckEGLErrors is only defined in SDLMain but it is used in both EGL_Open, EGL_Init. It would not work if we just move EGL_Init to the new file.

shantigilbert commented 6 years ago

@unknownbrackets unfortunately that didn't work, there is no error on EGL_Init() anymore but as @suzuke said, there is still errors on the others.

Also the change for the SDL window didn't work :(

shantigilbert commented 6 years ago

I managed to move forward on this a bit by adding this:

int8_t EGL_Init(); 
static EGLDisplay g_eglDisplay = NULL;
static EGLSurface g_eglSurface = NULL;
int8_t EGL_Close();

but now I get this error:

/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.3/PPSSPPSDL-3c16f84/SDL/SDLVulkanGraphicsContext.cpp: In member function 'bool SDLVulkanGraphicsContext::Init(SDL_Window*&, int, int, int, std::string*)':
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.3/PPSSPPSDL-3c16f84/SDL/SDLVulkanGraphicsContext.cpp:64:64: error: 'union SDL_SysWMinfo::<anonymous>' has no member named 'x11'
   vulkan_->InitSurface(WINDOWSYSTEM_XLIB, (void*)sys_info.info.x11.display,
                                                                ^~~
/home/sx05re/sx05re/8.2Kszaq/build.Sx05RE-S905.arm-1.8.3/PPSSPPSDL-3c16f84/SDL/SDLVulkanGraphicsContext.cpp:65:37: error: 'union SDL_SysWMinfo::<anonymous>' has no member named 'x11'
     (void *)(intptr_t)sys_info.info.x11.window, pixel_xres, pixel_yres);
make[1]: *** [CMakeFiles/Makefile2:464: CMakeFiles/native.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
At global scope:
cc1plus: warning: unrecognized command line option '-Wno-deprecated-register'
[ 41%] Linking CXX static library ../../lib/libarmips.a
[ 41%] Built target armips
make: *** [Makefile:128: all] Error 2
shantigilbert commented 6 years ago

Got it to compile with @suzuke 's no vulkan patch (we really don't need it in this device) but now just need to figure out the SDL window creation error. I think this might work, replacing from line https://github.com/hrydgard/ppsspp/blob/7ef749b6679bca58bb8c01593e4f7ca9bb0fc3ab/SDL/SDLGLGraphicsContext.cpp#L26 to https://github.com/hrydgard/ppsspp/blob/7ef749b6679bca58bb8c01593e4f7ca9bb0fc3ab/SDL/SDLGLGraphicsContext.cpp#L62


/*
                // maybe this?? 
        mode |= SDL_WINDOW_FULLSCREEN_DESKTOP;
*/

mode |= SDL_WINDOW_OPENGL | SDL_WINDOW_FULLSCREEN;
    SDL_GLContext glContext = nullptr;

        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
        SetGLCoreContext(false);

        window = SDL_CreateWindow("PPSSPP", x,y, pixel_xres, pixel_yres, mode);
        if (!window) {
            NativeShutdown();
            fprintf(stderr, "SDL_CreateWindow failed: %s\n", SDL_GetError());
        }

        glContext = SDL_GL_CreateContext(window);
        if (glContext != nullptr) {
            // Victory, got one.
        }

But I really have no idea what I am doing! so if someone can tell me if this would work and not break anything else I would appreciate it :)

I will post the full patch when I figure this out.

EDIT: it kinda worked, now I don't get an error, but I only get sound and no video :( btw this is the real error it gives without modifying anything:

SDL_CreateWindow failed: mali-fbdev: Can't create EGL window surface

shantigilbert commented 6 years ago

@unknownbrackets sorry to be a bother on this, but have you had any time to check this at all? I've been trying so many ways, but the best I could do is get audio with no video, my experience on this is practically null so I am just doing trial and error. It would be great if you could give me more pointers as to how to move forward to fix this. Thank you!

unknownbrackets commented 6 years ago

I googled around a bit - is your user in the "video" group?

-[Unknown]

shantigilbert commented 6 years ago

User is always root, LE only has one user.

hissingshark commented 6 years ago

@shantigilbert When you say

Last commit I was using was 5eba689

Do you mean that built and ran okay?

I've been trying #10534 to build PPSSPP since last year on an S905x and the best I managed was built, but with a black screen at runtime, and no error messages (sound and gamepad working in the background though).

I just checked out that commit and unfortunately that too had the black screen.

shantigilbert commented 6 years ago

@hissingshark The last commit that works for me is this one 9a732fe

Not sure what you are using as OS, I am using LibreElec, but to make it work I need to set the color depth to 16 so that it will run.

I use (for 1080p) fbset -fb /dev/fb0 -g 1920 1080 1920 2160 16

then you can run PPSSPP, if I run it without chaining depth all I get is sound.

But after the changes to SDLGLGraphicsContext.cpp nothing I've tried seems to work anymore.

hissingshark commented 6 years ago

@shantigilbert Well that's most enlightening, thank you! With that setting my v1.5.4 build and the 9a732fe both run.

I wish I'd know about this last year. Because now I can see how badly it's running on my box and I needn't have spent so many nights on it! I've tried downgrading as many setting as I can but can't quite get it playable. Tested GTA and the Burnout games so far. I'll try a bit more tweaking, but I think it's just beyond the SOC, which is understandable (don't know until you try). Having said that, you must have found it acceptable or you wouldn't be trying to build from master?

My OS is OSMC on their Vero4k. It would run better I'm sure if I was running 64-bit as it's aarch64/armv8-a, but unfortunately our userland is 32. I see from the 1st post that you were tricking it into building for armv7 too. I can build most of it 64, but at the final linking stage I get:

[100%] Linking CXX executable PPSSPPSDL /usr/bin/ld: skipping incompatible /opt/vero3/lib/libGLESv2.so when searching for -lGLESv2 /usr/bin/ld: cannot find -lGLESv2

I assume the video drivers are pre-compiled as 32bit and I can't work around that as the sources aren't available.

shantigilbert commented 6 years ago

Not sure about GTA, but the games I play on it run at 30+fps without a problem, which make them very playable To test, try running Ultimate Ghosts 'n Goblins and if it's below 30 fps then it has to be something on the OS you are using (or probably the settings?)

These are the options I used to build and older version for 64bit "-DUSING_FBDEV=1 \ -DUSING_GLES2=1 \ -DUSE_FFMPEG=1 \ -DARM64=1 \ -DSHARED_LIBZIP=1 \ -DARM_NEON=1"

but I didn't find any performance advantages so I never tried it again.

unknownbrackets commented 6 years ago

@hissingshark found some useful issues in #10534 which are probably related. There was a mistake in the way GL versions were being attempted. See #11144.

I think there's more information in that other issue (which is older than this one) at this point, so I'm going to close this as a duplicate. If I'm wrong, feel free to comment and I'll reopen.

-[Unknown]

shantigilbert commented 6 years ago

@unknownbrackets Thanks, although that fixed the SDL window error, when I run it there is still only a black screen with audio. (but you also mentioned that in the other issue)

Also I still had to add this to make it compile

int8_t EGL_Init(); 
static EGLDisplay g_eglDisplay = NULL;
static EGLSurface g_eglSurface = NULL;
int8_t EGL_Close();

Otherwise I would get the same errors as the first post. not sure what else could be, but you can leave this issue closed and follow up on the other one as it seems it has better info, Thanks!