hrydgard/ppsspp — pull request #2570 by unknownbrackets (2013-07-01 05:04:39+00:00)
Title: Small performance improvements (textures, shader lookup)

These commits improve performance a bit in God of War's demo. Specifically:

* It uses a lot of 16-bit textures, and decodes a lot. I'm not entirely sure why, but I reduced memory copies a bit at least so it's faster.

* In it and Tales of Phantasia X, a lot of time was being spent dirtying shaders. AFAICT, the map was not gaining us much since we generally always have <= 10 in it. I tried putting an `if (shaderSwitchDirty != 0)` around it (which did help), but using a `std::vector` instead helped more. Only downside is, if there's a game that triggers tons of shader combinations, it'll probably look up slower. I've never seen this, but if it's a concern I can change it to just the if instead (I think it's about half the performance benefit.)

* Invalidation was happening a lot. So, I flipped the texture address to the top 32-bits of the texture cache key. This allows us to use `lower_bound()` and `upper_bound()` for invalidation. I gave it a bit of leeway on either side (512x512 should be the largest texture, I think has been said, right?)

God of War was really inconsistent. I ran quite a number of trials, and things definitely averaged better and looked better in the profile with these changes. But in some areas there was almost no difference.

Anyway, textures invalidate in about 10% the time (1.8% total time -> 0.18% total time), `ApplyShader()` takes a lot less time (5% total time exclusive to 1.5% total time exclusive, ToPX even more iirc), and the texture thing I'm least confident about, it sometimes cut a few percent, sometimes made no difference.

-[Unknown]