Blender  V3.3
COM_TiledExecutionModel.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation. */
3 
5 #include "COM_Debug.h"
6 #include "COM_ExecutionGroup.h"
8 #include "COM_WorkScheduler.h"
9 
10 #include "BLT_translation.h"
11 
12 #ifdef WITH_CXX_GUARDEDALLOC
13 # include "MEM_guardedalloc.h"
14 #endif
15 
16 namespace blender::compositor {
17 
19  Span<NodeOperation *> operations,
21  : ExecutionModel(context, operations), groups_(groups)
22 {
23  const bNodeTree *node_tree = context.get_bnodetree();
24  node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Determining resolution"));
25 
26  unsigned int resolution[2];
27  for (ExecutionGroup *group : groups_) {
28  resolution[0] = 0;
29  resolution[1] = 0;
30  group->determine_resolution(resolution);
31 
32  if (border_.use_render_border) {
33  const rctf *render_border = border_.render_border;
34  group->set_render_border(
36  }
37 
38  if (border_.use_viewer_border) {
39  const rctf *viewer_border = border_.viewer_border;
40  group->set_viewer_border(
42  }
43  }
44 }
45 
47 {
48  unsigned int order = 0;
49  for (NodeOperation *operation : operations) {
50  if (operation->get_flags().is_read_buffer_operation) {
51  ReadBufferOperation *read_operation = (ReadBufferOperation *)operation;
52  read_operation->set_offset(order);
53  order++;
54  }
55  }
56 }
57 
59  const bNodeTree *bTree)
60 {
61  for (NodeOperation *operation : operations) {
62  if (operation->get_flags().is_write_buffer_operation) {
63  operation->set_bnodetree(bTree);
64  operation->init_execution();
65  }
66  }
67 }
68 
70 {
71  for (NodeOperation *operation : operations) {
72  if (operation->get_flags().is_read_buffer_operation) {
73  ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation);
74  read_operation->update_memory_buffer();
75  }
76  }
77 }
78 
80  const bNodeTree *bTree)
81 {
82  for (NodeOperation *operation : operations) {
83  if (!operation->get_flags().is_write_buffer_operation) {
84  operation->set_bnodetree(bTree);
85  operation->init_execution();
86  }
87  }
88 }
89 
91  const int chunk_size)
92 {
93  for (ExecutionGroup *execution_group : groups) {
94  execution_group->set_chunksize(chunk_size);
95  execution_group->init_execution();
96  }
97 }
98 
100 {
101  const bNodeTree *editingtree = this->context_.get_bnodetree();
102 
103  editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | Initializing execution"));
104 
106 
111 
113  execute_groups(eCompositorPriority::High, exec_system);
114  if (!context_.is_fast_calculation()) {
115  execute_groups(eCompositorPriority::Medium, exec_system);
116  execute_groups(eCompositorPriority::Low, exec_system);
117  }
120 
121  editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | De-initializing execution"));
122 
123  for (NodeOperation *operation : operations_) {
124  operation->deinit_execution();
125  }
126 
127  for (ExecutionGroup *execution_group : groups_) {
128  execution_group->deinit_execution();
129  }
130 }
131 
132 void TiledExecutionModel::execute_groups(eCompositorPriority priority,
133  ExecutionSystem &exec_system)
134 {
135  for (ExecutionGroup *execution_group : groups_) {
136  if (execution_group->get_flags().is_output &&
137  execution_group->get_render_priority() == priority) {
138  execution_group->execute(&exec_system);
139  }
140  }
141 }
142 
143 } // namespace blender::compositor
#define TIP_(msgid)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint order
Read Guarded memory(de)allocation.
Overall context of the compositor.
const bNodeTree * get_bnodetree() const
get the bnodetree of the context
Class ExecutionGroup is a group of Operations that are executed as one. This grouping is used to comb...
struct blender::compositor::ExecutionModel::@178 border_
the ExecutionSystem contains the whole compositor tree.
NodeOperation contains calculation logic.
void execute(ExecutionSystem &exec_system) override
TiledExecutionModel(CompositorContext &context, Span< NodeOperation * > operations, Span< ExecutionGroup * > groups)
eCompositorPriority
Possible priority settings.
Definition: COM_Enums.h:32
static void init_non_write_operations_for_execution(Span< NodeOperation * > operations, const bNodeTree *bTree)
static void update_read_buffer_offset(Span< NodeOperation * > operations)
static void init_write_operations_for_execution(Span< NodeOperation * > operations, const bNodeTree *bTree)
static void init_execution_groups_for_execution(Span< ExecutionGroup * > groups, const int chunk_size)
static void link_write_buffers(Span< NodeOperation * > operations)
static const int chunk_size
void(* stats_draw)(void *, const char *str)
static void start(const CompositorContext &context)
Start the execution this methods will start the WorkScheduler. Inside this method all threads are ini...
static void finish()
wait for all work to be completed.
static void stop()
stop the execution All created thread by the start method are destroyed.
float xmax
Definition: DNA_vec_types.h:69
float xmin
Definition: DNA_vec_types.h:69
float ymax
Definition: DNA_vec_types.h:70
float ymin
Definition: DNA_vec_types.h:70