GPU: utility function to unregister presets
authorCampbell Barton <ideasman42@gmail.com>
Tue, 11 Sep 2018 03:17:30 +0000 (13:17 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 11 Sep 2018 03:21:47 +0000 (13:21 +1000)
source/blender/gpu/GPU_batch_presets.h
source/blender/gpu/intern/gpu_batch_presets.c

index 6b010396a9bc7347a51c62c0cc6af118f444aeae..d5cabf8bf904ac29da11a9fd46e3328d6f26ef10 100644 (file)
@@ -49,6 +49,7 @@ struct GPUBatch *GPU_batch_preset_sphere_wire(int lod) ATTR_WARN_UNUSED_RESULT;
 
 void gpu_batch_presets_init(void);
 void gpu_batch_presets_register(struct GPUBatch *preset_batch);
+bool gpu_batch_presets_unregister(struct GPUBatch *preset_batch);
 void gpu_batch_presets_reset(void);
 void gpu_batch_presets_exit(void);
 
index 83287c574415e249b94d7f89b7d860801e77982d..126897ac8bf838e2d56cd26cb86c369fe13cbf13 100644 (file)
@@ -221,12 +221,23 @@ void gpu_batch_presets_register(GPUBatch *preset_batch)
        BLI_addtail(&presets_list, BLI_genericNodeN(preset_batch));
 }
 
+bool gpu_batch_presets_unregister(GPUBatch *preset_batch)
+{
+       for (LinkData *link = presets_list.last; link; link = link->prev) {
+               if (preset_batch == link->data) {
+                       BLI_remlink(&presets_list, link);
+                       MEM_freeN(link);
+                       return true;
+               }
+       }
+       return false;
+}
+
 void gpu_batch_presets_reset(void)
 {
        /* Reset vao caches for these every time we switch opengl context.
         * This way they will draw correctly for each window. */
-       LinkData *link = presets_list.first;
-       for (link = presets_list.first; link; link = link->next) {
+       for (LinkData *link = presets_list.first; link; link = link->next) {
                GPUBatch *preset = link->data;
                GPU_batch_vao_cache_clear(preset);
        }