diff options
| author | 2016-03-16 13:18:51 -0400 | |
|---|---|---|
| committer | 2016-03-16 13:18:51 -0400 | |
| commit | 96cafbe4cc4a1d5cae668a6ba174bead35e2a810 (patch) | |
| tree | 6d6c47cec0883c62c5cc38651e5a0491170d9a9a /src/video_core/shader/shader.cpp | |
| parent | Merge pull request #1479 from JayFoxRox/mad-encoding (diff) | |
| parent | shader_jit_x64: Clear cache after code space fills up. (diff) | |
| download | yuzu-96cafbe4cc4a1d5cae668a6ba174bead35e2a810.tar.gz yuzu-96cafbe4cc4a1d5cae668a6ba174bead35e2a810.tar.xz yuzu-96cafbe4cc4a1d5cae668a6ba174bead35e2a810.zip | |
Merge pull request #1503 from bunnei/clear-jit-cache
Clear JIT cache
Diffstat (limited to 'src/video_core/shader/shader.cpp')
| -rw-r--r-- | src/video_core/shader/shader.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 5e8930476..509558fc0 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp | |||
| @@ -32,6 +32,12 @@ namespace Shader { | |||
| 32 | static std::unordered_map<u64, CompiledShader*> shader_map; | 32 | static std::unordered_map<u64, CompiledShader*> shader_map; |
| 33 | static JitCompiler jit; | 33 | static JitCompiler jit; |
| 34 | static CompiledShader* jit_shader; | 34 | static CompiledShader* jit_shader; |
| 35 | |||
| 36 | static void ClearCache() { | ||
| 37 | shader_map.clear(); | ||
| 38 | jit.Clear(); | ||
| 39 | LOG_INFO(HW_GPU, "Shader JIT cache cleared"); | ||
| 40 | } | ||
| 35 | #endif // ARCHITECTURE_x86_64 | 41 | #endif // ARCHITECTURE_x86_64 |
| 36 | 42 | ||
| 37 | void Setup(UnitState<false>& state) { | 43 | void Setup(UnitState<false>& state) { |
| @@ -45,6 +51,12 @@ void Setup(UnitState<false>& state) { | |||
| 45 | if (iter != shader_map.end()) { | 51 | if (iter != shader_map.end()) { |
| 46 | jit_shader = iter->second; | 52 | jit_shader = iter->second; |
| 47 | } else { | 53 | } else { |
| 54 | // Check if remaining JIT code space is enough for at least one more (massive) shader | ||
| 55 | if (jit.GetSpaceLeft() < jit_shader_size) { | ||
| 56 | // If not, clear the cache of all previously compiled shaders | ||
| 57 | ClearCache(); | ||
| 58 | } | ||
| 59 | |||
| 48 | jit_shader = jit.Compile(); | 60 | jit_shader = jit.Compile(); |
| 49 | shader_map.emplace(cache_key, jit_shader); | 61 | shader_map.emplace(cache_key, jit_shader); |
| 50 | } | 62 | } |
| @@ -54,7 +66,7 @@ void Setup(UnitState<false>& state) { | |||
| 54 | 66 | ||
| 55 | void Shutdown() { | 67 | void Shutdown() { |
| 56 | #ifdef ARCHITECTURE_x86_64 | 68 | #ifdef ARCHITECTURE_x86_64 |
| 57 | shader_map.clear(); | 69 | ClearCache(); |
| 58 | #endif // ARCHITECTURE_x86_64 | 70 | #endif // ARCHITECTURE_x86_64 |
| 59 | } | 71 | } |
| 60 | 72 | ||
| @@ -135,7 +147,7 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr | |||
| 135 | std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); | 147 | std::fmin(std::fabs(ret.color[i].ToFloat32()), 1.0f)); |
| 136 | } | 148 | } |
| 137 | 149 | ||
| 138 | LOG_TRACE(Render_Software, "Output vertex: pos(%.2f, %.2f, %.2f, %.2f), quat(%.2f, %.2f, %.2f, %.2f), " | 150 | LOG_TRACE(HW_GPU, "Output vertex: pos(%.2f, %.2f, %.2f, %.2f), quat(%.2f, %.2f, %.2f, %.2f), " |
| 139 | "col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f), view(%.2f, %.2f, %.2f)", | 151 | "col(%.2f, %.2f, %.2f, %.2f), tc0(%.2f, %.2f), view(%.2f, %.2f, %.2f)", |
| 140 | ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(), | 152 | ret.pos.x.ToFloat32(), ret.pos.y.ToFloat32(), ret.pos.z.ToFloat32(), ret.pos.w.ToFloat32(), |
| 141 | ret.quat.x.ToFloat32(), ret.quat.y.ToFloat32(), ret.quat.z.ToFloat32(), ret.quat.w.ToFloat32(), | 153 | ret.quat.x.ToFloat32(), ret.quat.y.ToFloat32(), ret.quat.z.ToFloat32(), ret.quat.w.ToFloat32(), |