[Bf-blender-cvs] [58a8277098b] blender2.8: GPU: utility function to unregister presets
Campbell Barton
noreply at git.blender.org
Tue Sep 11 05:12:17 CEST 2018
Commit: 58a8277098b5c8cf43985d7955ad5e5c6f7894ae
Author: Campbell Barton
Date: Tue Sep 11 13:17:30 2018 +1000
Branches: blender2.8
https://developer.blender.org/rB58a8277098b5c8cf43985d7955ad5e5c6f7894ae
GPU: utility function to unregister presets
===================================================================
M source/blender/gpu/GPU_batch_presets.h
M source/blender/gpu/intern/gpu_batch_presets.c
===================================================================
diff --git a/source/blender/gpu/GPU_batch_presets.h b/source/blender/gpu/GPU_batch_presets.h
index 6b010396a9b..d5cabf8bf90 100644
--- a/source/blender/gpu/GPU_batch_presets.h
+++ b/source/blender/gpu/GPU_batch_presets.h
@@ -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);
diff --git a/source/blender/gpu/intern/gpu_batch_presets.c b/source/blender/gpu/intern/gpu_batch_presets.c
index 83287c57441..126897ac8bf 100644
--- a/source/blender/gpu/intern/gpu_batch_presets.c
+++ b/source/blender/gpu/intern/gpu_batch_presets.c
@@ -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);
}
More information about the Bf-blender-cvs
mailing list