Blender V5.0
render_types.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11/* ------------------------------------------------------------------------- */
12/* exposed internal in render module only! */
13/* ------------------------------------------------------------------------- */
14
15#include <memory>
16
17#include "DNA_scene_types.h"
18
19#include "BLI_mutex.hh"
20#include "BLI_threads.h"
21
22#include "RE_compositor.hh"
23#include "RE_pipeline.h"
24
25#include "tile_highlight.h"
26
27namespace blender::compositor {
28class RenderContext;
29class Profiler;
30enum class OutputTypes : uint8_t;
31} // namespace blender::compositor
32
33struct bNodeTree;
34struct Depsgraph;
35struct Main;
36struct Object;
37struct RenderDisplay;
38struct RenderEngine;
39struct ReportList;
40struct Scene;
41
42struct BaseRender {
43 BaseRender() = default;
44 virtual ~BaseRender();
45
46 /* Get class which manages highlight of tiles.
47 * Note that it might not exist: for example, viewport render does not support the tile
48 * highlight. */
50
51 virtual void compositor_execute(const Scene &scene,
52 const RenderData &render_data,
53 const bNodeTree &node_tree,
54 const char *view_name,
57 blender::compositor::OutputTypes needed_outputs) = 0;
58 virtual void compositor_free() = 0;
59
66 virtual bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) = 0;
67
68 /* Result of rendering */
69 RenderResult *result = nullptr;
70
71 /* Read/write mutex, all internal code that writes to the `result` must use a
72 * write lock, all external code must use a read lock. Internal code is assumed
73 * to not conflict with writes, so no lock used for that. */
75
76 /* Render engine. */
77 struct RenderEngine *engine = nullptr;
78
79 /* Guard for drawing render result using engine's `draw()` callback. */
81
86 std::shared_ptr<RenderDisplay> display;
87 bool display_shared = false;
88};
89
90struct ViewRender : public BaseRender {
92 {
93 return nullptr;
94 }
95
96 void compositor_execute(const Scene & /*scene*/,
97 const RenderData & /*render_data*/,
98 const bNodeTree & /*node_tree*/,
99 const char * /*view_name*/,
100 blender::compositor::RenderContext * /*render_context*/,
101 blender::compositor::Profiler * /*profiler*/,
102 blender::compositor::OutputTypes /*needed_outputs*/) override
103 {
104 }
105 void compositor_free() override {}
106
107 bool prepare_viewlayer(struct ViewLayer * /*view_layer*/,
108 struct Depsgraph * /*depsgraph*/) override
109 {
110 return true;
111 }
112};
113
115struct Render : public BaseRender {
116 Render();
117 ~Render() override;
118
123
124 void compositor_execute(const Scene &scene,
125 const RenderData &render_data,
126 const bNodeTree &node_tree,
127 const char *view_name,
130 blender::compositor::OutputTypes needed_outputs) override;
131 void compositor_free() override;
132
133 bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) override;
134
135 /* Owner pointer that uniquely identifiers the owner of this scene. */
136 const void *owner = nullptr;
137
138 /* state settings */
139 short flag = 0;
140 bool ok = false;
141
142 /* if render with single-layer option, other rendered layers are stored here */
145 ListBase fullresult = {nullptr, nullptr};
146 /* True if result has GPU textures, to quickly skip cache clear. */
148
152 int winx = 0, winy = 0;
153 rcti disprect = {0, 0, 0, 0}; /* part within winx winy */
154 rctf viewplane = {0, 0, 0, 0}; /* mapped on winx winy */
155
156 /* final picture width and height (within disprect) */
157 int rectx = 0, recty = 0;
158
159 /* Camera transform. Used by Freestyle, Eevee, and other draw manager engines.. */
160 float winmat[4][4] = {{0}};
161
162 /* Clipping. */
163 float clip_start = 0.0f;
164 float clip_end = 0.0f;
165
166 /* main, scene, and its full copy of renderdata and world */
167 struct Main *main = nullptr;
168 Scene *scene = nullptr;
171 struct Object *camera_override = nullptr;
172
174
175 /* NOTE: This is a minimal dependency graph and evaluated scene which is enough to access view
176 * layer visibility and use for postprocessing (compositor and sequencer). */
177 struct Depsgraph *pipeline_depsgraph = nullptr;
179
180 /* Compositor.
181 * NOTE: Use bare pointer instead of smart pointer because the it is a fully opaque type. */
184
185 /* Callbacks for the corresponding base class method implementation. */
186 bool (*prepare_viewlayer_cb)(void *handle,
187 struct ViewLayer *vl,
188 struct Depsgraph *depsgraph) = nullptr;
189 void *prepare_vl_handle = nullptr;
190
192
197 struct ReportList *reports = nullptr;
198
200 char viewname[MAX_NAME] = "";
201};
202
205
208
209 void display_update(RenderResult *render_result, rcti *rect);
210 void current_scene_update(struct Scene *scene);
211
212 void stats_draw(RenderStats *render_stats);
213 void progress(float progress);
214
215 void draw_lock();
216 void draw_unlock();
217
218 bool test_break();
219
220 /* Callbacks */
221 void (*display_update_cb)(void *handle, RenderResult *rr, rcti *rect) = nullptr;
222 void *duh = nullptr;
223 void (*current_scene_update_cb)(void *handle, struct Scene *scene) = nullptr;
224 void *suh = nullptr;
225
226 void (*stats_draw_cb)(void *handle, RenderStats *ri) = nullptr;
227 void *sdh = nullptr;
228 void (*progress_cb)(void *handle, float i) = nullptr;
229 void *prh = nullptr;
230
231 void (*draw_lock_cb)(void *handle, bool lock) = nullptr;
232 void *dlh = nullptr;
233 bool (*test_break_cb)(void *handle) = nullptr;
234 void *tbh = nullptr;
235
236 /* GPU contexts.
237 * TODO: replace by a whole draw manager. */
238 void *system_gpu_context = nullptr;
239 void *blender_gpu_context = nullptr;
240};
241
242/* **************** defines ********************* */
243
245#define R_ANIMATION 1 << 0
246/* Indicates that the render pipeline should not write its render result. This happens for instance
247 * when the render pipeline uses the compositor, but the compositor node tree does not have a group
248 * output node or a render layer input, and consequently no render result. In that case, the output
249 * will be written from the File Output nodes, since the render pipeline will early fail if neither
250 * a File Output nor a Group Output node exist in the scene. */
251#define R_SKIP_WRITE 1 << 1
pthread_rwlock_t ThreadRWMutex
#define BLI_RWLOCK_INITIALIZER
#define BLI_MUTEX_INITIALIZER
Definition BLI_threads.h:80
pthread_mutex_t ThreadMutex
Definition BLI_threads.h:79
#define MAX_NAME
Definition DNA_defs.h:50
volatile int lock
BPy_StructRNA * depsgraph
std::mutex Mutex
Definition BLI_mutex.hh:47
virtual void compositor_free()=0
ThreadMutex engine_draw_mutex
bool display_shared
virtual ~BaseRender()
struct RenderEngine * engine
virtual bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph)=0
virtual void compositor_execute(const Scene &scene, const RenderData &render_data, const bNodeTree &node_tree, const char *view_name, blender::compositor::RenderContext *render_context, blender::compositor::Profiler *profiler, blender::compositor::OutputTypes needed_outputs)=0
ThreadRWMutex resultmutex
std::shared_ptr< RenderDisplay > display
BaseRender()=default
RenderResult * result
virtual blender::render::TilesHighlight * get_tile_highlight()=0
void stats_draw(RenderStats *render_stats)
void progress(float progress)
void display_update(RenderResult *render_result, rcti *rect)
void(* current_scene_update_cb)(void *handle, struct Scene *scene)
void ensure_system_gpu_context()
void(* draw_lock_cb)(void *handle, bool lock)
void(* display_update_cb)(void *handle, RenderResult *rr, rcti *rect)
void(* stats_draw_cb)(void *handle, RenderStats *ri)
void * system_gpu_context
void current_scene_update(struct Scene *scene)
void * blender_gpu_context
void * ensure_blender_gpu_context()
void(* progress_cb)(void *handle, float i)
bool(* test_break_cb)(void *handle)
void compositor_free() override
float winmat[4][4]
~Render() override
Scene * pipeline_scene_eval
bool(* prepare_viewlayer_cb)(void *handle, struct ViewLayer *vl, struct Depsgraph *depsgraph)
bool result_has_gpu_texture_caches
RenderResult * pushedresult
float clip_start
RenderData r
blender::render::Compositor * compositor
struct Main * main
float clip_end
bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) override
const void * owner
Scene * scene
ListBase fullresult
blender::Mutex compositor_mutex
struct Depsgraph * pipeline_depsgraph
blender::render::TilesHighlight * get_tile_highlight() override
void * prepare_vl_handle
short flag
blender::render::TilesHighlight tile_highlight
char single_view_layer[MAX_NAME]
char viewname[MAX_NAME]
RenderStats i
void compositor_execute(const Scene &scene, const RenderData &render_data, const bNodeTree &node_tree, const char *view_name, blender::compositor::RenderContext *render_context, blender::compositor::Profiler *profiler, blender::compositor::OutputTypes needed_outputs) override
rctf viewplane
struct ReportList * reports
rcti disprect
struct Object * camera_override
blender::Vector< MovieWriter * > movie_writers
void compositor_execute(const Scene &, const RenderData &, const bNodeTree &, const char *, blender::compositor::RenderContext *, blender::compositor::Profiler *, blender::compositor::OutputTypes) override
blender::render::TilesHighlight * get_tile_highlight() override
void compositor_free() override
bool prepare_viewlayer(struct ViewLayer *, struct Depsgraph *) override
i
Definition text_draw.cc:230