Added new configuration parameter support 'GL_MAX_TEXTURE_IMAGE_UNITS' to the emscripten Module object so that codebases using fixed-function GL emulation mode can hint to the emulation code how many texture units they are using at maximum. This optimizes the emulation code path to avoid having to examine an unnecessary amount of texture units at each draw call (at minimum the code would loop over to confirm that the unused texunits are really unused, which would burn up some unneeded cycles.)
Remove vertex attribute size and type information from being part of the FFP emulation renderer key. This improves performance by making the renderer key simpler, which causes fewer renderer state key traversals to be done in getRenderer(), and by reducing the number of created shader programs and # of shader program switches performed during frame.
Simplify the key state used for identifying used vertex attribute set. The function CKeyView.next() shows up as one of the hottest in profiles, so merging multiple key identifiers to one helps performance.
Optimize GL emulation performance by packing the GLTexEnv renderer key to a tighter space, which greatly reduces the number of required CKeyView.next() traversals that show up costly in the profiles.
Cache the currently active FFP emulation renderer object. If renderer-related GL state does not change, the renderer can then be looked up very quickly, instead of having to recompute the key every time.
Fix GL logging message when GL_UNSAFE_OPTS is disabled.
Version immediate mode GL matrix stack data, so that the matrices don't need to be reset on each program if they didn't change.
Name GL functions that show up as anonymous in the profile.
Skip looping twice over textures in GL emulation renderer prepare() code. Clean up unnecessary variable.
Add new GL emulation related #define GL_FFP_ONLY which is used to signal that the C/C++ client code will not use any GL shaders, allowing more efficient optimizations to be performed in the FFP GL emulation code knowing that it doesn't need to worry about shader programs from the user.
Cast GL emulation matrix version numbers back to integers after increment. Code cleanup and clarify comments.
Merge pull request #1863 from juj/gl_emulation_opts_rebased

Optimize GL emulation layer.