hrydgard/ppsspp — pull request #7029 by unknownbrackets (2014-10-27 05:12:52+00:00)
Title: Attempt to make the texture hash match(able) - needs testing

Unfortunately, I *do not currently have an Android device*, so the ARM changes are *completely untested*. They do compile.

The non-SSE version matches the SSE2 version for all the textures I tested. Before you ask, no, MSVC is not able to vectorize it (I even tried making it easier in different ways.) Didn't check gcc. In MSVC is takes about 10 times as long as the SSE2 version (which puts it about in the same speed range as XXH32.)

The alternation to the SSE2 version has no speed impact.

The alternations to the NEON version **may** result in the same hash values, but are untested. They may or may not have a performance impact, which is also untested. Could really use someone's testing here.

The goal is that they would match and we could potentially use them for texture replacements or what have you.

To test the NEON versions' performance, you would do the following:

1. Change headless/Headless.cpp as follows:

1.1. Add `#include "GPU/Common/TextureDecoder.h"` near the top.
1.2. Find:
```c++
int main(int argc, const char* argv[])
{
```
Replace:
```c++
volatile u32 noOptimPlease;
int main(int argc, const char* argv[])
{
const static char ref[16384] = {1, 2, 3, 4, 5, -1, -1, -1, -1, -1};
double st1 = real_time_now();
for (int i = 0; i < 10000; ++i) {
noOptimPlease |= DoQuickTexHash(ref, 16384);
}
double et1 = real_time_now();
printf("Time taken: %f, result = %08x\n", et1 - st1, DoQuickTexHash(ref, 16384));
return 0;
```

2. Compile *without* the patch merged, using a command line like `ab HEADLESS=1`.

3. Push the binary to your device (not using Eclipse) via `adb push ppsspp/android/libs/armeabi-v7a/ppsspp_headless //data/local/tmp/`, and then `adb shell chmod 0777 //data/local/tmp/ppsspp_headless` (both commands are necessary, device need not be rooted or anything.)

4. Execute the test: `adb shell "cd /data/local/tmp/ && ./ppsspp_headless`, ideally a few times and record the numbers.

5. Recompile with my patch and the change to headless (again, `ab HEADLESS=1`.)

6. Re push the binary as in step 3. Yes, the chmod part is needed again as well.

7. Execute the test again and record the numbers.

Ideally, they will mostly match. I expect that they will.

The next interesting thing would be to compare the hash result. The results from the two versions **should** be different, or you did something wrong. What I want it to match is the PC version. If the result is `6a713c4b` in the new version, it's most likely a winner.

-[Unknown]