Skip to content

Commit

Permalink
Avoid unaligned accesses when hashing vertex data on ARM. Fixes #9114,…
Browse files Browse the repository at this point in the history
… may help #9128 and #9129.
  • Loading branch information
hrydgard committed Dec 1, 2016
1 parent e675761 commit fe6d2d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 0 additions & 1 deletion GPU/Common/SplineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ inline float bern1(float x) { return 3 * x * (1 - x) * (1 - x); }
inline float bern2(float x) { return 3 * x * x * (1 - x); }
inline float bern3(float x) { return x * x * x; }

// Not sure yet if these have any use
inline float bern0deriv(float x) { return -3 * (x - 1) * (x - 1); }
inline float bern1deriv(float x) { return 9 * x * x - 12 * x + 3; }
inline float bern2deriv(float x) { return 3 * (2 - 3 * x) * x; }
Expand Down
8 changes: 8 additions & 0 deletions GPU/Common/TextureDecoderNEON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.

#include "ppsspp_config.h"

#if PPSSPP_ARCH(ARM_NEON)

#include "ext/xxhash.h"

#include <arm_neon.h>

#include "GPU/GPUState.h"
Expand Down Expand Up @@ -182,6 +185,11 @@ void DoUnswizzleTex16NEON(const u8 *texptr, u32 *ydestp, int bxc, int byc, u32 p
#endif

u32 ReliableHash32NEON(const void *input, size_t len, u32 seed) {
if (((uintptr_t)input & 3) != 0) {
// Cannot handle misaligned data. Fall back to XXH32.
return XXH32(input, len, seed);
}

const u8 *p = (const u8 *)input;
const u8 *const bEnd = p + len;
U32 h32;
Expand Down
6 changes: 5 additions & 1 deletion ext/xxhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ You can contact the author at :
// For others CPU, the compiler will be more cautious, and insert extra code to ensure aligned access is respected.
// If you know your target CPU supports unaligned memory access, you want to force this option manually to improve performance.
// You can also enable this parameter if you know your input data will always be aligned (boundaries of 4, for U32).
#if !defined(IOS) && (defined(ARM) || defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64))

#include "ppsspp_config.h"

// ector NOTE: For whatever reason ARM is unhappy about this on Android.
#if !defined(IOS) && !defined(ANDROID) && (defined(ARM) || defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64))
# define XXH_USE_UNALIGNED_ACCESS 1
#endif

Expand Down

0 comments on commit fe6d2d4

Please sign in to comment.