Blender V5.3
blender/session.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "device/device.h"
8
9#include "scene/scene.h"
10#include "session/session.h"
11
12#include "util/unique_ptr.h"
13#include "util/vector.h"
14
15namespace blender {
16struct bScreen;
17struct Depsgraph;
18struct Main;
19struct Object;
20struct RegionView3D;
21struct RenderData;
22struct RenderEngine;
23struct Scene;
24struct SpaceImage;
25struct UserDef;
26struct View3D;
27} // namespace blender
28
30
32class BlenderSync;
33class ImageMetaData;
34class Scene;
35class Session;
36
38 public:
42 bool preview_osl);
43
50 const int width,
51 int height);
52
54
55 /* session */
56 void create_session();
57 void free_session();
58
59 void reset_session(blender::Main &b_data, blender::Depsgraph &b_depsgraph);
60
61 /* offline render */
62 void render(blender::Depsgraph &b_depsgraph);
63
65
66 void bake(blender::Depsgraph &b_depsgraph_,
67 blender::Object &b_object,
68 const string &bake_type,
69 const int bake_filter,
70 const int bake_width,
71 const int bake_height);
72
73 void full_buffer_written(string_view filename);
74 /* interactive updates */
75 void synchronize(blender::Depsgraph &b_depsgraph);
76
77 /* drawing */
79 void view_draw(const int w, const int h);
80 void view_pause(const bool pause);
81 void tag_redraw();
82 void tag_update();
83 void get_status(string &status, string &substatus);
84 void get_progress(double &progress, double &total_time, double &render_time);
85 void test_cancel();
88
90 bool view_paused = false;
95
100 blender::Depsgraph *b_depsgraph;
101 /* NOTE: Blender's scene might become invalid after call
102 * #free_blender_memory_if_possible(). */
109
114
119
121
122 /* Global state which is common for all render sessions created from Blender.
123 * Usually denotes command line arguments.
124 */
126
127 /* Blender is running from the command line, no windows are shown and some
128 * extra render optimization is possible (possible to free draw-only data and
129 * so on.
130 */
131 static bool headless;
132
134
135 protected:
136 void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name);
137
138 /* Check whether session error happened.
139 * If so, it is reported to the render engine and true is returned.
140 * Otherwise false is returned. */
142
143 void builtin_images_load();
144
145 /* Is used after each render layer synchronization is done with the goal
146 * of freeing render engine data which is held from Blender side (for
147 * example, dependency graph).
148 */
150
152
153 struct {
154 thread_mutex mutex;
155 int last_pass_index = -1;
157
158 /* NOTE: The BlenderSession references the display driver. */
160
162
163 int bake_id = 0;
164};
165
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name)
static bool headless
blender::RenderData * b_render
static bool print_render_stats
blender::UserDef & b_userpref
bool check_and_report_session_error()
void full_buffer_written(string_view filename)
blender::RegionView3D * b_rv3d
vector< string > full_buffer_files_
blender::Depsgraph * b_depsgraph
void ensure_display_driver_if_needed()
blender::Scene * b_scene
void synchronize(blender::Depsgraph &b_depsgraph)
blender::Main * b_data
void view_pause(const bool pause)
void render(blender::Depsgraph &b_depsgraph)
void free_blender_memory_if_possible()
void bake(blender::Depsgraph &b_depsgraph_, blender::Object &b_object, const string &bake_type, const int bake_filter, const int bake_width, const int bake_height)
blender::View3D * b_v3d
void reset_session(blender::Main &b_data, blender::Depsgraph &b_depsgraph)
BlenderDisplayDriver * display_driver_
unique_ptr< BlenderSync > sync
blender::RenderEngine & b_engine
struct BlenderSession::@017120010147135111060124053166052341311215141251 draw_state_
void view_draw(const int w, const int h)
unique_ptr< Session > session
blender::bScreen * b_screen
BlenderSession(blender::RenderEngine &b_engine, blender::UserDef &b_userpref, blender::Main &b_data, bool preview_osl)
void get_status(string &status, string &substatus)
void get_progress(double &progress, double &total_time, double &render_time)
static DeviceTypeMask device_override
Definition scene.h:133
#define CCL_NAMESPACE_END
DeviceTypeMask
BMesh Iterators.
std::mutex thread_mutex
Definition thread.h:27