Blender V5.3
cache_eviction.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include <chrono>
8
9#include "util/types.h"
10
12
13/* CacheEvictionManager has decides when texture cache eviction should
14 * happen in a render session. Different policies are used for viewport
15 * and final rendering. */
17 public:
18 explicit CacheEvictionManager(bool background);
19
20 /* Reset state when starting a new render. */
21 void reset();
22
23 /* Set and query if viewport navigation is happening. */
24 void set_navigating(bool navigating);
25 bool is_navigating() const;
26
27 /* For a render iteration, check if cache eviction is needed. */
28 bool need_eviction(bool idle, bool switched_to_new_tile);
29
30 /* Wait time until cache eviction needs to be performed. */
31 std::chrono::milliseconds wait_time(bool idle) const;
32
33 private:
34 const bool background_;
35
36 bool navigating_ = false;
37
38 double viewport_last_activity_ = 0.0;
39 bool viewport_was_navigating_ = false;
40 int render_tile_count_ = 0;
41
42 static constexpr double VIEWPORT_EVICTION_DELAY = 2.0;
43};
44
void set_navigating(bool navigating)
std::chrono::milliseconds wait_time(bool idle) const
CacheEvictionManager(bool background)
bool need_eviction(bool idle, bool switched_to_new_tile)
#define CCL_NAMESPACE_END