diff options
| author | 2016-03-26 21:02:15 -0400 | |
|---|---|---|
| committer | 2016-04-13 23:04:47 -0400 | |
| commit | a5a74eb121e0586706c3196d450c088280f996a5 (patch) | |
| tree | 1ed5030e828e221d2c34596effaa1e680a678391 /src | |
| parent | shader_jit_x64: Allocate each program independently and persist for emu session. (diff) | |
| download | yuzu-a5a74eb121e0586706c3196d450c088280f996a5.tar.gz yuzu-a5a74eb121e0586706c3196d450c088280f996a5.tar.xz yuzu-a5a74eb121e0586706c3196d450c088280f996a5.zip | |
shader_jit_x64: Specify shader main offset at runtime.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/shader/shader.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 4 | ||||
| -rw-r--r-- | 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<false>& state) { | |||
| 36 | #ifdef ARCHITECTURE_x86_64 | 36 | #ifdef ARCHITECTURE_x86_64 |
| 37 | if (VideoCore::g_shader_jit_enabled) { | 37 | if (VideoCore::g_shader_jit_enabled) { |
| 38 | u64 cache_key = (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^ | 38 | u64 cache_key = (Common::ComputeHash64(&g_state.vs.program_code, sizeof(g_state.vs.program_code)) ^ |
| 39 | Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data)) ^ | 39 | Common::ComputeHash64(&g_state.vs.swizzle_data, sizeof(g_state.vs.swizzle_data))); |
| 40 | g_state.regs.vs.main_offset); | ||
| 41 | 40 | ||
| 42 | auto iter = shader_map.find(cache_key); | 41 | auto iter = shader_map.find(cache_key); |
| 43 | if (iter != shader_map.end()) { | 42 | if (iter != shader_map.end()) { |
| @@ -98,7 +97,7 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr | |||
| 98 | 97 | ||
| 99 | #ifdef ARCHITECTURE_x86_64 | 98 | #ifdef ARCHITECTURE_x86_64 |
| 100 | if (VideoCore::g_shader_jit_enabled) | 99 | if (VideoCore::g_shader_jit_enabled) |
| 101 | jit_shader->Run(&state.registers); | 100 | jit_shader->Run(&state.registers, g_state.regs.vs.main_offset); |
| 102 | else | 101 | else |
| 103 | RunInterpreter(state); | 102 | RunInterpreter(state); |
| 104 | #else | 103 | #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() { | |||
| 838 | fixup_branches.clear(); | 838 | fixup_branches.clear(); |
| 839 | 839 | ||
| 840 | // Jump to start of the shader program | 840 | // Jump to start of the shader program |
| 841 | if (g_state.regs.vs.main_offset != 0) { | 841 | JMPptr(R(ABI_PARAM2)); |
| 842 | fixup_branches.push_back({ J(true), g_state.regs.vs.main_offset }); | ||
| 843 | } | ||
| 844 | 842 | ||
| 845 | // Compile entire program | 843 | // Compile entire program |
| 846 | Compile_Block(static_cast<unsigned>(g_state.vs.program_code.size())); | 844 | Compile_Block(static_cast<unsigned>(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 { | |||
| 25 | /// Memory allocated for each compiled shader (64Kb) | 25 | /// Memory allocated for each compiled shader (64Kb) |
| 26 | constexpr size_t MAX_SHADER_SIZE = 1024 * 64; | 26 | constexpr size_t MAX_SHADER_SIZE = 1024 * 64; |
| 27 | 27 | ||
| 28 | using CompiledShader = void(void* registers); | ||
| 29 | |||
| 30 | /** | 28 | /** |
| 31 | * 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 |
| 32 | * code that can be executed on the host machine directly. | 30 | * code that can be executed on the host machine directly. |
| @@ -35,8 +33,8 @@ class JitCompiler : public Gen::XCodeBlock { | |||
| 35 | public: | 33 | public: |
| 36 | JitCompiler(); | 34 | JitCompiler(); |
| 37 | 35 | ||
| 38 | void Run(void* registers) const { | 36 | void Run(void* registers, unsigned offset) const { |
| 39 | program(registers); | 37 | program(registers, code_ptr[offset]); |
| 40 | } | 38 | } |
| 41 | 39 | ||
| 42 | void Compile(); | 40 | void Compile(); |
| @@ -111,6 +109,7 @@ private: | |||
| 111 | /// Branches that need to be fixed up once the entire shader program is compiled | 109 | /// Branches that need to be fixed up once the entire shader program is compiled |
| 112 | std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches; | 110 | std::vector<std::pair<Gen::FixupBranch, unsigned>> fixup_branches; |
| 113 | 111 | ||
| 112 | using CompiledShader = void(void* registers, const u8* start_addr); | ||
| 114 | CompiledShader* program = nullptr; | 113 | CompiledShader* program = nullptr; |
| 115 | }; | 114 | }; |
| 116 | 115 | ||