Blender V5.0
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 "RNA_blender_cpp.hh"
8
9#include "device/device.h"
10
11#include "scene/scene.h"
12#include "session/session.h"
13
14#include "util/unique_ptr.h"
15#include "util/vector.h"
16
18
20class BlenderSync;
21class ImageMetaData;
22class Scene;
23class Session;
24
26 public:
27 BlenderSession(BL::RenderEngine &b_engine,
28 BL::Preferences &b_userpref,
29 BL::BlendData &b_data,
30 bool preview_osl);
31
32 BlenderSession(BL::RenderEngine &b_engine,
33 BL::Preferences &b_userpref,
34 BL::BlendData &b_data,
35 BL::SpaceView3D &b_v3d,
36 BL::RegionView3D &b_rv3d,
37 const int width,
38 int height);
39
41
42 /* session */
43 void create_session();
44 void free_session();
45
46 void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph);
47
48 /* offline render */
49 void render(BL::Depsgraph &b_depsgraph);
50
52
53 void bake(BL::Depsgraph &b_depsgraph_,
54 BL::Object &b_object,
55 const string &bake_type,
56 const int bake_filter,
57 const int bake_width,
58 const int bake_height);
59
60 void full_buffer_written(string_view filename);
61 /* interactive updates */
62 void synchronize(BL::Depsgraph &b_depsgraph);
63
64 /* drawing */
65 void draw(BL::SpaceImageEditor &space_image);
66 void view_draw(const int w, const int h);
67 void tag_redraw();
68 void tag_update();
69 void get_status(string &status, string &substatus);
70 void get_progress(double &progress, double &total_time, double &render_time);
71 void test_cancel();
74
80
81 BL::RenderEngine b_engine;
82 BL::Preferences b_userpref;
83 BL::BlendData b_data;
84 BL::RenderSettings b_render;
85 BL::Depsgraph b_depsgraph;
86 /* NOTE: Blender's scene might become invalid after call
87 * #free_blender_memory_if_possible(). */
88 BL::Scene b_scene;
89 BL::SpaceView3D b_v3d;
90 BL::RegionView3D b_rv3d;
93
95 string last_error;
98
102
104
106
107 /* Global state which is common for all render sessions created from Blender.
108 * Usually denotes command line arguments.
109 */
111
112 /* Blender is running from the command line, no windows are shown and some
113 * extra render optimization is possible (possible to free draw-only data and
114 * so on.
115 */
116 static bool headless;
117
119
120 protected:
121 void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name);
122
123 /* Check whether session error happened.
124 * If so, it is reported to the render engine and true is returned.
125 * Otherwise false is returned. */
127
128 void builtin_images_load();
129
130 /* Is used after each render layer synchronization is done with the goal
131 * of freeing render engine data which is held from Blender side (for
132 * example, dependency graph).
133 */
135
137
138 struct {
142
143 /* NOTE: The BlenderSession references the display driver. */
145
147
148 int bake_id = 0;
149};
150
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
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 bake(BL::Depsgraph &b_depsgraph_, BL::Object &b_object, const string &bake_type, const int bake_filter, const int bake_width, const int bake_height)
void free_blender_memory_if_possible()
BL::Preferences b_userpref
void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph)
BlenderDisplayDriver * display_driver_
unique_ptr< BlenderSync > sync
struct BlenderSession::@354214365005032072334250106204100123257136110325 draw_state_
BL::BlendData b_data
void render(BL::Depsgraph &b_depsgraph)
void draw(BL::SpaceImageEditor &space_image)
void view_draw(const int w, const int h)
BL::SpaceView3D b_v3d
unique_ptr< Session > session
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
const int status
std::mutex thread_mutex
Definition thread.h:27
double total_time