In JEmu2, the following line is called only once a frame. It uploads the emulated backbuffer to an OpenGL texture which is then later displayed.
GL11.glTexImage2D(
GL11.GL_TEXTURE_2D,
0,
GL11.GL_RGBA,
texWidth,
texHeight,
0,
GL11.GL_RGBA,
GL11.GL_UNSIGNED_BYTE,
buffer);
The entire emulator spends almost 40% of the time in this call (this is on an IBM laptop with ATI video card), so using this technique can be dog slow. While I can imagine this to be not very fast, this is just unacceptable and sure seems like a performance bug.
Is there some trick I don’t know about that’s bound to be faster than this?
I have a few options:
- Revert to java2D - not preferrable given performance problems on some platforms, fullscreen instability on some platforms, no control over VSync, no hw accellerated filtering, timing problems on pre java5 etc.
- Try SDL - I don’t have any experience with SDL, but it’s the default x-platform rendering API for 2D so worth checking out.
- Try J3D with D3D renderer on windows/OGL renderer on other platforms - Might work, but adds a lot of overhead.
- Convert all rendering in JEmu2 to OpenGL (currently everything is software rendered, except the final image) - Might not work, because then this line will be called many times in some games, although with less data per texture. Might lead to more incompatibility because I’ll need more OpenGL features.
- Ignore this performance problem
But I hope I don’t have to go to any of these alternatives because I’m just doing something wrong
Any thoughts?