Blender V4.3
compositor/realtime_compositor/intern/context.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "BLI_math_vector.hh"
6#include "BLI_rect.h"
7
8#include "DNA_node_types.h"
9#include "DNA_vec_types.h"
10
11#include "GPU_shader.hh"
12
13#include "BKE_node_runtime.hh"
14
15#include "COM_context.hh"
16#include "COM_profiler.hh"
17#include "COM_render_context.hh"
19#include "COM_texture_pool.hh"
20
22
23Context::Context(TexturePool &texture_pool) : texture_pool_(texture_pool) {}
24
26 int /*view_layer_id*/,
27 const char * /*pass_name*/,
28 MetaData & /*meta_data*/) const
29{
30}
31
33{
34 return nullptr;
35}
36
38{
39 return nullptr;
40}
41
43
45{
46 if (!this->get_node_tree().runtime->test_break) {
47 return false;
48 }
49 return this->get_node_tree().runtime->test_break(get_node_tree().runtime->tbh);
50}
51
53{
54 texture_pool_.reset();
55 cache_manager_.reset();
56}
57
59{
60 const rcti compositing_region = get_compositing_region();
61 const int x = BLI_rcti_size_x(&compositing_region);
62 const int y = BLI_rcti_size_y(&compositing_region);
63 return math::max(int2(1), int2(x, y));
64}
65
67{
68 const rcti compositing_region = get_compositing_region();
69 const int x = BLI_rcti_size_x(&compositing_region);
70 const int y = BLI_rcti_size_y(&compositing_region);
71 return x != 0 && y != 0;
72}
73
75{
76 return get_render_data().size / 100.0f;
77}
78
80{
81 return get_render_data().cfra;
82}
83
84float Context::get_time() const
85{
86 const float frame_number = float(get_frame_number());
87 const float frame_rate = float(get_render_data().frs_sec) /
88 float(get_render_data().frs_sec_base);
89 return frame_number / frame_rate;
90}
91
92GPUShader *Context::get_shader(const char *info_name, ResultPrecision precision)
93{
94 return cache_manager().cached_shaders.get(info_name, precision);
95}
96
97GPUShader *Context::get_shader(const char *info_name)
98{
99 return get_shader(info_name, get_precision());
100}
101
103{
104 return Result(*this, type, precision);
105}
106
111
113{
114 return texture_pool_;
115}
116
118{
119 return cache_manager_;
120}
121
122} // namespace blender::realtime_compositor
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:193
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:189
struct GPUShader GPUShader
GPUShader * get(const char *info_name, ResultPrecision precision)
virtual rcti get_compositing_region() const =0
GPUShader * get_shader(const char *info_name, ResultPrecision precision)
Result create_result(ResultType type, ResultPrecision precision)
virtual const RenderData & get_render_data() const =0
virtual ResultPrecision get_precision() const =0
virtual const bNodeTree & get_node_tree() const =0
virtual void populate_meta_data_for_pass(const Scene *scene, int view_layer_id, const char *pass_name, MetaData &meta_data) const
draw_view in_light_buf[] float
T max(const T &a, const T &b)
VecBase< int32_t, 2 > int2
bNodeTreeRuntimeHandle * runtime