diff --git a/GPU/Common/VertexDecoderArm64.cpp b/GPU/Common/VertexDecoderArm64.cpp index 989e37fa46..e7420b454c 100644 --- a/GPU/Common/VertexDecoderArm64.cpp +++ b/GPU/Common/VertexDecoderArm64.cpp @@ -60,8 +60,8 @@ static const ARM64Reg neonScratchRegQ = Q1; // S8-S15 are used during matrix generation // These only live through the matrix multiplication -static const ARM64Reg src[3] = { S8, S9, S10 }; // skin source -static const ARM64Reg acc[3] = { S11, S12, S13 }; // skin accumulator +static const ARM64Reg src[3] = { S16, S17, S18 }; // skin source +static const ARM64Reg acc[3] = { S19, S20, S21 }; // skin accumulator static const ARM64Reg srcNEON = Q2; static const ARM64Reg accNEON = Q3; @@ -139,9 +139,14 @@ static const JitLookup jitLookup[] = { JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec) { dec_ = &dec; + + const u32 ALL_CALLEE_SAVED = 0x7FF80000; + BitSet32 regs_to_save(ALL_CALLEE_SAVED); + const u8 *start = AlignCode16(); - WARN_LOG(HLE, "VertexDecoderJitCache::Compile"); + ABI_PushRegisters(regs_to_save); + // TODO: Also push D8-D15, the fp registers we need to save. bool prescaleStep = false; bool skinning = false; @@ -195,7 +200,8 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec) { SetJumpTarget(skip); } - // POP(6, R4, R5, R6, R7, R8, R_PC); + ABI_PopRegisters(regs_to_save); + RET(); FlushIcache(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 2f5230f012..264017e052 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -105,6 +105,8 @@ static UI::Theme ui_theme; #ifdef ARM #include "../../android/jni/ArmEmitterTest.h" +#elif defined(ARM64) +#include "../../android/jni/Arm64EmitterTest.h" #endif #ifdef IOS @@ -256,6 +258,8 @@ void NativeGetAppInfo(std::string *app_dir_name, std::string *app_nice_name, boo #if defined(ARM) && defined(ANDROID) ArmEmitterTest(); +#elif defined(ARM64) && defined(ANDROID) + Arm64EmitterTest(); #endif } diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index ba7e73f580..515fce2aa6 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -283,6 +283,12 @@ true true + + true + true + true + true + NotUsing @@ -349,7 +355,8 @@ - + + @@ -451,4 +458,4 @@ - \ No newline at end of file + diff --git a/Windows/PPSSPP.vcxproj.filters b/Windows/PPSSPP.vcxproj.filters index 887d6a8bae..ffadc00bce 100644 --- a/Windows/PPSSPP.vcxproj.filters +++ b/Windows/PPSSPP.vcxproj.filters @@ -98,6 +98,9 @@ Other Platforms + + Other Platforms + Other Platforms @@ -218,7 +221,10 @@ Windows\Input - + + Other Platforms + + Other Platforms @@ -332,4 +338,4 @@ Resource Files - \ No newline at end of file + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 377ff68b2c..278411ec8a 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -92,7 +92,8 @@ ARCH_FILES := \ $(SRC)/Core/MIPS/ARM64/Arm64RegCache.cpp \ $(SRC)/Core/MIPS/ARM64/Arm64RegCacheFPU.cpp \ $(SRC)/Core/Util/DisArm64.cpp \ - $(SRC)/GPU/Common/VertexDecoderArm64.cpp + $(SRC)/GPU/Common/VertexDecoderArm64.cpp \ + Arm64EmitterTest.cpp endif ifeq ($(TARGET_ARCH_ABI),armeabi) diff --git a/android/jni/Application.mk b/android/jni/Application.mk index 64df16e077..ea200484e5 100644 --- a/android/jni/Application.mk +++ b/android/jni/Application.mk @@ -2,6 +2,6 @@ APP_STL := gnustl_static APP_PLATFORM := android-9 #APP_ABI := armeabi-v7a x86 #APP_ABI := armeabi-v7a -APP_ABI := arm64-v8a +APP_ABI := arm64-v8a armeabi-v7a APP_GNUSTL_CPP_FEATURES := # NDK_TOOLCHAIN_VERSION := 4.9 diff --git a/android/jni/Arm64EmitterTest.cpp b/android/jni/Arm64EmitterTest.cpp new file mode 100644 index 0000000000..b23fbce984 --- /dev/null +++ b/android/jni/Arm64EmitterTest.cpp @@ -0,0 +1,88 @@ +#include "base/logging.h" +#include "Arm64EmitterTest.h" + +#include "Common/Arm64Emitter.h" +#include "Common/BitSet.h" +#include "Common/CPUDetect.h" + +static bool functionWasCalled; + +using namespace Arm64Gen; + +class TestCode : public Arm64Gen::ARM64CodeBlock { +public: + TestCode(); + void Generate(); + const u8 *testCodePtr; + const u8 *testCodePtr2; + ARM64FloatEmitter fp; +}; + +TestCode::TestCode() : fp(this) +{ + AllocCodeSpace(0x10000); +} + +static float abc[256] = {1.0f, 2.0f, 0.0f}; + +static float a[4] = {1.0f, 2.0f, 3.0f, 4.5f}; +static float b[4] = {1.0f, 1.0f, 1.0f, 0.5f}; +static float c[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + +static u32 x[4] = {0x04030201, 0x08070605, 0x0, 0x0}; +static u32 y[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; +static u32 z[4] = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}; + +void TestCode::Generate() +{ + testCodePtr = this->GetCodePtr(); + + const u32 ALL_CALLEE_SAVED = 0x7FF80000; + BitSet32 regs_to_save(ALL_CALLEE_SAVED); + + const u8 *start = AlignCode16(); + + ABI_PushRegisters(regs_to_save); + + fp.SCVTF(S0, W3, 12); + fp.SCVTF(S3, W12); + MOVI2R(X0, 1337); + + ABI_PopRegisters(regs_to_save); + + RET(); + + FlushIcache(); +} + +static u32 CallPtr(const void *ptr) { + return ((u32(*)())ptr)(); +} + +void Arm64EmitterTest() { + + for (int i = 0; i < 6; i++) { + ILOG("---------------------------"); + } + ILOG("---------------------------"); + ILOG("Running ARM64 emitter test!"); + ILOG("---------------------------"); + + TestCode gen; + gen.ReserveCodeSpace(0x1000); + const u8 *codeStart = gen.GetCodePtr(); + gen.Generate(); + + u32 retval = CallPtr(gen.testCodePtr); + ILOG("Returned %d", retval); + // ILOG("ARM emitter test 1 passed if %f == 3.0! retval = %08x", abc[32 + 31], retval); + /* + ILOG("x: %08x %08x %08x %08x", x[0], x[1], x[2], x[3]); + ILOG("y: %08x %08x %08x %08x", y[0], y[1], y[2], y[3]); + ILOG("z: %08x %08x %08x %08x", z[0], z[1], z[2], z[3]); + ILOG("c: %f %f %f %f", c[0], c[1], c[2], c[3]);*/ + for (int i = 0; i < 6; i++) { + ILOG("--------------------------"); + } + // DisassembleArm(codeStart, gen.GetCodePtr()-codeStart); +} diff --git a/android/jni/Arm64EmitterTest.h b/android/jni/Arm64EmitterTest.h new file mode 100644 index 0000000000..e307a3a104 --- /dev/null +++ b/android/jni/Arm64EmitterTest.h @@ -0,0 +1,5 @@ +#pragma once + +// Just a test of the ARM64 emitter, playing around with running some code without having the whole emu around. + +void Arm64EmitterTest(); \ No newline at end of file