Blender V5.3
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.hh"
21
22#include "RE_compositor.hh"
23#include "RE_pipeline.h"
24
25#include "tile_highlight.h"
26
27class GHOST_IContext;
28
29namespace blender {
30
31namespace compositor {
32class RenderContext;
34} // namespace compositor
35
36struct bNodeTree;
37struct Depsgraph;
38struct Main;
39struct Object;
40struct RenderDisplay;
41struct RenderEngine;
42struct ReportList;
43struct Scene;
44
45struct BaseRender {
46 BaseRender() = default;
47 virtual ~BaseRender();
48
49 /* Get class which manages highlight of tiles.
50 * Note that it might not exist: for example, viewport render does not support the tile
51 * highlight. */
53
54 virtual void compositor_execute(render::CompositorInputData input_data) = 0;
55 virtual void compositor_free() = 0;
56
63 virtual bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) = 0;
64
65 /* Result of rendering */
66 RenderResult *result = nullptr;
67
68 /* Read/write mutex, all internal code that writes to the `result` must use a
69 * write lock, all external code must use a read lock. Internal code is assumed
70 * to not conflict with writes, so no lock used for that. */
72
73 /* Render engine. */
74 struct RenderEngine *engine = nullptr;
75
76 /* Guard for drawing render result using engine's `draw()` callback. */
78
83 std::shared_ptr<RenderDisplay> display;
84 bool display_shared = false;
85};
86
87struct ViewRender : public BaseRender {
89 {
90 return nullptr;
91 }
92
93 void compositor_execute(render::CompositorInputData /*input_data*/) override {}
94 void compositor_free() override {}
95
96 bool prepare_viewlayer(struct ViewLayer * /*view_layer*/,
97 struct Depsgraph * /*depsgraph*/) override
98 {
99 return true;
100 }
101};
102
104struct Render : public BaseRender {
105 Render();
106 ~Render() override;
107
109 {
110 return &tile_highlight;
111 }
112
113 void compositor_execute(render::CompositorInputData input_data) override;
114 void compositor_free() override;
115
116 bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) override;
117
118 /* Owner pointer that uniquely identifiers the owner of this scene. */
119 const void *owner = nullptr;
120
121 /* state settings */
122 short flag = 0;
123 bool ok = false;
124
125 /* if render with single-layer option, other rendered layers are stored here */
128 ListBaseT<RenderResult> fullresult = {nullptr, nullptr};
129 /* True if result has GPU textures, to quickly skip cache clear. */
131
137 int winx = 0, winy = 0;
138 rcti disprect = {0, 0, 0, 0}; /* part within winx winy */
139 rctf viewplane = {0, 0, 0, 0}; /* mapped on winx winy */
140
141 /* final picture width and height (within disprect) */
142 int rectx = 0, recty = 0;
143
144 /* Camera transform. Used by Freestyle, Eevee, and other draw manager engines.. */
145 float winmat[4][4] = {{0}};
146
147 /* Clipping. */
148 float clip_start = 0.0f;
149 float clip_end = 0.0f;
150
151 /* main, scene, and its full copy of renderdata and world */
152 struct Main *main = nullptr;
153 Scene *scene = nullptr;
156 struct Object *camera_override = nullptr;
157
159
160 /* NOTE: This is a minimal dependency graph and evaluated scene which is enough to access view
161 * layer visibility and use for postprocessing (compositor and sequencer). */
162 struct Depsgraph *pipeline_depsgraph = nullptr;
164
165 /* Compositor.
166 * NOTE: Use bare pointer instead of smart pointer because the it is a fully opaque type. */
169
170 /* Callbacks for the corresponding base class method implementation. */
171 bool (*prepare_viewlayer_cb)(void *handle,
172 struct ViewLayer *vl,
173 struct Depsgraph *depsgraph) = nullptr;
174 void *prepare_vl_handle = nullptr;
175
177
182 struct ReportList *reports = nullptr;
183
185 char viewname[MAX_NAME] = "";
186};
187
190
191 void free_gpu_context();
192
195
196 void display_update(RenderResult *render_result);
197 void current_scene_update(struct Scene *scene);
198
199 void stats_draw(RenderStats *render_stats);
200 void progress(float progress);
201
202 void draw_lock();
203 void draw_unlock();
204
205 bool test_break();
206
207 /* Callbacks */
208 void (*display_update_cb)(void *handle, RenderResult *rr) = nullptr;
209 void *duh = nullptr;
210 void (*current_scene_update_cb)(void *handle, struct Scene *scene) = nullptr;
211 void *suh = nullptr;
212
213 void (*stats_draw_cb)(void *handle, RenderStats *ri) = nullptr;
214 void *sdh = nullptr;
215 void (*progress_cb)(void *handle, float i) = nullptr;
216 void *prh = nullptr;
217
218 void (*draw_lock_cb)(void *handle, bool lock) = nullptr;
219 void *dlh = nullptr;
220 bool (*test_break_cb)(void *handle) = nullptr;
221 void *tbh = nullptr;
222
223 /* GPU contexts.
224 * TODO: replace by a whole draw manager. */
226 void *blender_gpu_context = nullptr;
227};
228
229/* **************** defines ********************* */
230
232#define R_ANIMATION 1 << 0
233/* Indicates that the render pipeline should not write its render result. This happens for instance
234 * when the render pipeline uses the compositor, but the compositor node tree does not have a group
235 * output node or a render layer input, and consequently no render result. In that case, the output
236 * will be written from the File Output nodes, since the render pipeline will early fail if neither
237 * a File Output nor a Group Output node exist in the scene. */
238#define R_SKIP_WRITE 1 << 1
239
240} // namespace blender
#define BLI_RWLOCK_INITIALIZER
#define BLI_MUTEX_INITIALIZER
#define MAX_NAME
Definition DNA_defs.h:63
volatile int lock
BMesh Iterators.
unsigned char uint8_t
Definition BKE_text.h:79
std::mutex Mutex
Definition BLI_mutex.hh:51
pthread_mutex_t ThreadMutex
pthread_rwlock_t ThreadRWMutex
std::shared_ptr< RenderDisplay > display
virtual void compositor_execute(render::CompositorInputData input_data)=0
ThreadMutex engine_draw_mutex
virtual bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph)=0
virtual render::TilesHighlight * get_tile_highlight()=0
ThreadRWMutex resultmutex
RenderResult * result
virtual void compositor_free()=0
struct RenderEngine * engine
void(*) stats_draw_cb(void *handle, RenderStats *ri)
void * ensure_blender_gpu_context()
void display_update(RenderResult *render_result)
void(*) progress_cb(void *handle, float i)
void(*) display_update_cb(void *handle, RenderResult *rr)
void stats_draw(RenderStats *render_stats)
void(*) current_scene_update_cb(void *handle, struct Scene *scene)
void current_scene_update(struct Scene *scene)
void(*) draw_lock_cb(void *handle, bool lock)
void progress(float progress)
GHOST_IContext * system_gpu_context
bool(*) test_break_cb(void *handle)
struct Object * camera_override
const void * owner
bool result_has_gpu_texture_caches
void * prepare_vl_handle
float winmat[4][4]
void compositor_execute(render::CompositorInputData input_data) override
bool prepare_viewlayer(struct ViewLayer *view_layer, struct Depsgraph *depsgraph) override
render::TilesHighlight tile_highlight
Vector< MovieWriter * > movie_writers
RenderResult * pushedresult
render::TilesHighlight * get_tile_highlight() override
struct ReportList * reports
ListBaseT< RenderResult > fullresult
RenderStats i
struct Main * main
render::Compositor * compositor
Scene * pipeline_scene_eval
struct Depsgraph * pipeline_depsgraph
bool(*) prepare_viewlayer_cb(void *handle, struct ViewLayer *vl, struct Depsgraph *depsgraph)
void compositor_free() override
char viewname[MAX_NAME]
char single_view_layer[MAX_NAME]
bool prepare_viewlayer(struct ViewLayer *, struct Depsgraph *) override
void compositor_execute(render::CompositorInputData) override
void compositor_free() override
render::TilesHighlight * get_tile_highlight() override