summaryrefslogtreecommitdiff
path: root/src/video_core/shader/shader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core/shader/shader.cpp')
-rw-r--r--src/video_core/shader/shader.cpp14
1 files changed, 13 insertions, 1 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 {
32static std::unordered_map<u64, CompiledShader*> shader_map; 32static std::unordered_map<u64, CompiledShader*> shader_map;
33static JitCompiler jit; 33static JitCompiler jit;
34static CompiledShader* jit_shader; 34static CompiledShader* jit_shader;
35
36static 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
37void Setup(UnitState<false>& state) { 43void 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
55void Shutdown() { 67void 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