summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/shader/shader_interpreter.cpp36
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp22
-rw-r--r--src/video_core/shader/shader_jit_x64.h2
3 files changed, 58 insertions, 2 deletions
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp
index e14de0768..646171a19 100644
--- a/src/video_core/shader/shader_interpreter.cpp
+++ b/src/video_core/shader/shader_interpreter.cpp
@@ -334,6 +334,42 @@ void RunInterpreter(UnitState<Debug>& state) {
334 Record<DebugDataRecord::CMP_RESULT>(state.debug, iteration, state.conditional_code); 334 Record<DebugDataRecord::CMP_RESULT>(state.debug, iteration, state.conditional_code);
335 break; 335 break;
336 336
337 case OpCode::Id::EX2:
338 {
339 Record<DebugDataRecord::SRC1>(state.debug, iteration, src1);
340 Record<DebugDataRecord::DEST_IN>(state.debug, iteration, dest);
341
342 // EX2 only takes first component exp2 and writes it to all dest components
343 float24 ex2_res = float24::FromFloat32(std::exp2(src1[0].ToFloat32()));
344 for (int i = 0; i < 4; ++i) {
345 if (!swizzle.DestComponentEnabled(i))
346 continue;
347
348 dest[i] = ex2_res;
349 }
350
351 Record<DebugDataRecord::DEST_OUT>(state.debug, iteration, dest);
352 break;
353 }
354
355 case OpCode::Id::LG2:
356 {
357 Record<DebugDataRecord::SRC1>(state.debug, iteration, src1);
358 Record<DebugDataRecord::DEST_IN>(state.debug, iteration, dest);
359
360 // LG2 only takes the first component log2 and writes it to all dest components
361 float24 lg2_res = float24::FromFloat32(std::log2(src1[0].ToFloat32()));
362 for (int i = 0; i < 4; ++i) {
363 if (!swizzle.DestComponentEnabled(i))
364 continue;
365
366 dest[i] = lg2_res;
367 }
368
369 Record<DebugDataRecord::DEST_OUT>(state.debug, iteration, dest);
370 break;
371 }
372
337 default: 373 default:
338 LOG_ERROR(HW_GPU, "Unhandled arithmetic instruction: 0x%02x (%s): 0x%08x", 374 LOG_ERROR(HW_GPU, "Unhandled arithmetic instruction: 0x%02x (%s): 0x%08x",
339 (int)instr.opcode.Value().EffectiveOpCode(), instr.opcode.Value().GetInfo().name, instr.hex); 375 (int)instr.opcode.Value().EffectiveOpCode(), instr.opcode.Value().GetInfo().name, instr.hex);
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index 836942c6b..93f608584 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -25,8 +25,8 @@ const JitFunction instr_table[64] = {
25 &JitCompiler::Compile_DP4, // dp4 25 &JitCompiler::Compile_DP4, // dp4
26 nullptr, // dph 26 nullptr, // dph
27 nullptr, // unknown 27 nullptr, // unknown
28 nullptr, // ex2 28 &JitCompiler::Compile_EX2, // ex2
29 nullptr, // lg2 29 &JitCompiler::Compile_LG2, // lg2
30 nullptr, // unknown 30 nullptr, // unknown
31 &JitCompiler::Compile_MUL, // mul 31 &JitCompiler::Compile_MUL, // mul
32 nullptr, // lge 32 nullptr, // lge
@@ -331,6 +331,24 @@ void JitCompiler::Compile_DP4(Instruction instr) {
331 Compile_DestEnable(instr, SRC1); 331 Compile_DestEnable(instr, SRC1);
332} 332}
333 333
334void JitCompiler::Compile_EX2(Instruction instr) {
335 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
336 MOVSS(XMM0, R(SRC1));
337 ABI_CallFunction(reinterpret_cast<const void*>(exp2f));
338 SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(0, 0, 0, 0));
339 MOVAPS(SRC1, R(XMM0));
340 Compile_DestEnable(instr, SRC1);
341}
342
343void JitCompiler::Compile_LG2(Instruction instr) {
344 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
345 MOVSS(XMM0, R(SRC1));
346 ABI_CallFunction(reinterpret_cast<const void*>(log2f));
347 SHUFPS(XMM0, R(XMM0), _MM_SHUFFLE(0, 0, 0, 0));
348 MOVAPS(SRC1, R(XMM0));
349 Compile_DestEnable(instr, SRC1);
350}
351
334void JitCompiler::Compile_MUL(Instruction instr) { 352void JitCompiler::Compile_MUL(Instruction instr) {
335 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 353 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
336 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 354 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index b88f2a0d2..104f9f466 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -37,6 +37,8 @@ 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_EX2(Instruction instr);
41 void Compile_LG2(Instruction instr);
40 void Compile_MUL(Instruction instr); 42 void Compile_MUL(Instruction instr);
41 void Compile_FLR(Instruction instr); 43 void Compile_FLR(Instruction instr);
42 void Compile_MAX(Instruction instr); 44 void Compile_MAX(Instruction instr);