From 765d7242d5a14551d0dc876f13bf6ee579b47b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sun, 11 Mar 2018 23:43:09 +0100 Subject: GPUMaterial: Add Material shader cache. This is mostly to avoid re-compilation when using undo/redo operators. This also has the benefit to reuse the same GPUShader for multiple materials using the same nodetree configuration. The cache stores GPUPasses that already contains the shader code and a hash to test for matches. We use refcounts to know when a GPUPass is not used anymore. I had to move the GPUInput list from GPUPass to GPUMaterial because it's containing references to the material nodetree and cannot be reused. A garbage collection is hardcoded to run every 60 seconds to free every unused GPUPass. --- source/blender/windowmanager/intern/wm_init_exit.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index a2f5f1b1e10..98ac3eebb57 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -116,6 +116,7 @@ #include "BLF_api.h" #include "BLT_lang.h" +#include "GPU_material.h" #include "GPU_buffers.h" #include "GPU_draw.h" #include "GPU_init_exit.h" @@ -553,6 +554,7 @@ void WM_exit_ext(bContext *C, const bool do_python) BLF_exit(); if (!G.background) { + GPU_pass_cache_free(); DRW_opengl_context_destroy(); } -- cgit v1.2.3