Building mednafen_psx_hw on Rpi4 (GLES 3.1)

Hi,

I am trying to build mednafen-psx from latest git sources (https://github.com/libretro/beetle-psx-libretro). To build it for the Pi4, I have added as a platform this to the Makefile:

# Raspberry Pi4, 64bit mode.
else ifeq ($(platform), rpi4)
   TARGET  := $(TARGET_NAME)_libretro.so
   fpic    := -fPIC
   SHARED  := -shared -Wl,--no-undefined -Wl,--version-script=link.T
   LDFLAGS += $(PTHREAD_FLAGS)
   FLAGS   += $(PTHREAD_FLAGS)
   FLAGS   += -march=armv8-a+crc+simd -mtune=cortex-a72
   HAVE_OPENGL = 1
   SET_HAVE_HW = 1
   GLES     = 1
   GL_LIB  := -lGLESv2

RetroArch is running here on GLES 3.1, so GLES 3.1 is really available:

[INFO] [GL]: Found GL context: kms
[INFO] [GL]: Detecting screen resolution 1360x768.
[INFO] [EGL] Found EGL_EXT_platform_base, trying eglGetPlatformDisplayEXT
[INFO] [EGL]: EGL version: 1.4
[INFO] [EGL]: Current context: 0x55a8755da0.
[INFO] [KMS]: New FB: 1360x768 (stride: 5440).
[INFO] [GL]: Vendor: Broadcom, Renderer: V3D 4.2.
[INFO] [GL]: Version: OpenGL ES 3.1 Mesa 20.2.1.

However, when trying to build the mednafen PSX HW core I get this:

rsx/rsx_lib_gl.cpp: In function 'void DrawBuffer_bind_attributes(DrawBuffer<T>*)':
rsx/rsx_lib_gl.cpp:798:15: error: 'GL_DOUBLE' was not declared in this scope
          case GL_DOUBLE:
               ^~~~~~~~~
rsx/rsx_lib_gl.cpp:798:15: note: suggested alternative: 'GL_NONE'
          case GL_DOUBLE:
               ^~~~~~~~~
               GL_NONE
rsx/rsx_lib_gl.cpp: In function 'void Framebuffer_init(Framebuffer*, Texture*)':
rsx/rsx_lib_gl.cpp:882:22: error: 'GL_DRAW_FRAMEBUFFER' was not declared in this scope
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb->id);
                      ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:882:22: note: suggested alternative: 'GL_DRAW_FRAMEBUFFER_NV'
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb->id);
                      ^~~~~~~~~~~~~~~~~~~
                      GL_DRAW_FRAMEBUFFER_NV
rsx/rsx_lib_gl.cpp: In function 'void Texture_set_sub_image_window(Texture*, uint16_t*, uint16_t*, size_t, GLenum, GLenum, uint16_t*)':
rsx/rsx_lib_gl.cpp:936:18: error: 'GL_UNPACK_ROW_LENGTH' was not declared in this scope
    glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) row_len);
                  ^~~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:936:18: note: suggested alternative: 'GL_UNPACK_ROW_LENGTH_EXT'
    glPixelStorei(GL_UNPACK_ROW_LENGTH, (GLint) row_len);
                  ^~~~~~~~~~~~~~~~~~~~
                  GL_UNPACK_ROW_LENGTH_EXT
