GrapheneCt / PVR_PSP2

Driver layer GPU libraries and tests for PSP2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eglGetProcAddress returns NULL for GLES functions, while those functions are actually callable

kaaass opened this issue · comments

Hi, I'm trying to port a game using PVR_PSP2, which loads GL functions dynamically but found eglGetProcAddress didn't return right address. The situation is:

init_pvr_psp2();
init_egl();
auto addr = reinterpret_cast<uint32_t>(eglGetProcAddress("glGetError"));
log("glGetError addr = %x, error = %x\n", addr, eglGetError());
// prints: glGetError addr = 0, error = 3000
log("glGetError = %d\n", glGetError());
// prints: glGetError = 0, might indicate that GLES module are loaded
addr = reinterpret_cast<uint32_t>(eglGetProcAddress("glGetError"));
log("glGetError addr = %x, error = %x\n", addr, eglGetError());
// prints: glGetError addr = 0, error = 3000

The complete test code can be found here. Additionally, loading libGLESv1_CM.suprx manually in init_pvr_psp2 would solve this problem. But I thought this might not be the correct way to use it. Anyway, thanks for developing this excellent repo! Any help will be appreciated.

You are using gles2 context. Why are you trying to load gles1 module?

Moreover, if you intend to use sdl2, like your code suggests - why not use sdl context creation funcs?

You are using gles2 context. Why are you trying to load gles1 module?

I had tried to load libGLESv2.suprx manually, but it crashed. Also, yes, loading libGLESv1_CM.suprx did make eglGetProcAddress return a non-null value, but those functions didn't seem to work correctly.

Moreover, if you intend to use sdl2, like your code suggests - why not use sdl context creation funcs?

Actually, this is how I found this issue. Take my SDL2 + gl4es4vita code as an example. When I comment this line to let SDL2 handles context creation stuff, the program crashed during OpenGL calls. I tried to recompile gl4es4vita in debug profile and found it complains that glGetError is NULL here during SDL_GL_CreateContext. So I extracted several vital codes and managed to reproduce this.

I guess I did sth wrong while setting up the lib (SDL2 + gl4es4vita + PVR_PSP2 combo). But for the use case metioned in this issue, NULL return of eglGetProcAddress makes no sense to me (or maybe I miss sth in initialization?).

You have both gles1 and gles2 suprx-es. That leads to conflict. Leave only the one you're using

That solves all the problems, thanks for your help!!