diff options
author | bunnei <bunneidev@gmail.com> | 2016-03-12 18:15:49 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2016-03-12 18:15:49 +0100 |
commit | 6efb710b2801ff7e2baea0738174b0b8c9a2d9da (patch) | |
tree | bbea1de82ade8b69c31b824547a67018886fa561 /src/video_core/shader | |
parent | shader_jit_x64: Make assert outputs more useful & cleanup formatting. (diff) | |
download | yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.tar yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.tar.gz yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.tar.bz2 yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.tar.lz yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.tar.xz yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.tar.zst yuzu-6efb710b2801ff7e2baea0738174b0b8c9a2d9da.zip |
Diffstat (limited to 'src/video_core/shader')
-rw-r--r-- | src/video_core/shader/shader.cpp | 14 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 2 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_x64.h | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index babb124fe..509558fc0 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -32,6 +32,12 @@ namespace Shader { static std::unordered_map<u64, CompiledShader*> shader_map; static JitCompiler jit; static CompiledShader* jit_shader; + +static void ClearCache() { + shader_map.clear(); + jit.Clear(); + LOG_INFO(HW_GPU, "Shader JIT cache cleared"); +} #endif // ARCHITECTURE_x86_64 void Setup(UnitState<false>& state) { @@ -45,6 +51,12 @@ void Setup(UnitState<false>& state) { if (iter != shader_map.end()) { jit_shader = iter->second; } else { + // Check if remaining JIT code space is enough for at least one more (massive) shader + if (jit.GetSpaceLeft() < jit_shader_size) { + // If not, clear the cache of all previously compiled shaders + ClearCache(); + } + jit_shader = jit.Compile(); shader_map.emplace(cache_key, jit_shader); } @@ -54,7 +66,7 @@ void Setup(UnitState<false>& state) { void Shutdown() { #ifdef ARCHITECTURE_x86_64 - shader_map.clear(); + ClearCache(); #endif // ARCHITECTURE_x86_64 } diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index 1c700fca7..e6cdfe9c5 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp @@ -789,7 +789,7 @@ CompiledShader* JitCompiler::Compile() { } JitCompiler::JitCompiler() { - AllocCodeSpace(1024 * 1024 * 4); + AllocCodeSpace(jit_cache_size); } void JitCompiler::Clear() { diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index 5ad2d9606..5357c964b 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h @@ -19,6 +19,11 @@ namespace Pica { namespace Shader { +/// Memory needed to be available to compile the next shader (otherwise, clear the cache) +constexpr size_t jit_shader_size = 1024 * 512; +/// Memory allocated for the JIT code space cache +constexpr size_t jit_cache_size = 1024 * 1024 * 8; + using CompiledShader = void(void* registers); /** |