rsx/rsx_lib_gl.cpp: In function 'void GlRenderer_draw(GlRenderer*)':
rsx/rsx_lib_gl.cpp:982:28: error: 'GL_DRAW_FRAMEBUFFER' was not declared in this scope
    glFramebufferTexture(   GL_DRAW_FRAMEBUFFER,
                            ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:982:28: note: suggested alternative: 'GL_DRAW_FRAMEBUFFER_NV'
    glFramebufferTexture(   GL_DRAW_FRAMEBUFFER,
                            ^~~~~~~~~~~~~~~~~~~
                            GL_DRAW_FRAMEBUFFER_NV
rsx/rsx_lib_gl.cpp:983:10: error: 'GL_DEPTH_STENCIL_ATTACHMENT' was not declared in this scope
          GL_DEPTH_STENCIL_ATTACHMENT,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:983:10: note: suggested alternative: 'GL_STENCIL_ATTACHMENT'
          GL_DEPTH_STENCIL_ATTACHMENT,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
          GL_STENCIL_ATTACHMENT
rsx/rsx_lib_gl.cpp: In function 'void GlRenderer_upload_textures(GlRenderer*, uint16_t*, uint16_t*, uint16_t*)':
rsx/rsx_lib_gl.cpp:1116:10: error: 'GL_UNSIGNED_SHORT_1_5_5_5_REV' was not declared in this scope
          GL_UNSIGNED_SHORT_1_5_5_5_REV,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:1116:10: note: suggested alternative: 'GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT'
          GL_UNSIGNED_SHORT_1_5_5_5_REV,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
rsx/rsx_lib_gl.cpp:1151:37: error: 'GL_FILL' was not declared in this scope
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                     ^~~~~~~
rsx/rsx_lib_gl.cpp:1151:37: note: suggested alternative: 'GL_FOG'
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                     ^~~~~~~
                                     GL_FOG
rsx/rsx_lib_gl.cpp: In function 'bool GlRenderer_new(GlRenderer*, DrawConfig)':
rsx/rsx_lib_gl.cpp:1391:43: error: 'GL_LINE' was not declared in this scope
    GLenum command_draw_mode = wireframe ? GL_LINE : GL_FILL;
                                           ^~~~~~~
rsx/rsx_lib_gl.cpp:1391:43: note: suggested alternative: 'GL_LINES'
    GLenum command_draw_mode = wireframe ? GL_LINE : GL_FILL;
                                           ^~~~~~~
                                           GL_LINES
rsx/rsx_lib_gl.cpp:1391:53: error: 'GL_FILL' was not declared in this scope
    GLenum command_draw_mode = wireframe ? GL_LINE : GL_FILL;
                                                     ^~~~~~~
rsx/rsx_lib_gl.cpp:1391:53: note: suggested alternative: 'GL_FOG'
    GLenum command_draw_mode = wireframe ? GL_LINE : GL_FILL;
                                                     ^~~~~~~
                                                     GL_FOG
rsx/rsx_lib_gl.cpp:1408:28: error: 'GL_RGBA8' was not declared in this scope
          texture_storage = GL_RGBA8;
                            ^~~~~~~~
rsx/rsx_lib_gl.cpp:1408:28: note: suggested alternative: 'GL_RGBA4'
          texture_storage = GL_RGBA8;
                            ^~~~~~~~
                            GL_RGBA4
rsx/rsx_lib_gl.cpp:1425:10: error: 'GL_DEPTH24_STENCIL8' was not declared in this scope
          GL_DEPTH24_STENCIL8);
          ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:1425:10: note: suggested alternative: 'GL_DEPTH24_STENCIL8_OES'
          GL_DEPTH24_STENCIL8);
          ^~~~~~~~~~~~~~~~~~~
          GL_DEPTH24_STENCIL8_OES
rsx/rsx_lib_gl.cpp: In function 'void bind_libretro_framebuffer(GlRenderer*)':
rsx/rsx_lib_gl.cpp:1679:22: error: 'GL_DRAW_FRAMEBUFFER' was not declared in this scope
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
                      ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:1679:22: note: suggested alternative: 'GL_DRAW_FRAMEBUFFER_NV'
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
                      ^~~~~~~~~~~~~~~~~~~
                      GL_DRAW_FRAMEBUFFER_NV
rsx/rsx_lib_gl.cpp: In function 'bool retro_refresh_variables(GlRenderer*)':
rsx/rsx_lib_gl.cpp:1828:31: error: 'GL_RGBA8' was not declared in this scope
             texture_storage = GL_RGBA8;
                               ^~~~~~~~
rsx/rsx_lib_gl.cpp:1828:31: note: suggested alternative: 'GL_RGBA4'
             texture_storage = GL_RGBA8;
                               ^~~~~~~~
                               GL_RGBA4
rsx/rsx_lib_gl.cpp:1855:51: error: 'GL_DEPTH24_STENCIL8' was not declared in this scope
       Texture_init(&renderer->fb_out_depth, w, h, GL_DEPTH24_STENCIL8);
                                                   ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:1855:51: note: suggested alternative: 'GL_DEPTH24_STENCIL8_OES'
       Texture_init(&renderer->fb_out_depth, w, h, GL_DEPTH24_STENCIL8);
                                                   ^~~~~~~~~~~~~~~~~~~
                                                   GL_DEPTH24_STENCIL8_OES
rsx/rsx_lib_gl.cpp:1866:49: error: 'GL_LINE' was not declared in this scope
    renderer->command_polygon_mode = wireframe ? GL_LINE : GL_FILL;
                                                 ^~~~~~~
rsx/rsx_lib_gl.cpp:1866:49: note: suggested alternative: 'GL_LINES'
    renderer->command_polygon_mode = wireframe ? GL_LINE : GL_FILL;
                                                 ^~~~~~~
                                                 GL_LINES
