Blender  V2.93
blender_session.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __BLENDER_SESSION_H__
18 #define __BLENDER_SESSION_H__
19 
20 #include "RNA_blender_cpp.h"
21 
22 #include "device/device.h"
23 
24 #include "render/bake.h"
25 #include "render/scene.h"
26 #include "render/session.h"
27 
28 #include "util/util_vector.h"
29 
31 
32 class BlenderSync;
33 class ImageMetaData;
34 class Scene;
35 class Session;
36 class RenderBuffers;
37 class RenderTile;
38 
40  public:
42  BL::Preferences &b_userpref,
43  BL::BlendData &b_data,
44  bool preview_osl);
45 
47  BL::Preferences &b_userpref,
48  BL::BlendData &b_data,
49  BL::SpaceView3D &b_v3d,
51  int width,
52  int height);
53 
55 
56  /* session */
57  void create_session();
58  void free_session();
59 
60  void reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph);
61 
62  /* offline render */
64 
65  void bake(BL::Depsgraph &b_depsgrah,
66  BL::Object &b_object,
67  const string &pass_type,
68  const int custom_flag,
69  const int bake_width,
70  const int bake_height);
71 
72  void write_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile);
73  void write_render_tile(RenderTile &rtile);
74  void read_render_tile(RenderTile &rtile);
75 
76  /* update functions are used to update display buffer only after sample was rendered
77  * only needed for better visual feedback */
78  void update_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile);
79  void update_render_tile(RenderTile &rtile, bool highlight);
80 
81  /* interactive updates */
83 
84  /* drawing */
85  bool draw(int w, int h);
86  void tag_redraw();
87  void tag_update();
88  void get_status(string &status, string &substatus);
89  void get_kernel_status(string &kernel_status);
90  void get_progress(float &progress, double &total_time, double &render_time);
91  void test_cancel();
93  void update_bake_progress();
94 
95  bool background;
100 
102  BL::Preferences b_userpref;
103  BL::BlendData b_data;
104  BL::RenderSettings b_render;
106  /* NOTE: Blender's scene might become invalid after call
107  * free_blender_memory_if_possible().
108  */
110  BL::SpaceView3D b_v3d;
112  string b_rlay_name;
113  string b_rview_name;
114 
115  string last_status;
116  string last_error;
119 
120  int width, height;
123 
125 
126  /* Global state which is common for all render sessions created from Blender.
127  * Usually denotes command line arguments.
128  */
130 
131  /* Blender is running from the command line, no windows are shown and some
132  * extra render optimization is possible (possible to free draw-only data and
133  * so on.
134  */
135  static bool headless;
136 
137  /* ** Resumable render ** */
138 
139  /* Overall number of chunks in which the sample range is to be divided. */
141 
142  /* Current resumable chunk index to render. */
144 
145  /* Alternative to single-chunk rendering to render a range of chunks. */
148 
149  static bool print_render_stats;
150 
151  protected:
152  void stamp_view_layer_metadata(Scene *scene, const string &view_layer_name);
153 
155  RenderTile &rtile,
156  bool do_update_only);
158  bool do_update_only,
159  bool do_read_only,
160  bool highlight);
161 
162  void builtin_images_load();
163 
164  /* Update tile manager to reflect resumable render settings. */
165  void update_resumable_tile_manager(int num_samples);
166 
167  /* Is used after each render layer synchronization is done with the goal
168  * of freeing render engine data which is held from Blender side (for
169  * example, dependency graph).
170  */
172 };
173 
175 
176 #endif /* __BLENDER_SESSION_H__ */
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
struct Object Object
struct Scene Scene
struct RegionView3D RegionView3D
struct RenderEngine RenderEngine
struct RenderLayer RenderLayer
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)
void get_progress(float &progress, double &total_time, double &render_time)
BL::RenderSettings b_render
static bool headless
void get_kernel_status(string &kernel_status)
static bool print_render_stats
BL::RegionView3D b_rv3d
double start_resize_time
BL::RenderEngine b_engine
void synchronize(BL::Depsgraph &b_depsgraph)
static int end_resumable_chunk
void do_write_update_render_tile(RenderTile &rtile, bool do_update_only, bool do_read_only, bool highlight)
void write_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile)
void builtin_images_load()
void update_status_progress()
void * python_thread_state
void free_blender_memory_if_possible()
static int start_resumable_chunk
BL::Preferences b_userpref
void read_render_tile(RenderTile &rtile)
BlenderSync * sync
static int current_resumable_chunk
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)
BL::BlendData b_data
bool draw(int w, int h)
void update_render_tile(RenderTile &rtile, bool highlight)
Session * session
void render(BL::Depsgraph &b_depsgraph)
void write_render_tile(RenderTile &rtile)
BL::SpaceView3D b_v3d
void update_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile)
BlenderSession(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::BlendData &b_data, bool preview_osl)
void do_write_update_render_result(BL::RenderLayer &b_rlay, RenderTile &rtile, bool do_update_only)
static int num_resumable_chunks
double last_redraw_time
void get_status(string &status, string &substatus)
BL::Depsgraph b_depsgraph
static DeviceTypeMask device_override
void update_resumable_tile_manager(int num_samples)
DeviceTypeMask
Definition: device.h:54
#define CCL_NAMESPACE_END