GLES enabling in BGFX for MAME

I am getting these errors (about 200 of these) when using bgfx_backend as gles (render_gl.cpp) for MAME (for Android) for Mali T860 MP4. The same are coming during the init when the various texture formats (struct TextureFormat) are being checked for their support in the hardware. Vulkan bakend works fine but is much slower than gles and has glitches hence I would like to use gles.

When I check some parameters (from /sys/module/mali/parameters) from the device I see this -
$ cat mali_shared_mem_size
4294967295
$ cat mali_debug_level
2
$ cat mali_dedicated_mem_size
0

It seems from the dump above that no dedicated GPU memory is allocated and hence GPU/CPU share the memory hence I am confused with the first two issues (below). Currently I have a hack where I comment out anything above 30 in the struct TextureFormat but still have occassional crashes.

Please tell me whether more information is needed.

E/mali_so: encounter the first gles_error : 0x0001 : failed to allocate CPU memory (gles_texture_compressed_tex_image_2d at hardware/rockchip/mali_so/driver/product/gles/src/texture/mali_gles_texture_api.c:655)
E/mali_so: encounter the first gles_error : 0x0002 : failed to allocate GPU memory (gles_texture_compressed_tex_image_2d at hardware/rockchip/mali_so/driver/product/gles/src/texture/mali_gles_texture_api.c:700)
E/mali_so: encounter the first gles_error : 0x0003 : execution failed (gles_texturep_convert_internalformat at hardware/rockchip/mali_so/driver/product/gles/src/texture/mali_gles_texture_helpers.c:184)

  • I think I should apologize for not debugging further. The memory error is not right and when it came I got confused as to why a memory error. Actual I am getting errors 0x500 and 0x501 -


    GL_INVALID_ENUM, 0x0500
    Given when an enumeration parameter is not a legal enumeration for that function. This is given only for local problems; if the spec allows the enumeration in certain circumstances, where other parameters or state dictate those circumstances, then GL_INVALID_OPERATION is the result instead.

    GL_INVALID_VALUE, 0x0501
    Given when a value parameter is not a legal value for that function. This is only given for local problems; if the spec allows the value in certain circumstances, where other parameters or state dictate those circumstances, then GL_INVALID_OPERATION is the result instead.

    I am attaching the message dump files here. I have also filed the same at the BGFX site as well. All the warnings/errors (200) leads to a SIGTRAP -

    2019-11-07 16:29:53.813 5803-5856/? A/libc: Fatal signal 5 (SIGTRAP), code 1 in tid 5856 (SDLThread), pid 5803 (rg.mamedev.mame)

    Any help/insight will be great. Looking forward for any reply.

    BC1 is not supported by hardware (data below)


    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1531): **BGFX In isTextureFormatValid: 0, 0, 0, BC1** ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1450): BGFX In initTestTexture: _format - 0, _srgb - 0, _mipmaps - 0, _array - 0, _dim - 16 ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1491): BGFX initTestTexture: calling compressedtexImage - ii - 0, internalFmt - 0x83f1 ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1393): BGFX compressedTexImage target - 0xde1, level - 0, width - 16, height - 16, imagesize - 128

    D/: ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1394): BGFX compressedTexImage _internalformat - 0x83f1, _depth - 0, _border - 0, _data - 1828711968
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1434): BGFX calling glCompressedTexImage2D
    E/mali_so: encounter the first gles_error : 0x0001 : failed to allocate CPU memory (gles_texture_compressed_tex_image_2d at hardware/arm/maliT760/driver/product/gles/src/texture/mali_gles_texture_api.c:655)
    to dump the call_stack of the first error :
    I/[Gralloc]: Got handle 2 for fd 62
    leave, w : 1920, h : 1080, format : 0x1,internal_format : 0x1, usage : 0xb00. size=8294400,pixel_stride=1920,byte_stride=7680
    leave: prime_fd=62,share_attr_fd=63
    D/mali_so: #00 pc 00000000005599b4 /vendor/lib64/egl/libGLES_mali.so (glCompressedTexImage2D+112)
    #1 pc 0000000002e28194 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::initTestTexture(bgfx::TextureFormat::Enum, bool, bool, bool, int)+392)
    #2 pc 0000000002e635c0 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::isTextureFormatValid(bgfx::TextureFormat::Enum, bool, bool, bool, int)+1468)
    #3 pc 0000000002e2a960 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::RendererContextGL::init(bgfx::Init const&)+5928)
    #4 pc 0000000002e2888c /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::rendererCreate(bgfx::Init const&)+104)
    #5 pc 0000000002e07418 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::rendererCreate(bgfx::Init const&)+900)
    D/mali_so: #6 pc 0000000002e0a394 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::Context::rendererExecCommands(bgfx::CommandBuffer&)+12080)
    #7 pc 0000000002e01d90 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::Context::renderFrame(int)+212)
    #8 pc 0000000002e01be4 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::renderFrame(int)+172)
    #9 pc 0000000002e03c38 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::Context::renderThread(bx::Thread*, void*)+36)
    #10 pc 0000000002ec6a14 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bx::ThreadInternal::threadFunc(void*)+36)
    #11 pc 0000000000067d80 /system/lib64/libc.so (__pthread_start(void*)+36)
    #12 pc 000000000001ec18 /system/lib64/libc.so (__start_thread+68)
    D/: ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1494): BGFX initTestTexture: compressedtexImage returns - getGlError reports - 0x500
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1565): BGFX WARN TextureFormat::BC1 is not supported (500: GL_INVALID_ENUM).

    Hardware reports that it supports ETC1 (data below)

    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1531): BGFX In isTextureFormatValid: 0, 0, 0, ETC1
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1450): BGFX In initTestTexture: _format - 7, _srgb - 0, _mipmaps - 0, _array - 0, _dim - 16
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1491): BGFX initTestTexture: calling compressedtexImage - ii - 0, internalFmt - 0x8d64
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1393): BGFX compressedTexImage target - 0xde1, level - 0, width - 16, height - 16, imagesize - 128
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1394): BGFX compressedTexImage _internalformat - 0x8d64, _depth - 0, _border - 0, _data - 1828711968
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1434): BGFX calling glCompressedTexImage2D
    

    D/: ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1494): BGFX initTestTexture: compressedtexImage returns - getGlError reports - 0x0

    A FAIL CASE of a texture supported but then still throws an error

    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1531): **BGFX In isTextureFormatValid: 0, 0, 0, ASTC5x5**
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1450): BGFX In initTestTexture: _format - 21, _srgb - 0, _mipmaps - 0, _array - 0, _dim - 16
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1491): BGFX initTestTexture: calling compressedtexImage - ii - 0, internalFmt - 0x93b2
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1393): BGFX compressedTexImage target - 0xde1, level - 0, width - 16, height - 16, imagesize - 192
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1394): BGFX compressedTexImage _internalformat - 0x93b2, _depth - 0, _border - 0, _data - 1828711904
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1434): BGFX calling glCompressedTexImage2D
    

    E/mali_so: encounter the first gles_error : 0x0002 : failed to allocate GPU memory (gles_texture_compressed_tex_image_2d at hardware/arm/maliT760/driver/product/gles/src/texture/mali_gles_texture_api.c:700)
    to dump the call_stack of the first error :
    D/mali_so: #00 pc 00000000005599b4 /vendor/lib64/egl/libGLES_mali.so (glCompressedTexImage2D+112)
    D/mali_so: #1 pc 0000000002e28194 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::initTestTexture(bgfx::TextureFormat::Enum, bool, bool, bool, int)+392)
    #2 pc 0000000002e635c0 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::isTextureFormatValid(bgfx::TextureFormat::Enum, bool, bool, bool, int)+1468)
    #3 pc 0000000002e2a960 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::RendererContextGL::init(bgfx::Init const&)+5928)
    #4 pc 0000000002e2888c /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::gl::rendererCreate(bgfx::Init const&)+104)
    #5 pc 0000000002e07418 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::rendererCreate(bgfx::Init const&)+900)
    #6 pc 0000000002e0a394 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::Context::rendererExecCommands(bgfx::CommandBuffer&)+12080)
    #7 pc 0000000002e01d90 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::Context::renderFrame(int)+212)
    #8 pc 0000000002e01be4 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::renderFrame(int)+172)
    #9 pc 0000000002e03c38 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bgfx::Context::renderThread(bx::Thread*, void*)+36)
    #10 pc 0000000002ec6a14 /data/app/org.mamedev.mame-VgxC69JDTO58L9hu88n6Pg==/lib/arm64/libmain.so (bx::ThreadInternal::threadFunc(void*)+36)
    #11 pc 0000000000067d80 /system/lib64/libc.so (__pthread_start(void*)+36)
    #12 pc 000000000001ec18 /system/lib64/libc.so (__start_thread+68)
    D/: ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1494): BGFX initTestTexture: compressedtexImage returns - getGlError reports - 0x501
    ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1565): BGFX WARN TextureFormat::ASTC5x5 is not supported (501: GL_INVALID_VALUE).

    Some more data (yes I know I need to upgrade the ARM Mali driver by a whole 1276.78 Miles :) )

        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1899): BGFX       Vendor: ARM
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1900): BGFX     Renderer: Mali-T860
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1901): BGFX      Version: OpenGL ES 3.2 v1.r18p0-01rel0.b959385dd04b968bd095a8c31665a39a
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1902): BGFX GLSL version: OpenGL ES GLSL ES 3.20

    All the compressed texture supported by the hardware

    D/: ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1846): BGFX GL_NUM_COMPRESSED_TEXTURE_FORMATS 69
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     0:     8b90 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     1:     8b91 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     2:     8b92 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     3:     8b93 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     4:     8b94 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     5:     8b95 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     6:     8b96 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     7:     8b97 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     8:     8b98 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX     9:     8b99 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    10:     8d64 ETC1
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    11:     9274 ETC2
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    12:     9275 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    13:     9278 ETC2A
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    14:     9279 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    15:     9276 ETC2A1
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    16:     9277 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    17:     9270 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    18:     9272 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    19:     9271 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    20:     9273 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    21:     93b0 ASTC4x4
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    22:     93b1 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    23:     93b2 ASTC5x5
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    24:     93b3 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    25:     93b4 ASTC6x6
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    26:     93b5 ASTC8x5
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    27:     93b6 ASTC8x6
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    28:     93b7 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    29:     93b8 ASTC10x5
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    30:     93b9 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    31:     93ba <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    32:     93bb <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    33:     93bc <unknown>
    D/: ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    34:     93bd <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    35:     93d0 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    36:     93d1 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    37:     93d2 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    38:     93d3 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    39:     93d4 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    40:     93d5 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    41:     93d6 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    42:     93d7 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    43:     93d8 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    44:     93d9 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    45:     93da <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    46:     93db <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    47:     93dc <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    48:     93dd <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    49:     93c0 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    50:     93c1 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    51:     93c2 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    52:     93c3 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    53:     93c4 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    54:     93c5 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    55:     93c6 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    56:     93c7 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    57:     93c8 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    58:     93c9 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    59:     93e0 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    60:     93e1 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    61:     93e2 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    62:     93e3 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    63:     93e4 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    64:     93e5 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    65:     93e6 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    66:     93e7 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    67:     93e8 <unknown>
        ../../../../../3rdparty/bgfx/src/renderer_gl.cpp (1869): BGFX    68:     93e9 <unknown>

More questions in this forum