diff --git a/GPU/Common/VertexDecoderX86.cpp b/GPU/Common/VertexDecoderX86.cpp index c8329ec1c4..6fb69c99df 100644 --- a/GPU/Common/VertexDecoderX86.cpp +++ b/GPU/Common/VertexDecoderX86.cpp @@ -167,7 +167,7 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec, int BeginWrite(); const u8 *start = this->AlignCode16(); -#ifdef _M_IX86 +#if PPSSPP_ARCH(X86) // Store register values PUSH(ESI); PUSH(EDI); @@ -179,12 +179,20 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec, int MOV(32, R(srcReg), MDisp(ESP, 16 + offset + 0)); MOV(32, R(dstReg), MDisp(ESP, 16 + offset + 4)); MOV(32, R(counterReg), MDisp(ESP, 16 + offset + 8)); + + const uint8_t STACK_FIXED_ALLOC = 64; +#else + // Parameters automatically fall into place. + + // This will align the stack properly to 16 bytes (the call of this function pushed RIP, which is 8 bytes). + const uint8_t STACK_FIXED_ALLOC = 64 + 8; #endif + // Allocate temporary storage on the stack. + SUB(PTRBITS, R(ESP), Imm8(STACK_FIXED_ALLOC)); // Save XMM4/XMM5 which apparently can be problematic? // Actually, if they are, it must be a compiler bug because they SHOULD be ok. // So I won't bother. - SUB(PTRBITS, R(ESP), Imm8(64)); MOVUPS(MDisp(ESP, 0), XMM4); MOVUPS(MDisp(ESP, 16), XMM5); MOVUPS(MDisp(ESP, 32), XMM6); @@ -265,7 +273,7 @@ JittedVertexDecoder VertexDecoderJitCache::Compile(const VertexDecoder &dec, int MOVUPS(XMM5, MDisp(ESP, 16)); MOVUPS(XMM6, MDisp(ESP, 32)); MOVUPS(XMM7, MDisp(ESP, 48)); - ADD(PTRBITS, R(ESP), Imm8(64)); + ADD(PTRBITS, R(ESP), Imm8(STACK_FIXED_ALLOC)); #ifdef _M_IX86 // Restore register values