Blender V5.3
compositor_cache.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_threads.hh"
10#include "COM_result.hh"
11#include "DRW_engine.hh"
12
13#include "compositor_cache.hh"
14
15namespace blender::seq {
16
18{
19 bool use_main_context = false;
20 if (this->last_evaluation_used_gpu) {
21 /* Free resources with GPU context enabled. Cleanup may happen from the main thread, and we
22 * must use the main context there. */
23 BLI_assert(BLI_thread_is_main() || this->secondary_gpu_context.ghost_context != nullptr);
24 use_main_context = BLI_thread_is_main();
25 if (use_main_context) {
27 }
28 else {
29 gpu::GPU_activate_secondary_context(this->secondary_gpu_context);
30 }
31 }
32
33 this->cache_manager.free();
34
35 /* See comment above on context enabling. */
36 if (this->last_evaluation_used_gpu) {
37 if (use_main_context) {
39 }
40 else {
41 gpu::GPU_deactivate_secondary_context(this->secondary_gpu_context);
42 }
43 }
44}
45
48 const gpu::GPUSecondaryContextData &gpu_context)
49{
50 this->secondary_gpu_context = gpu ? gpu_context : gpu::GPUSecondaryContextData();
51
52 if (this->last_evaluation_used_gpu == gpu && this->last_evaluation_precision == precision) {
53 return;
54 }
55 this->cache_manager.free();
56 this->last_evaluation_used_gpu = gpu;
57 this->last_evaluation_precision = precision;
58}
59
60} // namespace blender::seq
void recreate_if_needed(bool gpu, compositor::ResultPrecision precision, const gpu::GPUSecondaryContextData &gpu_context)
void GPU_activate_secondary_context(const GPUSecondaryContextData &data)
void GPU_deactivate_secondary_context(const GPUSecondaryContextData &data)
void DRW_gpu_context_enable()
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void DRW_gpu_context_disable()
int BLI_thread_is_main()
Definition threads.cc:184