summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2016-04-12 23:34:03 -0400
committerGravatar bunnei2016-04-13 23:04:53 -0400
commit3f623b2561eb829b5c9c3855cb24a612b12f7d6f (patch)
tree188dcb1e4b059daefcd466f9ea6dab67bc43c009 /src
parentshader_jit_x64: Free memory that's no longer needed after compilation. (diff)
downloadyuzu-3f623b2561eb829b5c9c3855cb24a612b12f7d6f.tar.gz
yuzu-3f623b2561eb829b5c9c3855cb24a612b12f7d6f.tar.xz
yuzu-3f623b2561eb829b5c9c3855cb24a612b12f7d6f.zip
shader_jit_x64.cpp: Rename JitCompiler to JitShader.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/shader.cpp6
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp174
-rw-r--r--src/video_core/shader/shader_jit_x64.h4
3 files changed, 92 insertions, 92 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp
index 5214864ec..75301accd 100644
--- a/src/video_core/shader/shader.cpp
+++ b/src/video_core/shader/shader.cpp
@@ -28,8 +28,8 @@ namespace Pica {
28namespace Shader { 28namespace Shader {
29 29
30#ifdef ARCHITECTURE_x86_64 30#ifdef ARCHITECTURE_x86_64
31static std::unordered_map<u64, std::unique_ptr<JitCompiler>> shader_map; 31static std::unordered_map<u64, std::unique_ptr<JitShader>> shader_map;
32static const JitCompiler* jit_shader; 32static const JitShader* jit_shader;
33#endif // ARCHITECTURE_x86_64 33#endif // ARCHITECTURE_x86_64
34 34
35void Setup() { 35void Setup() {
@@ -42,7 +42,7 @@ void Setup() {
42 if (iter != shader_map.end()) { 42 if (iter != shader_map.end()) {
43 jit_shader = iter->second.get(); 43 jit_shader = iter->second.get();
44 } else { 44 } else {
45 auto shader = std::make_unique<JitCompiler>(); 45 auto shader = std::make_unique<JitShader>();
46 shader->Compile(); 46 shader->Compile();
47 jit_shader = shader.get(); 47 jit_shader = shader.get();
48 shader_map[cache_key] = std::move(shader); 48 shader_map[cache_key] = std::move(shader);
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index 773542283..9369d2fe5 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -20,73 +20,73 @@ namespace Shader {
20 20
21using namespace Gen; 21using namespace Gen;
22 22
23typedef void (JitCompiler::*JitFunction)(Instruction instr); 23typedef void (JitShader::*JitFunction)(Instruction instr);
24 24
25const JitFunction instr_table[64] = { 25const JitFunction instr_table[64] = {
26 &JitCompiler::Compile_ADD, // add 26 &JitShader::Compile_ADD, // add
27 &JitCompiler::Compile_DP3, // dp3 27 &JitShader::Compile_DP3, // dp3
28 &JitCompiler::Compile_DP4, // dp4 28 &JitShader::Compile_DP4, // dp4
29 &JitCompiler::Compile_DPH, // dph 29 &JitShader::Compile_DPH, // dph
30 nullptr, // unknown 30 nullptr, // unknown
31 &JitCompiler::Compile_EX2, // ex2 31 &JitShader::Compile_EX2, // ex2
32 &JitCompiler::Compile_LG2, // lg2 32 &JitShader::Compile_LG2, // lg2
33 nullptr, // unknown 33 nullptr, // unknown
34 &JitCompiler::Compile_MUL, // mul 34 &JitShader::Compile_MUL, // mul
35 &JitCompiler::Compile_SGE, // sge 35 &JitShader::Compile_SGE, // sge
36 &JitCompiler::Compile_SLT, // slt 36 &JitShader::Compile_SLT, // slt
37 &JitCompiler::Compile_FLR, // flr 37 &JitShader::Compile_FLR, // flr
38 &JitCompiler::Compile_MAX, // max 38 &JitShader::Compile_MAX, // max
39 &JitCompiler::Compile_MIN, // min 39 &JitShader::Compile_MIN, // min
40 &JitCompiler::Compile_RCP, // rcp 40 &JitShader::Compile_RCP, // rcp
41 &JitCompiler::Compile_RSQ, // rsq 41 &JitShader::Compile_RSQ, // rsq
42 nullptr, // unknown 42 nullptr, // unknown
43 nullptr, // unknown 43 nullptr, // unknown
44 &JitCompiler::Compile_MOVA, // mova 44 &JitShader::Compile_MOVA, // mova
45 &JitCompiler::Compile_MOV, // mov 45 &JitShader::Compile_MOV, // mov
46 nullptr, // unknown 46 nullptr, // unknown
47 nullptr, // unknown 47 nullptr, // unknown
48 nullptr, // unknown 48 nullptr, // unknown
49 nullptr, // unknown 49 nullptr, // unknown
50 &JitCompiler::Compile_DPH, // dphi 50 &JitShader::Compile_DPH, // dphi
51 nullptr, // unknown 51 nullptr, // unknown
52 &JitCompiler::Compile_SGE, // sgei 52 &JitShader::Compile_SGE, // sgei
53 &JitCompiler::Compile_SLT, // slti 53 &JitShader::Compile_SLT, // slti
54 nullptr, // unknown 54 nullptr, // unknown
55 nullptr, // unknown 55 nullptr, // unknown
56 nullptr, // unknown 56 nullptr, // unknown
57 nullptr, // unknown 57 nullptr, // unknown
58 nullptr, // unknown 58 nullptr, // unknown
59 &JitCompiler::Compile_NOP, // nop 59 &JitShader::Compile_NOP, // nop
60 &JitCompiler::Compile_END, // end 60 &JitShader::Compile_END, // end
61 nullptr, // break 61 nullptr, // break
62 &JitCompiler::Compile_CALL, // call 62 &JitShader::Compile_CALL, // call
63 &JitCompiler::Compile_CALLC, // callc 63 &JitShader::Compile_CALLC, // callc
64 &JitCompiler::Compile_CALLU, // callu 64 &JitShader::Compile_CALLU, // callu
65 &JitCompiler::Compile_IF, // ifu 65 &JitShader::Compile_IF, // ifu
66 &JitCompiler::Compile_IF, // ifc 66 &JitShader::Compile_IF, // ifc
67 &JitCompiler::Compile_LOOP, // loop 67 &JitShader::Compile_LOOP, // loop
68 nullptr, // emit 68 nullptr, // emit
69 nullptr, // sete 69 nullptr, // sete
70 &JitCompiler::Compile_JMP, // jmpc 70 &JitShader::Compile_JMP, // jmpc
71 &JitCompiler::Compile_JMP, // jmpu 71 &JitShader::Compile_JMP, // jmpu
72 &JitCompiler::Compile_CMP, // cmp 72 &JitShader::Compile_CMP, // cmp
73 &JitCompiler::Compile_CMP, // cmp 73 &JitShader::Compile_CMP, // cmp
74 &JitCompiler::Compile_MAD, // madi 74 &JitShader::Compile_MAD, // madi
75 &JitCompiler::Compile_MAD, // madi 75 &JitShader::Compile_MAD, // madi
76 &JitCompiler::Compile_MAD, // madi 76 &JitShader::Compile_MAD, // madi
77 &JitCompiler::Compile_MAD, // madi 77 &JitShader::Compile_MAD, // madi
78 &JitCompiler::Compile_MAD, // madi 78 &JitShader::Compile_MAD, // madi
79 &JitCompiler::Compile_MAD, // madi 79 &JitShader::Compile_MAD, // madi
80 &JitCompiler::Compile_MAD, // madi 80 &JitShader::Compile_MAD, // madi
81 &JitCompiler::Compile_MAD, // madi 81 &JitShader::Compile_MAD, // madi
82 &JitCompiler::Compile_MAD, // mad 82 &JitShader::Compile_MAD, // mad
83 &JitCompiler::Compile_MAD, // mad 83 &JitShader::Compile_MAD, // mad
84 &JitCompiler::Compile_MAD, // mad 84 &JitShader::Compile_MAD, // mad
85 &JitCompiler::Compile_MAD, // mad 85 &JitShader::Compile_MAD, // mad
86 &JitCompiler::Compile_MAD, // mad 86 &JitShader::Compile_MAD, // mad
87 &JitCompiler::Compile_MAD, // mad 87 &JitShader::Compile_MAD, // mad
88 &JitCompiler::Compile_MAD, // mad 88 &JitShader::Compile_MAD, // mad
89 &JitCompiler::Compile_MAD, // mad 89 &JitShader::Compile_MAD, // mad
90}; 90};
91 91
92// The following is used to alias some commonly used registers. Generally, RAX-RDX and XMM0-XMM3 can 92// The following is used to alias some commonly used registers. Generally, RAX-RDX and XMM0-XMM3 can
@@ -151,7 +151,7 @@ static void LogCritical(const char* msg) {
151 LOG_CRITICAL(HW_GPU, msg); 151 LOG_CRITICAL(HW_GPU, msg);
152} 152}
153 153
154void JitCompiler::RuntimeAssert(bool condition, const char* msg) { 154void JitShader::RuntimeAssert(bool condition, const char* msg) {
155 if (!condition) { 155 if (!condition) {
156 ABI_CallFunctionP(reinterpret_cast<const void*>(LogCritical), const_cast<char*>(msg)); 156 ABI_CallFunctionP(reinterpret_cast<const void*>(LogCritical), const_cast<char*>(msg));
157 } 157 }
@@ -164,7 +164,7 @@ void JitCompiler::RuntimeAssert(bool condition, const char* msg) {
164 * @param src_reg SourceRegister object corresponding to the source register to load 164 * @param src_reg SourceRegister object corresponding to the source register to load
165 * @param dest Destination XMM register to store the loaded, swizzled source register 165 * @param dest Destination XMM register to store the loaded, swizzled source register
166 */ 166 */
167void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) { 167void JitShader::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) {
168 X64Reg src_ptr; 168 X64Reg src_ptr;
169 size_t src_offset; 169 size_t src_offset;
170 170
@@ -236,7 +236,7 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source
236 } 236 }
237} 237}
238 238
239void JitCompiler::Compile_DestEnable(Instruction instr,X64Reg src) { 239void JitShader::Compile_DestEnable(Instruction instr,X64Reg src) {
240 DestRegister dest; 240 DestRegister dest;
241 unsigned operand_desc_id; 241 unsigned operand_desc_id;
242 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD || 242 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD ||
@@ -283,7 +283,7 @@ void JitCompiler::Compile_DestEnable(Instruction instr,X64Reg src) {
283 } 283 }
284} 284}
285 285
286void JitCompiler::Compile_SanitizedMul(Gen::X64Reg src1, Gen::X64Reg src2, Gen::X64Reg scratch) { 286void JitShader::Compile_SanitizedMul(Gen::X64Reg src1, Gen::X64Reg src2, Gen::X64Reg scratch) {
287 MOVAPS(scratch, R(src1)); 287 MOVAPS(scratch, R(src1));
288 CMPPS(scratch, R(src2), CMP_ORD); 288 CMPPS(scratch, R(src2), CMP_ORD);
289 289
@@ -296,7 +296,7 @@ void JitCompiler::Compile_SanitizedMul(Gen::X64Reg src1, Gen::X64Reg src2, Gen::
296 ANDPS(src1, R(scratch)); 296 ANDPS(src1, R(scratch));
297} 297}
298 298
299void JitCompiler::Compile_EvaluateCondition(Instruction instr) { 299void JitShader::Compile_EvaluateCondition(Instruction instr) {
300 // Note: NXOR is used below to check for equality 300 // Note: NXOR is used below to check for equality
301 switch (instr.flow_control.op) { 301 switch (instr.flow_control.op) {
302 case Instruction::FlowControlType::Or: 302 case Instruction::FlowControlType::Or:
@@ -327,23 +327,23 @@ void JitCompiler::Compile_EvaluateCondition(Instruction instr) {
327 } 327 }
328} 328}
329 329
330void JitCompiler::Compile_UniformCondition(Instruction instr) { 330void JitShader::Compile_UniformCondition(Instruction instr) {
331 int offset = offsetof(decltype(g_state.vs.uniforms), b) + (instr.flow_control.bool_uniform_id * sizeof(bool)); 331 int offset = offsetof(decltype(g_state.vs.uniforms), b) + (instr.flow_control.bool_uniform_id * sizeof(bool));
332 CMP(sizeof(bool) * 8, MDisp(UNIFORMS, offset), Imm8(0)); 332 CMP(sizeof(bool) * 8, MDisp(UNIFORMS, offset), Imm8(0));
333} 333}
334 334
335BitSet32 JitCompiler::PersistentCallerSavedRegs() { 335BitSet32 JitShader::PersistentCallerSavedRegs() {
336 return persistent_regs & ABI_ALL_CALLER_SAVED; 336 return persistent_regs & ABI_ALL_CALLER_SAVED;
337} 337}
338 338
339void JitCompiler::Compile_ADD(Instruction instr) { 339void JitShader::Compile_ADD(Instruction instr) {
340 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 340 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
341 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 341 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
342 ADDPS(SRC1, R(SRC2)); 342 ADDPS(SRC1, R(SRC2));
343 Compile_DestEnable(instr, SRC1); 343 Compile_DestEnable(instr, SRC1);
344} 344}
345 345
346void JitCompiler::Compile_DP3(Instruction instr) { 346void JitShader::Compile_DP3(Instruction instr) {
347 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 347 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
348 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 348 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
349 349
@@ -362,7 +362,7 @@ void JitCompiler::Compile_DP3(Instruction instr) {
362 Compile_DestEnable(instr, SRC1); 362 Compile_DestEnable(instr, SRC1);
363} 363}
364 364
365void JitCompiler::Compile_DP4(Instruction instr) { 365void JitShader::Compile_DP4(Instruction instr) {
366 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 366 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
367 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 367 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
368 368
@@ -379,7 +379,7 @@ void JitCompiler::Compile_DP4(Instruction instr) {
379 Compile_DestEnable(instr, SRC1); 379 Compile_DestEnable(instr, SRC1);
380} 380}
381 381
382void JitCompiler::Compile_DPH(Instruction instr) { 382void JitShader::Compile_DPH(Instruction instr) {
383 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::DPHI) { 383 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::DPHI) {
384 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1); 384 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1);
385 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2); 385 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2);
@@ -411,7 +411,7 @@ void JitCompiler::Compile_DPH(Instruction instr) {
411 Compile_DestEnable(instr, SRC1); 411 Compile_DestEnable(instr, SRC1);
412} 412}
413 413
414void JitCompiler::Compile_EX2(Instruction instr) { 414void JitShader::Compile_EX2(Instruction instr) {
415 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 415 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
416 MOVSS(XMM0, R(SRC1)); 416 MOVSS(XMM0, R(SRC1));
417 417
@@ -424,7 +424,7 @@ void JitCompiler::Compile_EX2(Instruction instr) {
424 Compile_DestEnable(instr, SRC1); 424 Compile_DestEnable(instr, SRC1);
425} 425}
426 426
427void JitCompiler::Compile_LG2(Instruction instr) { 427void JitShader::Compile_LG2(Instruction instr) {
428 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 428 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
429 MOVSS(XMM0, R(SRC1)); 429 MOVSS(XMM0, R(SRC1));
430 430
@@ -437,14 +437,14 @@ void JitCompiler::Compile_LG2(Instruction instr) {
437 Compile_DestEnable(instr, SRC1); 437 Compile_DestEnable(instr, SRC1);
438} 438}
439 439
440void JitCompiler::Compile_MUL(Instruction instr) { 440void JitShader::Compile_MUL(Instruction instr) {
441 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 441 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
442 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 442 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
443 Compile_SanitizedMul(SRC1, SRC2, SCRATCH); 443 Compile_SanitizedMul(SRC1, SRC2, SCRATCH);
444 Compile_DestEnable(instr, SRC1); 444 Compile_DestEnable(instr, SRC1);
445} 445}
446 446
447void JitCompiler::Compile_SGE(Instruction instr) { 447void JitShader::Compile_SGE(Instruction instr) {
448 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::SGEI) { 448 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::SGEI) {
449 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1); 449 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1);
450 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2); 450 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2);
@@ -459,7 +459,7 @@ void JitCompiler::Compile_SGE(Instruction instr) {
459 Compile_DestEnable(instr, SRC2); 459 Compile_DestEnable(instr, SRC2);
460} 460}
461 461
462void JitCompiler::Compile_SLT(Instruction instr) { 462void JitShader::Compile_SLT(Instruction instr) {
463 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::SLTI) { 463 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::SLTI) {
464 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1); 464 Compile_SwizzleSrc(instr, 1, instr.common.src1i, SRC1);
465 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2); 465 Compile_SwizzleSrc(instr, 2, instr.common.src2i, SRC2);
@@ -474,7 +474,7 @@ void JitCompiler::Compile_SLT(Instruction instr) {
474 Compile_DestEnable(instr, SRC1); 474 Compile_DestEnable(instr, SRC1);
475} 475}
476 476
477void JitCompiler::Compile_FLR(Instruction instr) { 477void JitShader::Compile_FLR(Instruction instr) {
478 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 478 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
479 479
480 if (Common::GetCPUCaps().sse4_1) { 480 if (Common::GetCPUCaps().sse4_1) {
@@ -487,7 +487,7 @@ void JitCompiler::Compile_FLR(Instruction instr) {
487 Compile_DestEnable(instr, SRC1); 487 Compile_DestEnable(instr, SRC1);
488} 488}
489 489
490void JitCompiler::Compile_MAX(Instruction instr) { 490void JitShader::Compile_MAX(Instruction instr) {
491 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 491 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
492 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 492 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
493 // SSE semantics match PICA200 ones: In case of NaN, SRC2 is returned. 493 // SSE semantics match PICA200 ones: In case of NaN, SRC2 is returned.
@@ -495,7 +495,7 @@ void JitCompiler::Compile_MAX(Instruction instr) {
495 Compile_DestEnable(instr, SRC1); 495 Compile_DestEnable(instr, SRC1);
496} 496}
497 497
498void JitCompiler::Compile_MIN(Instruction instr) { 498void JitShader::Compile_MIN(Instruction instr) {
499 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 499 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
500 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2); 500 Compile_SwizzleSrc(instr, 2, instr.common.src2, SRC2);
501 // SSE semantics match PICA200 ones: In case of NaN, SRC2 is returned. 501 // SSE semantics match PICA200 ones: In case of NaN, SRC2 is returned.
@@ -503,7 +503,7 @@ void JitCompiler::Compile_MIN(Instruction instr) {
503 Compile_DestEnable(instr, SRC1); 503 Compile_DestEnable(instr, SRC1);
504} 504}
505 505
506void JitCompiler::Compile_MOVA(Instruction instr) { 506void JitShader::Compile_MOVA(Instruction instr) {
507 SwizzlePattern swiz = { g_state.vs.swizzle_data[instr.common.operand_desc_id] }; 507 SwizzlePattern swiz = { g_state.vs.swizzle_data[instr.common.operand_desc_id] };
508 508
509 if (!swiz.DestComponentEnabled(0) && !swiz.DestComponentEnabled(1)) { 509 if (!swiz.DestComponentEnabled(0) && !swiz.DestComponentEnabled(1)) {
@@ -548,12 +548,12 @@ void JitCompiler::Compile_MOVA(Instruction instr) {
548 } 548 }
549} 549}
550 550
551void JitCompiler::Compile_MOV(Instruction instr) { 551void JitShader::Compile_MOV(Instruction instr) {
552 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 552 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
553 Compile_DestEnable(instr, SRC1); 553 Compile_DestEnable(instr, SRC1);
554} 554}
555 555
556void JitCompiler::Compile_RCP(Instruction instr) { 556void JitShader::Compile_RCP(Instruction instr) {
557 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 557 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
558 558
559 // TODO(bunnei): RCPSS is a pretty rough approximation, this might cause problems if Pica 559 // TODO(bunnei): RCPSS is a pretty rough approximation, this might cause problems if Pica
@@ -564,7 +564,7 @@ void JitCompiler::Compile_RCP(Instruction instr) {
564 Compile_DestEnable(instr, SRC1); 564 Compile_DestEnable(instr, SRC1);
565} 565}
566 566
567void JitCompiler::Compile_RSQ(Instruction instr) { 567void JitShader::Compile_RSQ(Instruction instr) {
568 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1); 568 Compile_SwizzleSrc(instr, 1, instr.common.src1, SRC1);
569 569
570 // TODO(bunnei): RSQRTSS is a pretty rough approximation, this might cause problems if Pica 570 // TODO(bunnei): RSQRTSS is a pretty rough approximation, this might cause problems if Pica
@@ -575,15 +575,15 @@ void JitCompiler::Compile_RSQ(Instruction instr) {
575 Compile_DestEnable(instr, SRC1); 575 Compile_DestEnable(instr, SRC1);
576} 576}
577 577
578void JitCompiler::Compile_NOP(Instruction instr) { 578void JitShader::Compile_NOP(Instruction instr) {
579} 579}
580 580
581void JitCompiler::Compile_END(Instruction instr) { 581void JitShader::Compile_END(Instruction instr) {
582 ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8); 582 ABI_PopRegistersAndAdjustStack(ABI_ALL_CALLEE_SAVED, 8);
583 RET(); 583 RET();
584} 584}
585 585
586void JitCompiler::Compile_CALL(Instruction instr) { 586void JitShader::Compile_CALL(Instruction instr) {
587 // Push offset of the return 587 // Push offset of the return
588 PUSH(64, Imm32(instr.flow_control.dest_offset + instr.flow_control.num_instructions)); 588 PUSH(64, Imm32(instr.flow_control.dest_offset + instr.flow_control.num_instructions));
589 589
@@ -595,21 +595,21 @@ void JitCompiler::Compile_CALL(Instruction instr) {
595 ADD(64, R(RSP), Imm32(8)); 595 ADD(64, R(RSP), Imm32(8));
596} 596}
597 597
598void JitCompiler::Compile_CALLC(Instruction instr) { 598void JitShader::Compile_CALLC(Instruction instr) {
599 Compile_EvaluateCondition(instr); 599 Compile_EvaluateCondition(instr);
600 FixupBranch b = J_CC(CC_Z, true); 600 FixupBranch b = J_CC(CC_Z, true);
601 Compile_CALL(instr); 601 Compile_CALL(instr);
602 SetJumpTarget(b); 602 SetJumpTarget(b);
603} 603}
604 604
605void JitCompiler::Compile_CALLU(Instruction instr) { 605void JitShader::Compile_CALLU(Instruction instr) {
606 Compile_UniformCondition(instr); 606 Compile_UniformCondition(instr);
607 FixupBranch b = J_CC(CC_Z, true); 607 FixupBranch b = J_CC(CC_Z, true);
608 Compile_CALL(instr); 608 Compile_CALL(instr);
609 SetJumpTarget(b); 609 SetJumpTarget(b);
610} 610}
611 611
612void JitCompiler::Compile_CMP(Instruction instr) { 612void JitShader::Compile_CMP(Instruction instr) {
613 using Op = Instruction::Common::CompareOpType::Op; 613 using Op = Instruction::Common::CompareOpType::Op;
614 Op op_x = instr.common.compare_op.x; 614 Op op_x = instr.common.compare_op.x;
615 Op op_y = instr.common.compare_op.y; 615 Op op_y = instr.common.compare_op.y;
@@ -652,7 +652,7 @@ void JitCompiler::Compile_CMP(Instruction instr) {
652 SHR(64, R(COND1), Imm8(63)); 652 SHR(64, R(COND1), Imm8(63));
653} 653}
654 654
655void JitCompiler::Compile_MAD(Instruction instr) { 655void JitShader::Compile_MAD(Instruction instr) {
656 Compile_SwizzleSrc(instr, 1, instr.mad.src1, SRC1); 656 Compile_SwizzleSrc(instr, 1, instr.mad.src1, SRC1);
657 657
658 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI) { 658 if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI) {
@@ -669,7 +669,7 @@ void JitCompiler::Compile_MAD(Instruction instr) {
669 Compile_DestEnable(instr, SRC1); 669 Compile_DestEnable(instr, SRC1);
670} 670}
671 671
672void JitCompiler::Compile_IF(Instruction instr) { 672void JitShader::Compile_IF(Instruction instr) {
673 RuntimeAssert(instr.flow_control.dest_offset >= program_counter, "Backwards if-statements not supported"); 673 RuntimeAssert(instr.flow_control.dest_offset >= program_counter, "Backwards if-statements not supported");
674 674
675 // Evaluate the "IF" condition 675 // Evaluate the "IF" condition
@@ -700,7 +700,7 @@ void JitCompiler::Compile_IF(Instruction instr) {
700 SetJumpTarget(b2); 700 SetJumpTarget(b2);
701} 701}
702 702
703void JitCompiler::Compile_LOOP(Instruction instr) { 703void JitShader::Compile_LOOP(Instruction instr) {
704 RuntimeAssert(instr.flow_control.dest_offset >= program_counter, "Backwards loops not supported"); 704 RuntimeAssert(instr.flow_control.dest_offset >= program_counter, "Backwards loops not supported");
705 RuntimeAssert(!looping, "Nested loops not supported"); 705 RuntimeAssert(!looping, "Nested loops not supported");
706 706
@@ -728,7 +728,7 @@ void JitCompiler::Compile_LOOP(Instruction instr) {
728 looping = false; 728 looping = false;
729} 729}
730 730
731void JitCompiler::Compile_JMP(Instruction instr) { 731void JitShader::Compile_JMP(Instruction instr) {
732 if (instr.opcode.Value() == OpCode::Id::JMPC) 732 if (instr.opcode.Value() == OpCode::Id::JMPC)
733 Compile_EvaluateCondition(instr); 733 Compile_EvaluateCondition(instr);
734 else if (instr.opcode.Value() == OpCode::Id::JMPU) 734 else if (instr.opcode.Value() == OpCode::Id::JMPU)
@@ -743,13 +743,13 @@ void JitCompiler::Compile_JMP(Instruction instr) {
743 fixup_branches.push_back({ b, instr.flow_control.dest_offset }); 743 fixup_branches.push_back({ b, instr.flow_control.dest_offset });
744} 744}
745 745
746void JitCompiler::Compile_Block(unsigned end) { 746void JitShader::Compile_Block(unsigned end) {
747 while (program_counter < end) { 747 while (program_counter < end) {
748 Compile_NextInstr(); 748 Compile_NextInstr();
749 } 749 }
750} 750}
751 751
752void JitCompiler::Compile_Return() { 752void JitShader::Compile_Return() {
753 // Peek return offset on the stack and check if we're at that offset 753 // Peek return offset on the stack and check if we're at that offset
754 MOV(64, R(RAX), MDisp(RSP, 8)); 754 MOV(64, R(RAX), MDisp(RSP, 8));
755 CMP(32, R(RAX), Imm32(program_counter)); 755 CMP(32, R(RAX), Imm32(program_counter));
@@ -760,7 +760,7 @@ void JitCompiler::Compile_Return() {
760 SetJumpTarget(b); 760 SetJumpTarget(b);
761} 761}
762 762
763void JitCompiler::Compile_NextInstr() { 763void JitShader::Compile_NextInstr() {
764 if (std::binary_search(return_offsets.begin(), return_offsets.end(), program_counter)) { 764 if (std::binary_search(return_offsets.begin(), return_offsets.end(), program_counter)) {
765 Compile_Return(); 765 Compile_Return();
766 } 766 }
@@ -783,7 +783,7 @@ void JitCompiler::Compile_NextInstr() {
783 } 783 }
784} 784}
785 785
786void JitCompiler::FindReturnOffsets() { 786void JitShader::FindReturnOffsets() {
787 return_offsets.clear(); 787 return_offsets.clear();
788 788
789 for (size_t offset = 0; offset < g_state.vs.program_code.size(); ++offset) { 789 for (size_t offset = 0; offset < g_state.vs.program_code.size(); ++offset) {
@@ -802,7 +802,7 @@ void JitCompiler::FindReturnOffsets() {
802 std::sort(return_offsets.begin(), return_offsets.end()); 802 std::sort(return_offsets.begin(), return_offsets.end());
803} 803}
804 804
805void JitCompiler::Compile() { 805void JitShader::Compile() {
806 // Reset flow control state 806 // Reset flow control state
807 program = (CompiledShader*)GetCodePtr(); 807 program = (CompiledShader*)GetCodePtr();
808 program_counter = 0; 808 program_counter = 0;
@@ -857,7 +857,7 @@ void JitCompiler::Compile() {
857 LOG_DEBUG(HW_GPU, "Compiled shader size=%d", size); 857 LOG_DEBUG(HW_GPU, "Compiled shader size=%d", size);
858} 858}
859 859
860JitCompiler::JitCompiler() { 860JitShader::JitShader() {
861 AllocCodeSpace(MAX_SHADER_SIZE); 861 AllocCodeSpace(MAX_SHADER_SIZE);
862} 862}
863 863
diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h
index aa5060584..005fbdbe3 100644
--- a/src/video_core/shader/shader_jit_x64.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -29,9 +29,9 @@ constexpr size_t MAX_SHADER_SIZE = 1024 * 64;
29 * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64 29 * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64
30 * code that can be executed on the host machine directly. 30 * code that can be executed on the host machine directly.
31 */ 31 */
32class JitCompiler : public Gen::XCodeBlock { 32class JitShader : public Gen::XCodeBlock {
33public: 33public:
34 JitCompiler(); 34 JitShader();
35 35
36 void Run(void* registers, unsigned offset) const { 36 void Run(void* registers, unsigned offset) const {
37 program(registers, code_ptr[offset]); 37 program(registers, code_ptr[offset]);