diff options
author | bunnei <bunneidev@gmail.com> | 2015-08-12 06:00:44 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2015-08-16 00:03:25 +0200 |
commit | bd7e691f78d916ed6ae5396b2d646d9b3a053dd7 (patch) | |
tree | a20367004f684afeca83e795ce66e62115e8e79d /src/video_core/shader | |
parent | JIT: Support negative address offsets. (diff) | |
download | yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.gz yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.bz2 yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.lz yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.xz yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.tar.zst yuzu-bd7e691f78d916ed6ae5396b2d646d9b3a053dd7.zip |
Diffstat (limited to 'src/video_core/shader')
-rw-r--r-- | src/video_core/shader/shader.cpp | 9 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit.cpp | 36 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_fake.cpp | 91 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 20 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_x64.h (renamed from src/video_core/shader/shader_jit.h) | 10 |
5 files changed, 22 insertions, 144 deletions
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 @@ #include "shader.h" #include "shader_interpreter.h" -#include "shader_jit.h" + +#ifdef ARCHITECTURE_X64 +#include "shader_jit_x64.h" +#endif // ARCHITECTURE_X64 namespace Pica { @@ -43,7 +46,7 @@ void Setup(UnitState& state) { jit_shader = jit.Compile(); shader_map.emplace(cache_key, jit_shader); } - } +#endif // ARCHITECTURE_X64 } void Shutdown() { @@ -92,7 +95,7 @@ OutputVertex Run(UnitState& state, const InputVertex& input, int num_attributes) RunInterpreter(state); #else RunInterpreter(state); -#endif +#endif // ARCHITECTURE_X64 #if PICA_DUMP_SHADERS 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 @@ -// Copyright 2015 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "video_core/pica.h" - -#include "shader.h" -#include "shader_jit.h" - -namespace Pica { - -namespace Shader { - -JitShader::JitShader() : jitted(nullptr) { -} - -void JitShader::DoJit(JitCompiler& jit) { - jitted = jit.Compile(); -} - -void JitShader::Run(UnitState& state) { - if (jitted) - jitted(&state); -} - -JitCompiler::JitCompiler() { - AllocCodeSpace(1024 * 1024 * 4); -} - -void JitCompiler::Clear() { - ClearCodeSpace(); -} - -} // namespace Shader - -} // 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 @@ -// Copyright 2015 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include "common/fake_emitter.h" - -#include "video_core/shader/shader.h" -#include "video_core/shader/shader_jit.h" - -namespace Pica { - -namespace Shader { - -using namespace FakeGen; - -void Jit::Comp_ADD(Instruction instr) { -} - -void Jit::Comp_DP3(Instruction instr) { -} - -void Jit::Comp_DP4(Instruction instr) { -} - -void Jit::Comp_MUL(Instruction instr) { -} - -void Jit::Comp_FLR(Instruction instr) { -} - -void Jit::Comp_MAX(Instruction instr) { -} - -void Jit::Comp_MIN(Instruction instr) { -} - -void Jit::Comp_MOVA(Instruction instr) { -} - -void Jit::Comp_MOV(Instruction instr) { -} - -void Jit::Comp_SLTI(Instruction instr) { -} - -void Jit::Comp_RCP(Instruction instr) { -} - -void Jit::Comp_RSQ(Instruction instr) { -} - -void Jit::Comp_NOP(Instruction instr) { -} - -void Jit::Comp_END(Instruction instr) { -} - -void Jit::Comp_CALL(Instruction instr) { -} - -void Jit::Comp_CALLC(Instruction instr) { -} - -void Jit::Comp_CALLU(Instruction instr) { -} - -void Jit::Comp_CMP(Instruction instr) { -} - -void Jit::Comp_MAD(Instruction instr) { -} - -void Jit::Comp_IF(Instruction instr) { -} - -void Jit::Comp_LOOP(Instruction instr) { -} - -void Jit::Comp_JMP(Instruction instr) { -} - -void Jit::Comp_NextInstr(unsigned* offset) { -} - -CompiledShader Jit::Compile() { - return nullptr; -} - -} // namespace Shader - -} // 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 @@ #include <smmintrin.h> -#include "common/abi.h" #include "common/cpu_detect.h" -#include "common/x64_emitter.h" + +#include "common/x64/abi.h" +#include "common/x64/emitter.h" #include "shader.h" -#include "shader_jit.h" +#include "shader_jit_x64.h" namespace Pica { @@ -134,7 +135,7 @@ static const u8 NO_DEST_REG_MASK = 0xf; */ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) { X64Reg src_ptr; - std::size_t src_offset; + int src_offset; if (src_reg.GetRegisterType() == RegisterType::FloatUniform) { src_ptr = UNIFORMS; @@ -451,7 +452,6 @@ void JitCompiler::Compile_NOP(Instruction instr) { void JitCompiler::Compile_END(Instruction instr) { ABI_PopAllCalleeSavedRegsAndAdjustStack(); RET(); - done = true; } void JitCompiler::Compile_CALL(Instruction instr) { @@ -655,7 +655,7 @@ CompiledShader* JitCompiler::Compile() { MOVAPS(NEGBIT, MDisp(RAX, 0)); looping = false; - done = false; + while (offset < g_state.vs.program_code.size()) { Compile_NextInstr(&offset); } @@ -663,6 +663,14 @@ CompiledShader* JitCompiler::Compile() { return (CompiledShader*)start; } +JitCompiler::JitCompiler() { + AllocCodeSpace(1024 * 1024 * 4); +} + +void JitCompiler::Clear() { + ClearCodeSpace(); +} + } // namespace Shader } // 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 @@ #include <nihstro/shader_bytecode.h> -#if defined(_M_X86_64) -#include "common/x64_emitter.h" -#else -#include "common/fake_emitter.h" -#endif +#include "common/x64/emitter.h" #include "video_core/pica.h" @@ -65,18 +61,16 @@ private: void Compile_Block(unsigned stop); void Compile_NextInstr(unsigned* offset); -#if defined(_M_X86_64) void Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, Gen::X64Reg dest); void Compile_DestEnable(Instruction instr, Gen::X64Reg dest); void Compile_EvaluateCondition(Instruction instr); void Compile_UniformCondition(Instruction instr); -#endif /// Pointer to the variable that stores the current Pica code offset. Used to handle nested code blocks. unsigned* offset_ptr = nullptr; - bool done = false; + /// Set to true if currently in a loop, used to check for the existence of nested loops bool looping = false; }; |