summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar aroulin2015-08-21 12:49:21 +0200
committerGravatar aroulin2015-08-22 11:09:53 +0200
commit2f1514b90430ccb2d74b3fcaca435c692f159e5d (patch)
tree4bfc9d867d893c2eaa55bd6344abff5c3e34e000 /src
parentShader: implement DPH/DPHI in interpreter (diff)
downloadyuzu-2f1514b90430ccb2d74b3fcaca435c692f159e5d.tar.gz
yuzu-2f1514b90430ccb2d74b3fcaca435c692f159e5d.tar.xz
yuzu-2f1514b90430ccb2d74b3fcaca435c692f159e5d.zip
Shader: implement DPH/DPHI in JIT
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp37
-rw-r--r--src/video_core/shader/shader_jit_x64.h1
2 files changed, 36 insertions, 2 deletions
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index a1bdd8456..366be3901 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -23,7 +23,7 @@ const JitFunction instr_table[64] = {
23 &JitCompiler::Compile_ADD, // add 23 &JitCompiler::Compile_ADD, // add
24 &JitCompiler::Compile_DP3, // dp3 24 &JitCompiler::Compile_DP3, // dp3
25 &JitCompiler::Compile_DP4, // dp4 25 &JitCompiler::Compile_DP4, // dp4
26 nullptr, // dph 26 &JitCompiler::Compile_DPH, // dph
27 nullptr, // unknown 27 nullptr, // unknown
28 &JitCompiler::Compile_EX2, // ex2 28 &JitCompiler::Compile_EX2, // ex2
29 &JitCompiler::Compile_LG2, // lg2 29 &JitCompiler::Compile_LG2, // lg2
@@ -44,7 +44,7 @@ const JitFunction instr_table[64] = {
44 nullptr, // unknown 44 nullptr, // unknown
45 nullptr, // unknown 45 nullptr, // unknown
46 nullptr, // unknown 46 nullptr, // unknown
47 nullptr, // dphi 47 &JitCompiler::Compile_DPH, // dphi
48 nullptr, // unknown 48 nullptr, // unknown
49 &JitCompiler::Compile_SGE, // sgei 49 &JitCompiler::Compile_SGE, // sgei
50 &JitCompiler::Compile_SLT, // slti 50 &JitCompiler::Compile_SLT, // slti
@@ -347,6 +347,39 @@ void JitCompiler::Compile_DP4(Instruction instr) {
347 Compile_DestEnable(instr, SRC1); 347 Compile_DestEnable(instr, SRC1);
348} 348}
349 349
350void JitCompiler::Compile_DPH(Instruction instr) {
351 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::DPHI) {
352 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1);
353 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2);
354 } else {
355 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
356 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
357 }
358
359 if (Common::GetCPUCaps().sse4_1) {
360 // Set 4th component to 1.0
361 BLENDPS(SRC1, R(ONE), 0x8); // 0b1000
362 DPPS(SRC1, R(SRC2), 0xff);
363 } else {
364 // Reverse to set the 4th component to 1.0
365 SHUFPS(SRC1, R(SRC1), _MM_SHUFFLE(0, 1, 2, 3));
366 MOVSS(SRC1, R(ONE));
367 SHUFPS(SRC1, R(SRC1), _MM_SHUFFLE(0, 1, 2, 3));
368
369 MULPS(SRC1, R(SRC2));
370
371 MOVAPS(SRC2, R(SRC1));
372 SHUFPS(SRC1, R(SRC1), _MM_SHUFFLE(2, 3, 0, 1)); // XYZW -> ZWXY
373 ADDPS(SRC1, R(SRC2));
374
375 MOVAPS(SRC2, R(SRC1));
376 SHUFPS(SRC1, R(SRC1), _MM_SHUFFLE(0, 1, 2, 3)); // XYZW -> WZYX
377 ADDPS(SRC1, R(SRC2));
378 }
379
380 Compile_DestEnable(instr, SRC1);
381}
382
350void JitCompiler::Compile_EX2(Instruction instr) { 383void JitCompiler::Compile_EX2(Instruction instr) {
351 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 384 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
352 MOVSS(XMM0, R(SRC1)); 385 MOVSS(XMM0, R(SRC1));
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index b2aa5293c..fbe19fe93 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -37,6 +37,7 @@ public:
37 void Compile_ADD(Instruction instr); 37 void Compile_ADD(Instruction instr);
38 void Compile_DP3(Instruction instr); 38 void Compile_DP3(Instruction instr);
39 void Compile_DP4(Instruction instr); 39 void Compile_DP4(Instruction instr);
40 void Compile_DPH(Instruction instr);
40 void Compile_EX2(Instruction instr); 41 void Compile_EX2(Instruction instr);
41 void Compile_LG2(Instruction instr); 42 void Compile_LG2(Instruction instr);
42 void Compile_MUL(Instruction instr); 43 void Compile_MUL(Instruction instr);