diff options
| author | 2015-08-19 19:58:49 -0400 | |
|---|---|---|
| committer | 2015-08-19 19:58:49 -0400 | |
| commit | a575399fbcf6f2c29e9dd9835c5014226b453348 (patch) | |
| tree | 9566863df2add30681caa0bc47ee477e6b4ef23a /src | |
| parent | Merge pull request #1045 from LittleWhite-tb/qt-recent-files (diff) | |
| parent | Shader: implement SGE, SGEI and SLT in JIT (diff) | |
| download | yuzu-a575399fbcf6f2c29e9dd9835c5014226b453348.tar.gz yuzu-a575399fbcf6f2c29e9dd9835c5014226b453348.tar.xz yuzu-a575399fbcf6f2c29e9dd9835c5014226b453348.zip | |
Merge pull request #1055 from aroulin/shader-sge-sgei-slt
Shader: Implement SGE, SGEI and SLT in interpreter/JIT
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/shader_interpreter.cpp | 14 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 48 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64.h | 3 |
3 files changed, 50 insertions, 15 deletions
diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 646171a19..063cc38f0 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp | |||
| @@ -278,6 +278,20 @@ void RunInterpreter(UnitState<Debug>& state) { | |||
| 278 | break; | 278 | break; |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | case OpCode::Id::SGE: | ||
| 282 | case OpCode::Id::SGEI: | ||
| 283 | Record<DebugDataRecord::SRC1>(state.debug, iteration, src1); | ||
| 284 | Record<DebugDataRecord::SRC2>(state.debug, iteration, src2); | ||
| 285 | Record<DebugDataRecord::DEST_IN>(state.debug, iteration, dest); | ||
| 286 | for (int i = 0; i < 4; ++i) { | ||
| 287 | if (!swizzle.DestComponentEnabled(i)) | ||
| 288 | continue; | ||
| 289 | |||
| 290 | dest[i] = (src1[i] >= src2[i]) ? float24::FromFloat32(1.0f) : float24::FromFloat32(0.0f); | ||
| 291 | } | ||
| 292 | Record<DebugDataRecord::DEST_OUT>(state.debug, iteration, dest); | ||
| 293 | break; | ||
| 294 | |||
| 281 | case OpCode::Id::SLT: | 295 | case OpCode::Id::SLT: |
| 282 | case OpCode::Id::SLTI: | 296 | case OpCode::Id::SLTI: |
| 283 | Record<DebugDataRecord::SRC1>(state.debug, iteration, src1); | 297 | Record<DebugDataRecord::SRC1>(state.debug, iteration, src1); |
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index e4b8295b3..a1bdd8456 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp | |||
| @@ -29,8 +29,8 @@ const JitFunction instr_table[64] = { | |||
| 29 | &JitCompiler::Compile_LG2, // 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 | &JitCompiler::Compile_SGE, // sge |
| 33 | nullptr, // slt | 33 | &JitCompiler::Compile_SLT, // slt |
| 34 | &JitCompiler::Compile_FLR, // flr | 34 | &JitCompiler::Compile_FLR, // flr |
| 35 | &JitCompiler::Compile_MAX, // max | 35 | &JitCompiler::Compile_MAX, // max |
| 36 | &JitCompiler::Compile_MIN, // min | 36 | &JitCompiler::Compile_MIN, // min |
| @@ -46,8 +46,8 @@ const JitFunction instr_table[64] = { | |||
| 46 | nullptr, // unknown | 46 | nullptr, // unknown |
| 47 | nullptr, // dphi | 47 | nullptr, // dphi |
| 48 | nullptr, // unknown | 48 | nullptr, // unknown |
| 49 | nullptr, // sgei | 49 | &JitCompiler::Compile_SGE, // sgei |
| 50 | &JitCompiler::Compile_SLTI, // slti | 50 | &JitCompiler::Compile_SLT, // slti |
| 51 | nullptr, // unknown | 51 | nullptr, // unknown |
| 52 | nullptr, // unknown | 52 | nullptr, // unknown |
| 53 | nullptr, // unknown | 53 | nullptr, // unknown |
| @@ -386,6 +386,36 @@ void JitCompiler::Compile_MUL(Instruction instr) { | |||
| 386 | Compile_DestEnable(instr, SRC1); | 386 | Compile_DestEnable(instr, SRC1); |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | void JitCompiler::Compile_SGE(Instruction instr) { | ||
| 390 | if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::SGEI) { | ||
| 391 | Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1); | ||
| 392 | Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2); | ||
| 393 | } else { | ||
| 394 | Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); | ||
| 395 | Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); | ||
| 396 | } | ||
| 397 | |||
| 398 | CMPPS(SRC1, R(SRC2), CMP_NLT); | ||
| 399 | ANDPS(SRC1, R(ONE)); | ||
| 400 | |||
| 401 | Compile_DestEnable(instr, SRC1); | ||
| 402 | } | ||
| 403 | |||
| 404 | void JitCompiler::Compile_SLT(Instruction instr) { | ||
| 405 | if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::SLTI) { | ||
| 406 | Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1); | ||
| 407 | Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2); | ||
| 408 | } else { | ||
| 409 | Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); | ||
| 410 | Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); | ||
| 411 | } | ||
| 412 | |||
| 413 | CMPPS(SRC1, R(SRC2), CMP_LT); | ||
| 414 | ANDPS(SRC1, R(ONE)); | ||
| 415 | |||
| 416 | Compile_DestEnable(instr, SRC1); | ||
| 417 | } | ||
| 418 | |||
| 389 | void JitCompiler::Compile_FLR(Instruction instr) { | 419 | void JitCompiler::Compile_FLR(Instruction instr) { |
| 390 | Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); | 420 | Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); |
| 391 | 421 | ||
| @@ -463,16 +493,6 @@ void JitCompiler::Compile_MOV(Instruction instr) { | |||
| 463 | Compile_DestEnable(instr, SRC1); | 493 | Compile_DestEnable(instr, SRC1); |
| 464 | } | 494 | } |
| 465 | 495 | ||
| 466 | void JitCompiler::Compile_SLTI(Instruction instr) { | ||
| 467 | Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1); | ||
| 468 | Compile_SwizzleSrc(instr, 1, instr.common.src2i, SRC2); | ||
| 469 | |||
| 470 | CMPSS(SRC1, R(SRC2), CMP_LT); | ||
| 471 | ANDPS(SRC1, R(ONE)); | ||
| 472 | |||
| 473 | Compile_DestEnable(instr, SRC1); | ||
| 474 | } | ||
| 475 | |||
| 476 | void JitCompiler::Compile_RCP(Instruction instr) { | 496 | void JitCompiler::Compile_RCP(Instruction instr) { |
| 477 | Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); | 497 | Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); |
| 478 | 498 | ||
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index a6ae7fbf1..b2aa5293c 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h | |||
| @@ -40,6 +40,8 @@ public: | |||
| 40 | void Compile_EX2(Instruction instr); | 40 | void Compile_EX2(Instruction instr); |
| 41 | void Compile_LG2(Instruction instr); | 41 | void Compile_LG2(Instruction instr); |
| 42 | void Compile_MUL(Instruction instr); | 42 | void Compile_MUL(Instruction instr); |
| 43 | void Compile_SGE(Instruction instr); | ||
| 44 | void Compile_SLT(Instruction instr); | ||
| 43 | void Compile_FLR(Instruction instr); | 45 | void Compile_FLR(Instruction instr); |
| 44 | void Compile_MAX(Instruction instr); | 46 | void Compile_MAX(Instruction instr); |
| 45 | void Compile_MIN(Instruction instr); | 47 | void Compile_MIN(Instruction instr); |
| @@ -47,7 +49,6 @@ public: | |||
| 47 | void Compile_RSQ(Instruction instr); | 49 | void Compile_RSQ(Instruction instr); |
| 48 | void Compile_MOVA(Instruction instr); | 50 | void Compile_MOVA(Instruction instr); |
| 49 | void Compile_MOV(Instruction instr); | 51 | void Compile_MOV(Instruction instr); |
| 50 | void Compile_SLTI(Instruction instr); | ||
| 51 | void Compile_NOP(Instruction instr); | 52 | void Compile_NOP(Instruction instr); |
| 52 | void Compile_END(Instruction instr); | 53 | void Compile_END(Instruction instr); |
| 53 | void Compile_CALL(Instruction instr); | 54 | void Compile_CALL(Instruction instr); |