summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2015-08-18 22:02:25 -0400
committerGravatar bunnei2015-08-18 22:02:25 -0400
commit3c5ff418ca9a0cf3af0a8eeae76bb111a7af73bc (patch)
tree079c8e9671bf16e9467248598d7d471dcac57943 /src
parentMerge pull request #1037 from aroulin/shader-ex2-lg2 (diff)
parentShader: Save caller-saved registers in JIT before a CALL (diff)
downloadyuzu-3c5ff418ca9a0cf3af0a8eeae76bb111a7af73bc.tar.gz
yuzu-3c5ff418ca9a0cf3af0a8eeae76bb111a7af73bc.tar.xz
yuzu-3c5ff418ca9a0cf3af0a8eeae76bb111a7af73bc.zip
Merge pull request #1047 from aroulin/shader-ex2-lg2
Shader: Save caller-saved registers in JIT before a CALL
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp30
-rw-r--r--src/video_core/shader/shader_jit_x64.h3
2 files changed, 33 insertions, 0 deletions
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index 93f608584..e4b8295b3 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -280,6 +280,22 @@ void JitCompiler::Compile_UniformCondition(Instruction instr) {
280 CMP(sizeof(bool) * 8, MDisp(UNIFORMS, offset), Imm8(0)); 280 CMP(sizeof(bool) * 8, MDisp(UNIFORMS, offset), Imm8(0));
281} 281}
282 282
283void JitCompiler::Compile_PushCallerSavedXMM() {
284#ifndef _WIN32
285 SUB(64, R(RSP), Imm8(2 * 16));
286 MOVUPS(MDisp(RSP, 16), ONE);
287 MOVUPS(MDisp(RSP, 0), NEGBIT);
288#endif
289}
290
291void JitCompiler::Compile_PopCallerSavedXMM() {
292#ifndef _WIN32
293 MOVUPS(NEGBIT, MDisp(RSP, 0));
294 MOVUPS(ONE, MDisp(RSP, 16));
295 ADD(64, R(RSP), Imm8(2 * 16));
296#endif
297}
298
283void JitCompiler::Compile_ADD(Instruction instr) { 299void JitCompiler::Compile_ADD(Instruction instr) {
284 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 300 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
285 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 301 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
@@ -334,7 +350,14 @@ void JitCompiler::Compile_DP4(Instruction instr) {
334void JitCompiler::Compile_EX2(Instruction instr) { 350void JitCompiler::Compile_EX2(Instruction instr) {
335 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 351 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
336 MOVSS(XMM0, R(SRC1)); 352 MOVSS(XMM0, R(SRC1));
353
354 // The following will actually break the stack alignment
355 ABI_PushAllCallerSavedRegsAndAdjustStack();
356 Compile_PushCallerSavedXMM();
337 ABI_CallFunction(reinterpret_cast<const void*>(exp2f)); 357 ABI_CallFunction(reinterpret_cast<const void*>(exp2f));
358 Compile_PopCallerSavedXMM();
359 ABI_PopAllCallerSavedRegsAndAdjustStack();
360
338 SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(0, 0, 0, 0)); 361 SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(0, 0, 0, 0));
339 MOVAPS(SRC1, R(XMM0)); 362 MOVAPS(SRC1, R(XMM0));
340 Compile_DestEnable(instr, SRC1); 363 Compile_DestEnable(instr, SRC1);
@@ -343,7 +366,14 @@ void JitCompiler::Compile_EX2(Instruction instr) {
343void JitCompiler::Compile_LG2(Instruction instr) { 366void JitCompiler::Compile_LG2(Instruction instr) {
344 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 367 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
345 MOVSS(XMM0, R(SRC1)); 368 MOVSS(XMM0, R(SRC1));
369
370 // The following will actually break the stack alignment
371 ABI_PushAllCallerSavedRegsAndAdjustStack();
372 Compile_PushCallerSavedXMM();
346 ABI_CallFunction(reinterpret_cast<const void*>(log2f)); 373 ABI_CallFunction(reinterpret_cast<const void*>(log2f));
374 Compile_PopCallerSavedXMM();
375 ABI_PopAllCallerSavedRegsAndAdjustStack();
376
347 SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(0, 0, 0, 0)); 377 SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(0, 0, 0, 0));
348 MOVAPS(SRC1, R(XMM0)); 378 MOVAPS(SRC1, R(XMM0));
349 Compile_DestEnable(instr, SRC1); 379 Compile_DestEnable(instr, SRC1);
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index 104f9f466..a6ae7fbf1 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -69,6 +69,9 @@ private:
69 void Compile_EvaluateCondition(Instruction instr); 69 void Compile_EvaluateCondition(Instruction instr);
70 void Compile_UniformCondition(Instruction instr); 70 void Compile_UniformCondition(Instruction instr);
71 71
72 void Compile_PushCallerSavedXMM();
73 void Compile_PopCallerSavedXMM();
74
72 /// Pointer to the variable that stores the current Pica code offset. Used to handle nested code blocks. 75 /// Pointer to the variable that stores the current Pica code offset. Used to handle nested code blocks.
73 unsigned* offset_ptr = nullptr; 76 unsigned* offset_ptr = nullptr;
74 77