Blender  V3.3
COM_ExecutionGroup.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #pragma once
5 
6 #ifdef WITH_CXX_GUARDEDALLOC
7 # include "MEM_guardedalloc.h"
8 #endif
9 
10 #include <iostream>
11 
12 #include "BLI_array.hh"
13 #include "BLI_vector.hh"
14 
15 #include "COM_Enums.h"
16 #include "COM_WorkPackage.h"
17 
18 #include "DNA_node_types.h"
19 #include "DNA_vec_types.h"
20 
21 namespace blender::compositor {
22 
23 class ExecutionSystem;
24 class NodeOperation;
25 class MemoryProxy;
26 class MemoryBuffer;
27 class ReadBufferOperation;
28 
30  bool initialized : 1;
36  bool is_output : 1;
37  bool complex : 1;
38 
42  bool open_cl : 1;
43 
48  bool single_threaded : 1;
49 
51  {
52  initialized = false;
53  is_output = false;
54  complex = false;
55  open_cl = false;
56  single_threaded = false;
57  }
58 };
59 
60 std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags);
61 
69  private:
70  // fields
74  int id_;
75 
79  Vector<NodeOperation *> operations_;
80 
81  ExecutionGroupFlags flags_;
82 
86  unsigned int width_;
87 
91  unsigned int height_;
92 
97  unsigned int chunk_size_;
98 
102  unsigned int x_chunks_len_;
103 
107  unsigned int y_chunks_len_;
108 
112  unsigned int chunks_len_;
113 
118  unsigned int max_read_buffer_offset_;
119 
123  Vector<ReadBufferOperation *> read_operations_;
124 
130  const bNodeTree *bTree_;
131 
135  unsigned int chunks_finished_;
136 
140  Vector<WorkPackage> work_packages_;
141 
146  rcti viewer_border_;
147 
151  double execution_start_time_;
152 
153  // methods
158  bool can_contain(NodeOperation &operation);
159 
163  void determine_chunk_rect(rcti *r_rect, unsigned int x_chunk, unsigned int y_chunk) const;
164 
170  void init_number_of_chunks();
171 
183  bool schedule_chunk_when_possible(ExecutionSystem *graph, int chunk_x, int chunk_y);
184 
195  bool schedule_area_when_possible(ExecutionSystem *graph, rcti *area);
196 
201  bool schedule_chunk(unsigned int chunk_number);
202 
210  void determine_depending_area_of_interest(rcti *input,
211  ReadBufferOperation *read_operation,
212  rcti *output);
213 
217  blender::Array<unsigned int> get_execution_order() const;
218 
219  void init_read_buffer_operations();
220  void init_work_packages();
221 
222  public:
223  // constructors
224  ExecutionGroup(int id);
225 
226  int get_id() const
227  {
228  return id_;
229  }
230 
232  {
233  return flags_;
234  }
235 
236  // methods
245  bool add_operation(NodeOperation *operation);
246 
251  void set_output_execution_group(bool is_output)
252  {
253  flags_.is_output = is_output;
254  }
255 
260  void determine_resolution(unsigned int resolution[2]);
261 
266  void set_resolution(unsigned int resolution[2])
267  {
268  width_ = resolution[0];
269  height_ = resolution[1];
270  }
271 
275  unsigned int get_width() const
276  {
277  return width_;
278  }
279 
283  unsigned int get_height() const
284  {
285  return height_;
286  }
287 
293 
299 
304  void init_execution();
305 
312  MemoryBuffer **get_input_buffers_opencl(int chunk_number);
313 
321 
327  void finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers);
328 
333  void deinit_execution();
334 
356 
360  void determine_chunk_rect(rcti *r_rect, unsigned int chunk_number) const;
361 
362  void set_chunksize(int chunksize)
363  {
364  chunk_size_ = chunksize;
365  }
366 
372 
377  void set_viewer_border(float xmin, float xmax, float ymin, float ymax);
378 
379  void set_render_border(float xmin, float xmax, float ymin, float ymax);
380 
381  /* allow the DebugInfo class to look at internals */
382  friend class DebugInfo;
383 
384 #ifdef WITH_CXX_GUARDEDALLOC
385  MEM_CXX_CLASS_ALLOC_FUNCS("COM:ExecutionGroup")
386 #endif
387 };
388 
389 std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group);
390 
391 } // namespace blender::compositor
Read Guarded memory(de)allocation.
Class ExecutionGroup is a group of Operations that are executed as one. This grouping is used to comb...
void finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers)
after a chunk is executed the needed resources can be freed or unlocked.
void set_resolution(unsigned int resolution[2])
set the resolution of this executiongroup
void execute(ExecutionSystem *graph)
schedule an ExecutionGroup
bool add_operation(NodeOperation *operation)
add an operation to this ExecutionGroup
NodeOperation * get_output_operation() const
get the output operation of this ExecutionGroup
const ExecutionGroupFlags get_flags() const
MemoryBuffer * construct_consolidated_memory_buffer(MemoryProxy &memory_proxy, rcti &rect)
compose multiple chunks into a single chunk
MemoryBuffer ** get_input_buffers_opencl(int chunk_number)
get all inputbuffers needed to calculate an chunk
MemoryBuffer * allocate_output_buffer(rcti &rect)
allocate the outputbuffer of a chunk
void init_execution()
init_execution is called just before the execution of the whole graph will be done.
void set_output_execution_group(bool is_output)
set whether this ExecutionGroup is an output
eCompositorPriority get_render_priority()
get the Render priority of this ExecutionGroup
unsigned int get_height() const
get the height of this execution group
void determine_resolution(unsigned int resolution[2])
determine the resolution of this ExecutionGroup
unsigned int get_width() const
get the width of this execution group
void set_render_border(float xmin, float xmax, float ymin, float ymax)
void set_viewer_border(float xmin, float xmax, float ymin, float ymax)
set border for viewer operation
void deinit_execution()
deinit_execution is called just after execution the whole graph.
the ExecutionSystem contains the whole compositor tree.
a MemoryBuffer contains access to the data of a chunk
A MemoryProxy is a unique identifier for a memory buffer. A single MemoryProxy is used among all chun...
NodeOperation contains calculation logic.
Depsgraph * graph
eCompositorPriority
Possible priority settings.
Definition: COM_Enums.h:32
ccl_global KernelShaderEvalInput ccl_global float * output
ccl_global KernelShaderEvalInput * input
static void area(int d1, int d2, int e1, int e2, float weights[2])
std::ostream & operator<<(std::ostream &os, const eCompositorPriority &priority)
Definition: COM_Enums.cc:26