rsx/rsx_lib_gl.cpp:1866:59: error: 'GL_FILL' was not declared in this scope
    renderer->command_polygon_mode = wireframe ? GL_LINE : GL_FILL;
                                                           ^~~~~~~
rsx/rsx_lib_gl.cpp:1866:59: note: suggested alternative: 'GL_FOG'
    renderer->command_polygon_mode = wireframe ? GL_LINE : GL_FILL;
                                                           ^~~~~~~
                                                           GL_FOG
rsx/rsx_lib_gl.cpp: In function 'void cleanup_gl_state()':
rsx/rsx_lib_gl.cpp:2153:22: error: 'GL_DRAW_FRAMEBUFFER' was not declared in this scope
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
                      ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:2153:22: note: suggested alternative: 'GL_DRAW_FRAMEBUFFER_NV'
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
                      ^~~~~~~~~~~~~~~~~~~
                      GL_DRAW_FRAMEBUFFER_NV
rsx/rsx_lib_gl.cpp: In function 'void rsx_gl_finalize_frame(const void*, unsigned int, unsigned int, unsigned int)':
rsx/rsx_lib_gl.cpp:2491:37: error: 'GL_FILL' was not declared in this scope
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                     ^~~~~~~
rsx/rsx_lib_gl.cpp:2491:37: note: suggested alternative: 'GL_FOG'
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                     ^~~~~~~
                                     GL_FOG
rsx/rsx_lib_gl.cpp: In function 'void rsx_gl_load_image(uint16_t, uint16_t, uint16_t, uint16_t, uint16_t*, uint32_t, uint32_t)':
rsx/rsx_lib_gl.cpp:3107:10: error: 'GL_UNSIGNED_SHORT_1_5_5_5_REV' was not declared in this scope
          GL_UNSIGNED_SHORT_1_5_5_5_REV,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:3107:10: note: suggested alternative: 'GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT'
          GL_UNSIGNED_SHORT_1_5_5_5_REV,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT
rsx/rsx_lib_gl.cpp:3139:37: error: 'GL_FILL' was not declared in this scope
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                     ^~~~~~~
rsx/rsx_lib_gl.cpp:3139:37: note: suggested alternative: 'GL_FOG'
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                                     ^~~~~~~
                                     GL_FOG
rsx/rsx_lib_gl.cpp: In function 'void rsx_gl_fill_rect(uint32_t, uint16_t, uint16_t, uint16_t, uint16_t)':
rsx/rsx_lib_gl.cpp:3204:28: error: 'GL_DRAW_FRAMEBUFFER' was not declared in this scope
       glFramebufferTexture(GL_DRAW_FRAMEBUFFER,
                            ^~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:3204:28: note: suggested alternative: 'GL_DRAW_FRAMEBUFFER_NV'
       glFramebufferTexture(GL_DRAW_FRAMEBUFFER,
                            ^~~~~~~~~~~~~~~~~~~
                            GL_DRAW_FRAMEBUFFER_NV
rsx/rsx_lib_gl.cpp:3205:13: error: 'GL_DEPTH_STENCIL_ATTACHMENT' was not declared in this scope
             GL_DEPTH_STENCIL_ATTACHMENT,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
rsx/rsx_lib_gl.cpp:3205:13: note: suggested alternative: 'GL_STENCIL_ATTACHMENT'
             GL_DEPTH_STENCIL_ATTACHMENT,
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
             GL_STENCIL_ATTACHMENT
make: *** [Makefile:674: rsx/rsx_lib_gl.o] Error 1

So, is Mednafen PSX HW suppose to build against GLES 3.1? Thanks

No, and i also have serious doubts pi4 could handle it anyway.

So, just to get a clear idea, what GLES version, if any, does Mednafen PSX HW require? Or is it desktop-GL only?

Desktop GL or vulkan, you could also use the software renderer (build with HAVE_HW=0 HAVE_OPENGL=0), it would give you an idea of how the core would perform on pi4.

Software renderer does, in fact, perform pretty well. Except for Tekken 3 ot Tobal 2, where interlaced mode totally kills performance. If only interlaced mode could be disabled as in DuckStation…

Meaning full speed ? If so, i guess it would be interesting indeed to see if the core can run on gles

Yes, meaning fullspeed. Except on Tekken 3 an Tobal 2 where interlaced mode is used. That totally destroys performance. But other games seem pretty much fullspeed. Anyway, we have Vulkan without X on the Pi4 now, so maybe you can save that time dedicated to GLES investigation :slight_smile: