hrydgard/ppsspp — pull request #2621 by arnastia (2013-07-05 02:42:27+00:00)
Title: Improved PSP memory update code (ReadFramebuffersToMemory)

Several changes/things to notice here:

* This now renders a screen aligned quad textured with the source framebuffer offscreen to another smaller framebuffer instead of using glBlitFramebuffers() to copy framebuffer contents. This way the texture is flipped and OpenGL ES support is hopefully added;

* Data is now read from this second framebuffer asynchronously using PBOs on OpenGL devices (every call data can be requested from a framebuffer and received from another). OpenGL ES devices do this synchronously with a single call to glReadPixels, as before;

* On OpenGL devices an option named FramebuffersCPUConvert can be used to force pixel format conversion (i.e., e.g., RGBA8888 to ABGR4444) to happen on the CPU as opposed to on the GPU/driver by specifying it on glReadPixels(), since cards from different vendors apparently treat some of its arguments differently (notably the type parameter seems to be handled differently between AMD and Nvidia). I added code to try and guess the vendor, but only have Nvidia devices, so only tested the end result on those. This option does nothing on OpenGL ES devices and CPU conversion is always performed on these (untested though);

* If FramebuffersCPUConvert is true or always on OpenGL ES devices, we request RGBA data in GL_UNSIGNED_BYTE format and then convert it on the CPU. Otherwise, on OpenGL devices we request data in specific types and formats for 16-bit textures (e.g., RGBA5551) and GL_UNSIGNED_BYTE for 32-bit textures and push it as is to memory (as said before, seems liable to differences in implementation);

* ReadFramebuffersToMemory() is now called only every three frames (but for all framebuffers on the same frame), provided they were used within those three frames. This is done in DecimateFBOs();

And some other less important, miscellaneous changes. These are the biggest changes, I guess. Many thanks to @unknownbrackets and other people on issue #1686 for their many suggestions and reports too.

PS: I seem to have committed some random version of the lang submodule by mistake; ignore it please.