Blender V4.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#ifndef __BLENDER_SESSION_H__
6#define __BLENDER_SESSION_H__
7
8#include "MEM_guardedalloc.h"
9
10#include "RNA_blender_cpp.hh"
11
12#include "device/device.h"
13
14#include "scene/bake.h"
15#include "scene/scene.h"
16#include "session/session.h"
17
18#include "util/vector.h"
19
21
23class BlenderSync;
24class ImageMetaData;
25class Scene;
26class Session;
27
29 public:
30 BlenderSession(BL::RenderEngine &b_engine,
31 BL::Preferences &b_userpref,
32 BL::BlendData &b_data,
33 bool preview_osl);
34
35 BlenderSession(BL::RenderEngine &b_engine,
36 BL::Preferences &b_userpref,
37 BL::BlendData &b_data,
38 BL::SpaceView3D &b_v3d,
39 BL::RegionView3D &b_rv3d,
40 int width,
41 int height);
42
44
45 /* session */
46 void create_session();
47 void free_session();
48
49 void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph);
50
51 /* offline render */
52 void render(BL::Depsgraph &b_depsgraph);
53
55
56 void bake(BL::Depsgraph &b_depsgrah,
57 BL::Object &b_object,
58 const string &pass_type,
59 const int custom_flag,
60 const int bake_width,
61 const int bake_height);
62
63 void full_buffer_written(string_view filename);
64 /* interactive updates */
65 void synchronize(BL::Depsgraph &b_depsgraph);
66
67 /* drawing */
68 void draw(BL::SpaceImageEditor &space_image);
69 void view_draw(int w, int h);
70 void tag_redraw();
71 void tag_update();
72 void get_status(string &status, string &substatus);
73 void get_progress(double &progress, double &total_time, double &render_time);
74 void test_cancel();
77
83
84 BL::RenderEngine b_engine;
85 BL::Preferences b_userpref;
86 BL::BlendData b_data;
87 BL::RenderSettings b_render;
88 BL::Depsgraph b_depsgraph;
89 /* NOTE: Blender's scene might become invalid after call
90 * #free_blender_memory_if_possible(). */
91 BL::Scene b_scene;
92 BL::SpaceView3D b_v3d;
93 BL::RegionView3D b_rv3d;
96
98 string last_error;
101
105
107
109
110 /* Global state which is common for all render sessions created from Blender.
111 * Usually denotes command line arguments.
112 */
114
115 /* Blender is running from the command line, no windows are shown and some
116 * extra render optimization is possible (possible to free draw-only data and
117 * so on.
118 */
119 static bool headless;
120
122
123 protected:
124 void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name);
125
126 /* Check whether session error happened.
127 * If so, it is reported to the render engine and true is returned.
128 * Otherwise false is returned. */
130
131 void builtin_images_load();
132
133 /* Is used after each render layer synchronization is done with the goal
134 * of freeing render engine data which is held from Blender side (for
135 * example, dependency graph).
136 */
138
140
141 struct {
145
146 /* NOTE: The BlenderSession references the display driver. */
148
150
151 int bake_id = 0;
152};
153
155
156#endif /* __BLENDER_SESSION_H__ */
Read Guarded memory(de)allocation.
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)
BL::RenderSettings b_render
static bool headless
struct BlenderSession::@1415 draw_state_
thread_mutex mutex
static bool print_render_stats
BL::RegionView3D b_rv3d
bool check_and_report_session_error()
BL::RenderEngine b_engine
void full_buffer_written(string_view filename)
void synchronize(BL::Depsgraph &b_depsgraph)
vector< string > full_buffer_files_
void ensure_display_driver_if_needed()
void free_blender_memory_if_possible()
void view_draw(int w, int h)
BL::Preferences b_userpref
BlenderSync * sync
void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph)
void bake(BL::Depsgraph &b_depsgrah, BL::Object &b_object, const string &pass_type, const int custom_flag, const int bake_width, const int bake_height)
BlenderDisplayDriver * display_driver_
BL::BlendData b_data
void render(BL::Depsgraph &b_depsgraph)
void draw(BL::SpaceImageEditor &space_image)
BL::SpaceView3D b_v3d
BlenderSession(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::BlendData &b_data, bool preview_osl)
void get_status(string &status, string &substatus)
void get_progress(double &progress, double &total_time, double &render_time)
BL::Depsgraph b_depsgraph
static DeviceTypeMask device_override
#define CCL_NAMESPACE_END
DeviceTypeMask
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex
Definition thread.h:29
double total_time