From a5a74eb121e0586706c3196d450c088280f996a5 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 26 Mar 2016 21:02:15 -0400 Subject: shader_jit_x64: Specify shader main offset at runtime. --- src/video_core/shader/shader.cpp | 5 ++--- src/video_core/shader/shader_jit_x64.cpp | 4 +--- src/video_core/shader/shader_jit_x64.h | 7 +++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index e17368a4a..b35413488 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -36,8 +36,7 @@ void Setup(UnitState& state) { #ifdef ARCHITECTURE_x86_64 if (VideoCore::g_shader_jit_enabled) { u64 cache_key = (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^ - Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)) ^ - g_state.regs.vs.main_offset); + Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data))); auto iter = shader_map.find(cache_key); if (iter != shader_map.end()) { @@ -98,7 +97,7 @@ OutputVertex Run(UnitState& state, const InputVertex& input, int num_attr #ifdef ARCHITECTURE_x86_64 if (VideoCore::g_shader_jit_enabled) - jit_shader->Run(&state.registers); + jit_shader->Run(&state.registers, g_state.regs.vs.main_offset); else RunInterpreter(state); #else diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index 3da4e51fa..cbdc1e40f 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp @@ -838,9 +838,7 @@ void JitCompiler::Compile() { fixup_branches.clear(); // Jump to start of the shader program - if (g_state.regs.vs.main_offset != 0) { - fixup_branches.push_back({ J(true), g_state.regs.vs.main_offset }); - } + JMPptr(R(ABI_PARAM2)); // Compile entire program Compile_Block(static_cast(g_state.vs.program_code.size())); diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index 19f9bdb56..1501d13bf 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h @@ -25,8 +25,6 @@ namespace Shader { /// Memory allocated for each compiled shader (64Kb) constexpr size_t MAX_SHADER_SIZE = 1024 * 64; -using CompiledShader = void(void* registers); - /** * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64 * code that can be executed on the host machine directly. @@ -35,8 +33,8 @@ class JitCompiler : public Gen::XCodeBlock { public: JitCompiler(); - void Run(void* registers) const { - program(registers); + void Run(void* registers, unsigned offset) const { + program(registers, code_ptr[offset]); } void Compile(); @@ -111,6 +109,7 @@ private: /// Branches that need to be fixed up once the entire shader program is compiled std::vector> fixup_branches; + using CompiledShader = void(void* registers, const u8* start_addr); CompiledShader* program = nullptr; }; -- cgit v1.2.3