Blender  V3.3
blender/session.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #ifndef __BLENDER_SESSION_H__
5 #define __BLENDER_SESSION_H__
6 
7 #include "MEM_guardedalloc.h"
8 
9 #include "RNA_blender_cpp.h"
10 
11 #include "device/device.h"
12 
13 #include "scene/bake.h"
14 #include "scene/scene.h"
15 #include "session/session.h"
16 
17 #include "util/vector.h"
18 
20 
22 class BlenderSync;
23 class ImageMetaData;
24 class Scene;
25 class Session;
26 
28  public:
30  BL::Preferences &b_userpref,
31  BL::BlendData &b_data,
32  bool preview_osl);
33 
35  BL::Preferences &b_userpref,
36  BL::BlendData &b_data,
37  BL::SpaceView3D &b_v3d,
39  int width,
40  int height);
41 
43 
44  /* session */
45  void create_session();
46  void free_session();
47 
48  void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph);
49 
50  /* offline render */
52 
53  void render_frame_finish();
54 
55  void bake(BL::Depsgraph &b_depsgrah,
56  BL::Object &b_object,
57  const string &pass_type,
58  const int custom_flag,
59  const int bake_width,
60  const int bake_height);
61 
62  void full_buffer_written(string_view filename);
63  /* interactive updates */
65 
66  /* drawing */
67  void draw(BL::SpaceImageEditor &space_image);
68  void view_draw(int w, int h);
69  void tag_redraw();
70  void tag_update();
71  void get_status(string &status, string &substatus);
72  void get_progress(double &progress, double &total_time, double &render_time);
73  void test_cancel();
75  void update_bake_progress();
76 
77  bool background;
82 
84  BL::Preferences b_userpref;
85  BL::BlendData b_data;
86  BL::RenderSettings b_render;
88  /* NOTE: Blender's scene might become invalid after call
89  * #free_blender_memory_if_possible(). */
91  BL::SpaceView3D b_v3d;
93  string b_rlay_name;
94  string b_rview_name;
95 
96  string last_status;
97  string last_error;
98  double last_progress;
100 
101  int width, height;
104 
106 
108 
109  /* Global state which is common for all render sessions created from Blender.
110  * Usually denotes command line arguments.
111  */
113 
114  /* Blender is running from the command line, no windows are shown and some
115  * extra render optimization is possible (possible to free draw-only data and
116  * so on.
117  */
118  static bool headless;
119 
120  static bool print_render_stats;
121 
122  protected:
123  void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name);
124 
125  /* Check whether session error happened.
126  * If so, it is reported to the render engine and true is returned.
127  * Otherwise false is returned. */
129 
130  void builtin_images_load();
131 
132  /* Is used after each render layer synchronization is done with the goal
133  * of freeing render engine data which is held from Blender side (for
134  * example, dependency graph).
135  */
137 
139 
140  struct {
142  int last_pass_index = -1;
144 
145  /* NOTE: The BlenderSession references the display driver. */
147 
149 
150  int bake_id = 0;
151 };
152 
154 
155 #endif /* __BLENDER_SESSION_H__ */
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
struct Object Object
struct Scene Scene
struct RegionView3D RegionView3D
Read Guarded memory(de)allocation.
struct RenderEngine RenderEngine
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()
double start_resize_time
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 builtin_images_load()
void update_status_progress()
void * python_thread_state
void free_blender_memory_if_possible()
void view_draw(int w, int h)
struct BlenderSession::@1229 draw_state_
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
Session * session
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)
double last_redraw_time
void get_status(string &status, string &substatus)
void get_progress(double &progress, double &total_time, double &render_time)
BL::Depsgraph b_depsgraph
BL::Scene b_scene
double last_status_time
static DeviceTypeMask device_override
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
DeviceTypeMask
Definition: device/device.h:48
CCL_NAMESPACE_BEGIN typedef std::mutex thread_mutex
Definition: thread.h:27