summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar bunnei2015-08-12 00:00:44 -0400
committerGravatar bunnei2015-08-15 18:03:25 -0400
commitbd7e691f78d916ed6ae5396b2d646d9b3a053dd7 (patch)
treea20367004f684afeca83e795ce66e62115e8e79d /src/video_core
parentJIT: Support negative address offsets. (diff)
downloadyuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.gz
yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.xz
yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.zip
x64: Refactor to remove fake interfaces and general cleanups.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/CMakeLists.txt10
-rw-r--r--src/video_core/shader/shader.cpp9
-rw-r--r--src/video_core/shader/shader_jit.cpp36
-rw-r--r--src/video_core/shader/shader_jit_fake.cpp91
-rw-r--r--src/video_core/shader/shader_jit_x64.cpp20
-rw-r--r--src/video_core/shader/shader_jit_x64.h (renamed from src/video_core/shader/shader_jit.h)10
6 files changed, 26 insertions, 150 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 544ed0297..221abc160 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -13,7 +13,6 @@ set(SRCS
13 rasterizer.cpp 13 rasterizer.cpp
14 shader/shader.cpp 14 shader/shader.cpp
15 shader/shader_interpreter.cpp 15 shader/shader_interpreter.cpp
16 shader/shader_jit.cpp
17 utils.cpp 16 utils.cpp
18 video_core.cpp 17 video_core.cpp
19 ) 18 )
@@ -39,17 +38,16 @@ set(HEADERS
39 renderer_base.h 38 renderer_base.h
40 shader/shader.h 39 shader/shader.h
41 shader/shader_interpreter.h 40 shader/shader_interpreter.h
42 shader/shader_jit.h
43 utils.h 41 utils.h
44 video_core.h 42 video_core.h
45 ) 43 )
46 44
47if(_M_X86_64) 45if(ARCHITECTURE_X64)
48 set(SRCS ${SRCS} 46 set(SRCS ${SRCS}
49 shader/shader_jit_x64.cpp) 47 shader/shader_jit_x64.cpp)
50else() 48
51 set(SRCS ${SRCS} 49 set(HEADERS ${HEADERS}
52 shader/shader_jit_fake.cpp) 50 shader/shader_jit_x64.h)
53endif() 51endif()
54 52
55create_directory_groups(${SRCS} ${HEADERS}) 53create_directory_groups(${SRCS} ${HEADERS})
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp
index fa1f7cafe..f7459e2ad 100644
--- a/src/video_core/shader/shader.cpp
+++ b/src/video_core/shader/shader.cpp
@@ -15,7 +15,10 @@
15 15
16#include "shader.h" 16#include "shader.h"
17#include "shader_interpreter.h" 17#include "shader_interpreter.h"
18#include "shader_jit.h" 18
19#ifdef ARCHITECTURE_X64
20#include "shader_jit_x64.h"
21#endif // ARCHITECTURE_X64
19 22
20namespace Pica { 23namespace Pica {
21 24
@@ -43,7 +46,7 @@ void Setup(UnitState& state) {
43 jit_shader = jit.Compile(); 46 jit_shader = jit.Compile();
44 shader_map.emplace(cache_key, jit_shader); 47 shader_map.emplace(cache_key, jit_shader);
45 } 48 }
46 } 49#endif // ARCHITECTURE_X64
47} 50}
48 51
49void Shutdown() { 52void Shutdown() {
@@ -92,7 +95,7 @@ OutputVertex Run(UnitState& state, const InputVertex& input, int num_attributes)
92 RunInterpreter(state); 95 RunInterpreter(state);
93#else 96#else
94 RunInterpreter(state); 97 RunInterpreter(state);
95#endif 98#endif // ARCHITECTURE_X64
96 99
97#if PICA_DUMP_SHADERS 100#if PICA_DUMP_SHADERS
98 DebugUtils::DumpShader(setup.program_code.data(), state.debug.max_offset, setup.swizzle_data.data(), 101 DebugUtils::DumpShader(setup.program_code.data(), state.debug.max_offset, setup.swizzle_data.data(),
diff --git a/src/video_core/shader/shader_jit.cpp b/src/video_core/shader/shader_jit.cpp
deleted file mode 100644
index 69fb7f6be..000000000
--- a/src/video_core/shader/shader_jit.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "video_core/pica.h"
6
7#include "shader.h"
8#include "shader_jit.h"
9
10namespace Pica {
11
12namespace Shader {
13
14JitShader::JitShader() : jitted(nullptr) {
15}
16
17void JitShader::DoJit(JitCompiler& jit) {
18 jitted = jit.Compile();
19}
20
21void JitShader::Run(UnitState& state) {
22 if (jitted)
23 jitted(&state);
24}
25
26JitCompiler::JitCompiler() {
27 AllocCodeSpace(1024 * 1024 * 4);
28}
29
30void JitCompiler::Clear() {
31 ClearCodeSpace();
32}
33
34} // namespace Shader
35
36} // namespace Pica
diff --git a/src/video_core/shader/shader_jit_fake.cpp b/src/video_core/shader/shader_jit_fake.cpp
deleted file mode 100644
index e1e79b733..000000000
--- a/src/video_core/shader/shader_jit_fake.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/fake_emitter.h"
6
7#include "video_core/shader/shader.h"
8#include "video_core/shader/shader_jit.h"
9
10namespace Pica {
11
12namespace Shader {
13
14using namespace FakeGen;
15
16void Jit::Comp_ADD(Instruction instr) {
17}
18
19void Jit::Comp_DP3(Instruction instr) {
20}
21
22void Jit::Comp_DP4(Instruction instr) {
23}
24
25void Jit::Comp_MUL(Instruction instr) {
26}
27
28void Jit::Comp_FLR(Instruction instr) {
29}
30
31void Jit::Comp_MAX(Instruction instr) {
32}
33
34void Jit::Comp_MIN(Instruction instr) {
35}
36
37void Jit::Comp_MOVA(Instruction instr) {
38}
39
40void Jit::Comp_MOV(Instruction instr) {
41}
42
43void Jit::Comp_SLTI(Instruction instr) {
44}
45
46void Jit::Comp_RCP(Instruction instr) {
47}
48
49void Jit::Comp_RSQ(Instruction instr) {
50}
51
52void Jit::Comp_NOP(Instruction instr) {
53}
54
55void Jit::Comp_END(Instruction instr) {
56}
57
58void Jit::Comp_CALL(Instruction instr) {
59}
60
61void Jit::Comp_CALLC(Instruction instr) {
62}
63
64void Jit::Comp_CALLU(Instruction instr) {
65}
66
67void Jit::Comp_CMP(Instruction instr) {
68}
69
70void Jit::Comp_MAD(Instruction instr) {
71}
72
73void Jit::Comp_IF(Instruction instr) {
74}
75
76void Jit::Comp_LOOP(Instruction instr) {
77}
78
79void Jit::Comp_JMP(Instruction instr) {
80}
81
82void Jit::Comp_NextInstr(unsigned* offset) {
83}
84
85CompiledShader Jit::Compile() {
86 return nullptr;
87}
88
89} // namespace Shader
90
91} // namespace Pica
diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp
index d69f3a549..1e20a06a7 100644
--- a/src/video_core/shader/shader_jit_x64.cpp
+++ b/src/video_core/shader/shader_jit_x64.cpp
@@ -4,12 +4,13 @@
4 4
5#include <smmintrin.h> 5#include <smmintrin.h>
6 6
7#include "common/abi.h"
8#include "common/cpu_detect.h" 7#include "common/cpu_detect.h"
9#include "common/x64_emitter.h" 8
9#include "common/x64/abi.h"
10#include "common/x64/emitter.h"
10 11
11#include "shader.h" 12#include "shader.h"
12#include "shader_jit.h" 13#include "shader_jit_x64.h"
13 14
14namespace Pica { 15namespace Pica {
15 16
@@ -134,7 +135,7 @@ static const u8 NO_DEST_REG_MASK = 0xf;
134 */ 135 */
135void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) { 136void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) {
136 X64Reg src_ptr; 137 X64Reg src_ptr;
137 std::size_t src_offset; 138 int src_offset;
138 139
139 if (src_reg.GetRegisterType() == RegisterType::FloatUniform) { 140 if (src_reg.GetRegisterType() == RegisterType::FloatUniform) {
140 src_ptr = UNIFORMS; 141 src_ptr = UNIFORMS;
@@ -451,7 +452,6 @@ void JitCompiler::Compile_NOP(Instruction instr) {
451void JitCompiler::Compile_END(Instruction instr) { 452void JitCompiler::Compile_END(Instruction instr) {
452 ABI_PopAllCalleeSavedRegsAndAdjustStack(); 453 ABI_PopAllCalleeSavedRegsAndAdjustStack();
453 RET(); 454 RET();
454 done = true;
455} 455}
456 456
457void JitCompiler::Compile_CALL(Instruction instr) { 457void JitCompiler::Compile_CALL(Instruction instr) {
@@ -655,7 +655,7 @@ CompiledShader* JitCompiler::Compile() {
655 MOVAPS(NEGBIT, MDisp(RAX, 0)); 655 MOVAPS(NEGBIT, MDisp(RAX, 0));
656 656
657 looping = false; 657 looping = false;
658 done = false; 658
659 while (offset < g_state.vs.program_code.size()) { 659 while (offset < g_state.vs.program_code.size()) {
660 Compile_NextInstr(&offset); 660 Compile_NextInstr(&offset);
661 } 661 }
@@ -663,6 +663,14 @@ CompiledShader* JitCompiler::Compile() {
663 return (CompiledShader*)start; 663 return (CompiledShader*)start;
664} 664}
665 665
666JitCompiler::JitCompiler() {
667 AllocCodeSpace(1024 * 1024 * 4);
668}
669
670void JitCompiler::Clear() {
671 ClearCodeSpace();
672}
673
666} // namespace Shader 674} // namespace Shader
667 675
668} // namespace Pica 676} // namespace Pica
diff --git a/src/video_core/shader/shader_jit.h b/src/video_core/shader/shader_jit_x64.h
index f05b64a92..719a24210 100644
--- a/src/video_core/shader/shader_jit.h
+++ b/src/video_core/shader/shader_jit_x64.h
@@ -6,11 +6,7 @@
6 6
7#include <nihstro/shader_bytecode.h> 7#include <nihstro/shader_bytecode.h>
8 8
9#if defined(_M_X86_64) 9#include "common/x64/emitter.h"
10#include "common/x64_emitter.h"
11#else
12#include "common/fake_emitter.h"
13#endif
14 10
15#include "video_core/pica.h" 11#include "video_core/pica.h"
16 12
@@ -65,18 +61,16 @@ private:
65 void Compile_Block(unsigned stop); 61 void Compile_Block(unsigned stop);
66 void Compile_NextInstr(unsigned* offset); 62 void Compile_NextInstr(unsigned* offset);
67 63
68#if defined(_M_X86_64)
69 void Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, Gen::X64Reg dest); 64 void Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, Gen::X64Reg dest);
70 void Compile_DestEnable(Instruction instr, Gen::X64Reg dest); 65 void Compile_DestEnable(Instruction instr, Gen::X64Reg dest);
71 66
72 void Compile_EvaluateCondition(Instruction instr); 67 void Compile_EvaluateCondition(Instruction instr);
73 void Compile_UniformCondition(Instruction instr); 68 void Compile_UniformCondition(Instruction instr);
74#endif
75 69
76 /// Pointer to the variable that stores the current Pica code offset. Used to handle nested code blocks. 70 /// Pointer to the variable that stores the current Pica code offset. Used to handle nested code blocks.
77 unsigned* offset_ptr = nullptr; 71 unsigned* offset_ptr = nullptr;
78 72
79 bool done = false; 73 /// Set to true if currently in a loop, used to check for the existence of nested loops
80 bool looping = false; 74 bool looping = false;
81}; 75};
82 76