diff options
author | Manuel Castilla <manzanillawork@gmail.com> | 2021-04-28 18:05:12 +0300 |
---|---|---|
committer | Manuel Castilla <manzanillawork@gmail.com> | 2021-04-28 18:13:04 +0300 |
commit | fff5aa5a9f72314fa43b680225b1c7eae98ddeed (patch) | |
tree | 5fa427f25a4c9544e8493034d0750fb60a861f12 /source/blender/compositor/intern/COM_NodeOperation.h | |
parent | 1b5b4b067e634b54149e371bd7f8f004fff2d1b3 (diff) |
[WIP] Compositor: Full-frame base system
This patch adds the base code needed to make the full-frame system work for both current tiled/per-pixel implementation of operations and full-frame.
Two execution models:
- Tiled: Current implementation. Renders execution groups in tiles from outputs to input. Not all operations are buffered. Runs the tiled/per-pixel implementation.
- FullFrame: All operations are buffered. Fully renders operations from inputs to outputs. Runs full-frame implementation of operations if available otherwise the current tiled/per-pixel. Creates output buffers on first read and free them as soon as all its readers have finished, reducing peak memory usage of complex/long trees.
This should allow us to convert operations to full-frame in small steps with the system already working and solve the problem of high memory usage.
FullFrame breaking changes respect Tiled system, mainly:
- Translate, Rotate, Scale, and Transform take effect immediately instead of next buffered operation.
- Any sampling is always done over inputs instead of last buffered operation.
Differential Revision: https://developer.blender.org/D11113
Diffstat (limited to 'source/blender/compositor/intern/COM_NodeOperation.h')
-rw-r--r-- | source/blender/compositor/intern/COM_NodeOperation.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index baf3a0878b9..7596cdcac68 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -39,6 +39,8 @@ namespace blender::compositor { class OpenCLDevice; class ReadBufferOperation; class WriteBufferOperation; +class OutputManager; +class ExecutionSystem; class NodeOperation; typedef NodeOperation SocketReader; @@ -232,6 +234,11 @@ struct NodeOperationFlags { */ bool use_datatype_conversion : 1; + /** + * Has this operation fullframe implementation. + */ + bool is_fullframe_operation : 1; + NodeOperationFlags() { complex = false; @@ -247,6 +254,7 @@ struct NodeOperationFlags { is_viewer_operation = false; is_preview_operation = false; use_datatype_conversion = true; + is_fullframe_operation = false; } }; @@ -537,9 +545,54 @@ class NodeOperation { return std::unique_ptr<MetaData>(); } + /*** Full-frame methods ***/ + /** + * Determines the areas this operation and its inputs need to render. Results are saved in the + * output manager. + */ + void determine_rects_to_render(const rcti &render_rect, OutputManager &output_man); + /** + * Determines the reads received by this operation and its inputs. Results are saved in the + * output manager. + */ + void determine_reads(OutputManager &output_man); + /** + * Renders this operation and its inputs. Rendered buffers are saved in the output manager. + */ + void render(ExecutionSystem &exec_system); + + private: + /** + * Renders this operation using the tiled implementation. + */ + void render_non_fullframe(MemoryBuffer *output_buf, + Span<rcti> render_rects, + blender::Span<MemoryBuffer *> inputs, + ExecutionSystem &exec_system); + protected: NodeOperation(); + /*** Full-frame methods ***/ + /** + * Executes operation updating output memory buffer. Single-threaded calls. + */ + virtual void update_memory_buffer(MemoryBuffer *UNUSED(output), + const rcti &UNUSED(output_rect), + blender::Span<MemoryBuffer *> UNUSED(inputs), + ExecutionSystem &UNUSED(exec_system)) + { + } + /** + * Get input area being read by this operation. + * + * Implementation don't need to ensure r_input_rect is within operation bounds. The caller must + * clamp it. + */ + virtual void get_input_area_of_interest(int input_idx, + const rcti &output_rect, + rcti &r_input_rect); + void addInputSocket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center); void addOutputSocket(DataType datatype); |