Compare commits
4 Commits
temp-enum-
...
temp-compo
Author | SHA1 | Date | |
---|---|---|---|
4a22faf15a | |||
12a5a60557 | |||
a808c5ae65 | |||
c0995c27a8 |
@@ -74,8 +74,8 @@ extern "C" {
|
||||
*
|
||||
* during the preparation of the execution All ReadBufferOperation will receive an offset.
|
||||
* This offset is used during execution as an optimization trick
|
||||
* Next all operations will be initialized for execution \see NodeOperation.initExecution
|
||||
* Next all ExecutionGroup's will be initialized for execution \see ExecutionGroup.initExecution
|
||||
* Next all operations will be initialized for execution \see NodeOperation.init_execution
|
||||
* Next all ExecutionGroup's will be initialized for execution \see ExecutionGroup.init_execution
|
||||
* this all is controlled from \see ExecutionSystem.execute
|
||||
*
|
||||
* \section priority Render priority
|
||||
@@ -92,7 +92,7 @@ extern "C" {
|
||||
* When match the ExecutionGroup will be executed (this happens in serial)
|
||||
*
|
||||
* \see ExecutionSystem.execute control of the Render priority
|
||||
* \see NodeOperation.getRenderPriority receive the render priority
|
||||
* \see NodeOperation.get_render_priority receive the render priority
|
||||
* \see ExecutionGroup.execute the main loop to execute a whole ExecutionGroup
|
||||
*
|
||||
* \section order Chunk order
|
||||
@@ -121,7 +121,7 @@ extern "C" {
|
||||
* Chunk is finished.
|
||||
*
|
||||
* \see ExecutionGroup.execute
|
||||
* \see ViewerOperation.getChunkOrder
|
||||
* \see ViewerOperation.get_chunk_order
|
||||
* \see ChunkOrdering
|
||||
*
|
||||
* \section interest Area of interest
|
||||
@@ -152,13 +152,13 @@ extern "C" {
|
||||
*
|
||||
* In the above example ExecutionGroup B has an outputoperation (ViewerOperation)
|
||||
* and is being executed.
|
||||
* The first chunk is evaluated [@ref ExecutionGroup.scheduleChunkWhenPossible],
|
||||
* The first chunk is evaluated [@ref ExecutionGroup.schedule_chunk_when_possible],
|
||||
* but not all input chunks are available.
|
||||
* The relevant ExecutionGroup (that can calculate the missing chunks; ExecutionGroup A)
|
||||
* is asked to calculate the area ExecutionGroup B is missing.
|
||||
* [@ref ExecutionGroup.scheduleAreaWhenPossible]
|
||||
* [@ref ExecutionGroup.schedule_area_when_possible]
|
||||
* ExecutionGroup B checks what chunks the area spans, and tries to schedule these chunks.
|
||||
* If all input data is available these chunks are scheduled [@ref ExecutionGroup.scheduleChunk]
|
||||
* If all input data is available these chunks are scheduled [@ref ExecutionGroup.schedule_chunk]
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
@@ -171,18 +171,18 @@ extern "C" {
|
||||
* O------------------------------->O |
|
||||
* . O |
|
||||
* . O-------\ |
|
||||
* . . | ExecutionGroup.scheduleChunkWhenPossible
|
||||
* . . | ExecutionGroup.schedule_chunk_when_possible
|
||||
* . . O----/ (*) |
|
||||
* . . O |
|
||||
* . . O |
|
||||
* . . O ExecutionGroup.scheduleAreaWhenPossible|
|
||||
* . . O ExecutionGroup.schedule_area_when_possible|
|
||||
* . . O---------------------------------------->O
|
||||
* . . . O----------\ ExecutionGroup.scheduleChunkWhenPossible
|
||||
* . . . O----------\ ExecutionGroup.schedule_chunk_when_possible
|
||||
* . . . . | (*)
|
||||
* . . . . O-------/
|
||||
* . . . . O
|
||||
* . . . . O
|
||||
* . . . . O-------\ ExecutionGroup.scheduleChunk
|
||||
* . . . . O-------\ ExecutionGroup.schedule_chunk
|
||||
* . . . . . |
|
||||
* . . . . . O----/
|
||||
* . . . . O<=O
|
||||
@@ -198,7 +198,7 @@ extern "C" {
|
||||
* This happens until all chunks of (ExecutionGroup B) are finished executing or the user break's the process.
|
||||
*
|
||||
* NodeOperation like the ScaleOperation can influence the area of interest by reimplementing the
|
||||
* [@ref NodeOperation.determineAreaOfInterest] method
|
||||
* [@ref NodeOperation.determine_area_of_interest] method
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
@@ -221,13 +221,13 @@ extern "C" {
|
||||
*
|
||||
* \see ExecutionGroup.execute Execute a complete ExecutionGroup.
|
||||
* Halts until finished or breaked by user
|
||||
* \see ExecutionGroup.scheduleChunkWhenPossible Tries to schedule a single chunk,
|
||||
* \see ExecutionGroup.schedule_chunk_when_possible Tries to schedule a single chunk,
|
||||
* checks if all input data is available. Can trigger dependent chunks to be calculated
|
||||
* \see ExecutionGroup.scheduleAreaWhenPossible
|
||||
* \see ExecutionGroup.schedule_area_when_possible
|
||||
* Tries to schedule an area. This can be multiple chunks
|
||||
* (is called from [@ref ExecutionGroup.scheduleChunkWhenPossible])
|
||||
* \see ExecutionGroup.scheduleChunk Schedule a chunk on the WorkScheduler
|
||||
* \see NodeOperation.determineDependingAreaOfInterest Influence the area of interest of a chunk.
|
||||
* (is called from [@ref ExecutionGroup.schedule_chunk_when_possible])
|
||||
* \see ExecutionGroup.schedule_chunk Schedule a chunk on the WorkScheduler
|
||||
* \see NodeOperation.determine_depending_area_of_interest Influence the area of interest of a chunk.
|
||||
* \see WriteBufferOperation Operation to write to a MemoryProxy/MemoryBuffer
|
||||
* \see ReadBufferOperation Operation to read from a MemoryProxy/MemoryBuffer
|
||||
* \see MemoryProxy proxy for information about memory image
|
||||
@@ -283,16 +283,16 @@ extern "C" {
|
||||
* The OutputOperation of the ExecutionGroup is called to execute the area of the outputbuffer.
|
||||
*
|
||||
* \see ExecutionGroup
|
||||
* \see NodeOperation.executeRegion executes a single chunk of a NodeOperation
|
||||
* \see NodeOperation.execute_region executes a single chunk of a NodeOperation
|
||||
* \see CPUDevice.execute
|
||||
*
|
||||
* \subsection GPUDevice OpenCLDevice
|
||||
*
|
||||
* To be completed!
|
||||
* \see NodeOperation.executeOpenCLRegion
|
||||
* \see NodeOperation.execute_opencl_region
|
||||
* \see OpenCLDevice.execute
|
||||
*
|
||||
* \section executePixel executing a pixel
|
||||
* \section execute_pixel executing a pixel
|
||||
* Finally the last step, the node functionality :)
|
||||
*/
|
||||
|
||||
@@ -312,10 +312,10 @@ extern "C" {
|
||||
* (true) or editing (false).
|
||||
* based on this setting the system will work differently:
|
||||
* - during rendering only Composite & the File output node will be calculated
|
||||
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations
|
||||
* \see NodeOperation.is_output_program(int rendering) of the specific operations
|
||||
*
|
||||
* - during editing all output nodes will be calculated
|
||||
* \see NodeOperation.isOutputProgram(int rendering) of the specific operations
|
||||
* \see NodeOperation.is_output_program(int rendering) of the specific operations
|
||||
*
|
||||
* - another quality setting can be used bNodeTree.
|
||||
* The quality is determined by the bNodeTree fields.
|
||||
@@ -326,10 +326,10 @@ extern "C" {
|
||||
* - output nodes can have different priorities in the WorkScheduler.
|
||||
* This is implemented in the COM_execute function.
|
||||
*
|
||||
* \param viewSettings:
|
||||
* \param view_settings:
|
||||
* reference to view settings used for color management
|
||||
*
|
||||
* \param displaySettings:
|
||||
* \param display_settings:
|
||||
* reference to display settings used for color management
|
||||
*
|
||||
* OCIO_TODO: this options only used in rare cases, namely in output file node,
|
||||
@@ -343,13 +343,13 @@ void COM_execute(RenderData *render_data,
|
||||
Scene *scene,
|
||||
bNodeTree *node_tree,
|
||||
int rendering,
|
||||
const ColorManagedViewSettings *viewSettings,
|
||||
const ColorManagedDisplaySettings *displaySettings,
|
||||
const char *viewName);
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings,
|
||||
const char *view_name);
|
||||
|
||||
/**
|
||||
* \brief Deinitialize the compositor caches and allocated memory.
|
||||
* Use COM_clearCaches to only free the caches.
|
||||
* Use COM_clear_caches to only free the caches.
|
||||
*/
|
||||
void COM_deinitialize(void);
|
||||
|
||||
@@ -357,7 +357,7 @@ void COM_deinitialize(void);
|
||||
* \brief Clear all compositor caches. (Compositor system will still remain available).
|
||||
* To deinitialize the compositor use the COM_deinitialize method.
|
||||
*/
|
||||
// void COM_clearCaches(void); // NOT YET WRITTEN
|
||||
// void COM_clear_caches(void); // NOT YET WRITTEN
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "BLI_float2.hh"
|
||||
#include "BLI_index_range.hh"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
|
@@ -25,7 +25,7 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type)
|
||||
buffer_ = buffer;
|
||||
inflated_buffer_ = nullptr;
|
||||
set_canvas(buffer->get_rect());
|
||||
addOutputSocket(data_type);
|
||||
add_output_socket(data_type);
|
||||
flags.is_constant_operation = buffer_->is_a_single_elem();
|
||||
flags.is_fullframe_operation = false;
|
||||
}
|
||||
@@ -33,39 +33,42 @@ BufferOperation::BufferOperation(MemoryBuffer *buffer, DataType data_type)
|
||||
const float *BufferOperation::get_constant_elem()
|
||||
{
|
||||
BLI_assert(buffer_->is_a_single_elem());
|
||||
return buffer_->getBuffer();
|
||||
return buffer_->get_buffer();
|
||||
}
|
||||
|
||||
void BufferOperation::initExecution()
|
||||
void BufferOperation::init_execution()
|
||||
{
|
||||
if (buffer_->is_a_single_elem()) {
|
||||
initMutex();
|
||||
init_mutex();
|
||||
}
|
||||
}
|
||||
|
||||
void *BufferOperation::initializeTileData(rcti * /*rect*/)
|
||||
void *BufferOperation::initialize_tile_data(rcti * /*rect*/)
|
||||
{
|
||||
if (buffer_->is_a_single_elem() == false) {
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
lockMutex();
|
||||
lock_mutex();
|
||||
if (!inflated_buffer_) {
|
||||
inflated_buffer_ = buffer_->inflate();
|
||||
}
|
||||
unlockMutex();
|
||||
unlock_mutex();
|
||||
return inflated_buffer_;
|
||||
}
|
||||
|
||||
void BufferOperation::deinitExecution()
|
||||
void BufferOperation::deinit_execution()
|
||||
{
|
||||
if (buffer_->is_a_single_elem()) {
|
||||
deinitMutex();
|
||||
deinit_mutex();
|
||||
}
|
||||
delete inflated_buffer_;
|
||||
}
|
||||
|
||||
void BufferOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
|
||||
void BufferOperation::execute_pixel_sampled(float output[4],
|
||||
float x,
|
||||
float y,
|
||||
PixelSampler sampler)
|
||||
{
|
||||
switch (sampler) {
|
||||
case PixelSampler::Nearest:
|
||||
@@ -73,16 +76,16 @@ void BufferOperation::executePixelSampled(float output[4], float x, float y, Pix
|
||||
break;
|
||||
case PixelSampler::Bilinear:
|
||||
default:
|
||||
buffer_->readBilinear(output, x, y);
|
||||
buffer_->read_bilinear(output, x, y);
|
||||
break;
|
||||
case PixelSampler::Bicubic:
|
||||
/* No bicubic. Same implementation as ReadBufferOperation. */
|
||||
buffer_->readBilinear(output, x, y);
|
||||
buffer_->read_bilinear(output, x, y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BufferOperation::executePixelFiltered(
|
||||
void BufferOperation::execute_pixel_filtered(
|
||||
float output[4], float x, float y, float dx[2], float dy[2])
|
||||
{
|
||||
const float uv[2] = {x, y};
|
||||
|
@@ -31,11 +31,12 @@ class BufferOperation : public ConstantOperation {
|
||||
BufferOperation(MemoryBuffer *buffer, DataType data_type);
|
||||
|
||||
const float *get_constant_elem() override;
|
||||
void *initializeTileData(rcti *rect) override;
|
||||
void initExecution() override;
|
||||
void deinitExecution() override;
|
||||
void executePixelSampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
void executePixelFiltered(float output[4], float x, float y, float dx[2], float dy[2]) override;
|
||||
void *initialize_tile_data(rcti *rect) override;
|
||||
void init_execution() override;
|
||||
void deinit_execution() override;
|
||||
void execute_pixel_sampled(float output[4], float x, float y, PixelSampler sampler) override;
|
||||
void execute_pixel_filtered(
|
||||
float output[4], float x, float y, float dx[2], float dy[2]) override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include <iterator>
|
||||
|
||||
|
@@ -19,12 +19,11 @@
|
||||
#include "COM_CPUDevice.h"
|
||||
|
||||
#include "COM_ExecutionGroup.h"
|
||||
|
||||
#include "BLI_rect.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
CPUDevice::CPUDevice(int thread_id) : m_thread_id(thread_id)
|
||||
CPUDevice::CPUDevice(int thread_id) : thread_id_(thread_id)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,11 +31,11 @@ void CPUDevice::execute(WorkPackage *work_package)
|
||||
{
|
||||
switch (work_package->type) {
|
||||
case eWorkPackageType::Tile: {
|
||||
const unsigned int chunkNumber = work_package->chunk_number;
|
||||
ExecutionGroup *executionGroup = work_package->execution_group;
|
||||
const unsigned int chunk_number = work_package->chunk_number;
|
||||
ExecutionGroup *execution_group = work_package->execution_group;
|
||||
|
||||
executionGroup->getOutputOperation()->executeRegion(&work_package->rect, chunkNumber);
|
||||
executionGroup->finalizeChunkExecution(chunkNumber, nullptr);
|
||||
execution_group->get_output_operation()->execute_region(&work_package->rect, chunk_number);
|
||||
execution_group->finalize_chunk_execution(chunk_number, nullptr);
|
||||
break;
|
||||
}
|
||||
case eWorkPackageType::CustomFunction: {
|
||||
|
@@ -39,11 +39,11 @@ class CPUDevice : public Device {
|
||||
|
||||
int thread_id()
|
||||
{
|
||||
return m_thread_id;
|
||||
return thread_id_;
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_thread_id;
|
||||
int thread_id_;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -16,9 +16,9 @@
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include "COM_ChunkOrder.h"
|
||||
#include <cfloat>
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "COM_ChunkOrder.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
|
@@ -17,43 +17,38 @@
|
||||
*/
|
||||
|
||||
#include "COM_CompositorContext.h"
|
||||
#include "COM_defines.h"
|
||||
#include <cstdio>
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
CompositorContext::CompositorContext()
|
||||
{
|
||||
this->m_scene = nullptr;
|
||||
this->m_rd = nullptr;
|
||||
this->m_quality = eCompositorQuality::High;
|
||||
this->m_hasActiveOpenCLDevices = false;
|
||||
this->m_fastCalculation = false;
|
||||
this->m_viewSettings = nullptr;
|
||||
this->m_displaySettings = nullptr;
|
||||
this->m_bnodetree = nullptr;
|
||||
scene_ = nullptr;
|
||||
rd_ = nullptr;
|
||||
quality_ = eCompositorQuality::High;
|
||||
hasActiveOpenCLDevices_ = false;
|
||||
fast_calculation_ = false;
|
||||
view_settings_ = nullptr;
|
||||
display_settings_ = nullptr;
|
||||
bnodetree_ = nullptr;
|
||||
}
|
||||
|
||||
int CompositorContext::getFramenumber() const
|
||||
int CompositorContext::get_framenumber() const
|
||||
{
|
||||
BLI_assert(m_rd);
|
||||
return m_rd->cfra;
|
||||
BLI_assert(rd_);
|
||||
return rd_->cfra;
|
||||
}
|
||||
|
||||
Size2f CompositorContext::get_render_size() const
|
||||
{
|
||||
return {getRenderData()->xsch * getRenderPercentageAsFactor(),
|
||||
getRenderData()->ysch * getRenderPercentageAsFactor()};
|
||||
return {get_render_data()->xsch * get_render_percentage_as_factor(),
|
||||
get_render_data()->ysch * get_render_percentage_as_factor()};
|
||||
}
|
||||
|
||||
eExecutionModel CompositorContext::get_execution_model() const
|
||||
{
|
||||
if (U.experimental.use_full_frame_compositor) {
|
||||
BLI_assert(m_bnodetree != nullptr);
|
||||
switch (m_bnodetree->execution_mode) {
|
||||
BLI_assert(bnodetree_ != nullptr);
|
||||
switch (bnodetree_->execution_mode) {
|
||||
case 1:
|
||||
return eExecutionModel::FullFrame;
|
||||
case 0:
|
||||
|
@@ -18,16 +18,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_rect.h"
|
||||
|
||||
#include "COM_Enums.h"
|
||||
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
struct bNodeInstanceHash;
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
@@ -41,55 +38,55 @@ class CompositorContext {
|
||||
* editor) This field is initialized in ExecutionSystem and must only be read from that point
|
||||
* on. \see ExecutionSystem
|
||||
*/
|
||||
bool m_rendering;
|
||||
bool rendering_;
|
||||
|
||||
/**
|
||||
* \brief The quality of the composite.
|
||||
* This field is initialized in ExecutionSystem and must only be read from that point on.
|
||||
* \see ExecutionSystem
|
||||
*/
|
||||
eCompositorQuality m_quality;
|
||||
eCompositorQuality quality_;
|
||||
|
||||
Scene *m_scene;
|
||||
Scene *scene_;
|
||||
|
||||
/**
|
||||
* \brief Reference to the render data that is being composited.
|
||||
* This field is initialized in ExecutionSystem and must only be read from that point on.
|
||||
* \see ExecutionSystem
|
||||
*/
|
||||
RenderData *m_rd;
|
||||
RenderData *rd_;
|
||||
|
||||
/**
|
||||
* \brief reference to the bNodeTree
|
||||
* This field is initialized in ExecutionSystem and must only be read from that point on.
|
||||
* \see ExecutionSystem
|
||||
*/
|
||||
bNodeTree *m_bnodetree;
|
||||
bNodeTree *bnodetree_;
|
||||
|
||||
/**
|
||||
* \brief Preview image hash table
|
||||
* This field is initialized in ExecutionSystem and must only be read from that point on.
|
||||
*/
|
||||
bNodeInstanceHash *m_previews;
|
||||
bNodeInstanceHash *previews_;
|
||||
|
||||
/**
|
||||
* \brief does this system have active opencl devices?
|
||||
*/
|
||||
bool m_hasActiveOpenCLDevices;
|
||||
bool hasActiveOpenCLDevices_;
|
||||
|
||||
/**
|
||||
* \brief Skip slow nodes
|
||||
*/
|
||||
bool m_fastCalculation;
|
||||
bool fast_calculation_;
|
||||
|
||||
/* \brief color management settings */
|
||||
const ColorManagedViewSettings *m_viewSettings;
|
||||
const ColorManagedDisplaySettings *m_displaySettings;
|
||||
const ColorManagedViewSettings *view_settings_;
|
||||
const ColorManagedDisplaySettings *display_settings_;
|
||||
|
||||
/**
|
||||
* \brief active rendering view name
|
||||
*/
|
||||
const char *m_viewName;
|
||||
const char *view_name_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -100,192 +97,192 @@ class CompositorContext {
|
||||
/**
|
||||
* \brief set the rendering field of the context
|
||||
*/
|
||||
void setRendering(bool rendering)
|
||||
void set_rendering(bool rendering)
|
||||
{
|
||||
this->m_rendering = rendering;
|
||||
rendering_ = rendering;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the rendering field of the context
|
||||
*/
|
||||
bool isRendering() const
|
||||
bool is_rendering() const
|
||||
{
|
||||
return this->m_rendering;
|
||||
return rendering_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the scene of the context
|
||||
*/
|
||||
void setRenderData(RenderData *rd)
|
||||
void set_render_data(RenderData *rd)
|
||||
{
|
||||
this->m_rd = rd;
|
||||
rd_ = rd;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the bnodetree of the context
|
||||
*/
|
||||
void setbNodeTree(bNodeTree *bnodetree)
|
||||
void set_bnodetree(bNodeTree *bnodetree)
|
||||
{
|
||||
this->m_bnodetree = bnodetree;
|
||||
bnodetree_ = bnodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the bnodetree of the context
|
||||
*/
|
||||
const bNodeTree *getbNodeTree() const
|
||||
const bNodeTree *get_bnodetree() const
|
||||
{
|
||||
return this->m_bnodetree;
|
||||
return bnodetree_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the scene of the context
|
||||
*/
|
||||
const RenderData *getRenderData() const
|
||||
const RenderData *get_render_data() const
|
||||
{
|
||||
return this->m_rd;
|
||||
return rd_;
|
||||
}
|
||||
|
||||
void setScene(Scene *scene)
|
||||
void set_scene(Scene *scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
scene_ = scene;
|
||||
}
|
||||
Scene *getScene() const
|
||||
Scene *get_scene() const
|
||||
{
|
||||
return m_scene;
|
||||
return scene_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the preview image hash table
|
||||
*/
|
||||
void setPreviewHash(bNodeInstanceHash *previews)
|
||||
void set_preview_hash(bNodeInstanceHash *previews)
|
||||
{
|
||||
this->m_previews = previews;
|
||||
previews_ = previews;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the preview image hash table
|
||||
*/
|
||||
bNodeInstanceHash *getPreviewHash() const
|
||||
bNodeInstanceHash *get_preview_hash() const
|
||||
{
|
||||
return this->m_previews;
|
||||
return previews_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set view settings of color management
|
||||
*/
|
||||
void setViewSettings(const ColorManagedViewSettings *viewSettings)
|
||||
void set_view_settings(const ColorManagedViewSettings *view_settings)
|
||||
{
|
||||
this->m_viewSettings = viewSettings;
|
||||
view_settings_ = view_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get view settings of color management
|
||||
*/
|
||||
const ColorManagedViewSettings *getViewSettings() const
|
||||
const ColorManagedViewSettings *get_view_settings() const
|
||||
{
|
||||
return this->m_viewSettings;
|
||||
return view_settings_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set display settings of color management
|
||||
*/
|
||||
void setDisplaySettings(const ColorManagedDisplaySettings *displaySettings)
|
||||
void set_display_settings(const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
this->m_displaySettings = displaySettings;
|
||||
display_settings_ = display_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get display settings of color management
|
||||
*/
|
||||
const ColorManagedDisplaySettings *getDisplaySettings() const
|
||||
const ColorManagedDisplaySettings *get_display_settings() const
|
||||
{
|
||||
return this->m_displaySettings;
|
||||
return display_settings_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the quality
|
||||
*/
|
||||
void setQuality(eCompositorQuality quality)
|
||||
void set_quality(eCompositorQuality quality)
|
||||
{
|
||||
this->m_quality = quality;
|
||||
quality_ = quality;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the quality
|
||||
*/
|
||||
eCompositorQuality getQuality() const
|
||||
eCompositorQuality get_quality() const
|
||||
{
|
||||
return this->m_quality;
|
||||
return quality_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the current frame-number of the scene in this context
|
||||
*/
|
||||
int getFramenumber() const;
|
||||
int get_framenumber() const;
|
||||
|
||||
/**
|
||||
* \brief has this system active openclDevices?
|
||||
* \brief has this system active opencl_devices?
|
||||
*/
|
||||
bool getHasActiveOpenCLDevices() const
|
||||
bool get_has_active_opencl_devices() const
|
||||
{
|
||||
return this->m_hasActiveOpenCLDevices;
|
||||
return hasActiveOpenCLDevices_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set has this system active openclDevices?
|
||||
* \brief set has this system active opencl_devices?
|
||||
*/
|
||||
void setHasActiveOpenCLDevices(bool hasAvtiveOpenCLDevices)
|
||||
{
|
||||
this->m_hasActiveOpenCLDevices = hasAvtiveOpenCLDevices;
|
||||
hasActiveOpenCLDevices_ = hasAvtiveOpenCLDevices;
|
||||
}
|
||||
|
||||
/** Whether it has a view with a specific name and not the default one. */
|
||||
bool has_explicit_view() const
|
||||
{
|
||||
return m_viewName && m_viewName[0] != '\0';
|
||||
return view_name_ && view_name_[0] != '\0';
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the active rendering view
|
||||
*/
|
||||
const char *getViewName() const
|
||||
const char *get_view_name() const
|
||||
{
|
||||
return this->m_viewName;
|
||||
return view_name_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the active rendering view
|
||||
*/
|
||||
void setViewName(const char *viewName)
|
||||
void set_view_name(const char *view_name)
|
||||
{
|
||||
this->m_viewName = viewName;
|
||||
view_name_ = view_name;
|
||||
}
|
||||
|
||||
int getChunksize() const
|
||||
int get_chunksize() const
|
||||
{
|
||||
return this->getbNodeTree()->chunksize;
|
||||
return this->get_bnodetree()->chunksize;
|
||||
}
|
||||
|
||||
void setFastCalculation(bool fastCalculation)
|
||||
void set_fast_calculation(bool fast_calculation)
|
||||
{
|
||||
this->m_fastCalculation = fastCalculation;
|
||||
fast_calculation_ = fast_calculation;
|
||||
}
|
||||
bool isFastCalculation() const
|
||||
bool is_fast_calculation() const
|
||||
{
|
||||
return this->m_fastCalculation;
|
||||
return fast_calculation_;
|
||||
}
|
||||
bool isGroupnodeBufferEnabled() const
|
||||
bool is_groupnode_buffer_enabled() const
|
||||
{
|
||||
return (this->getbNodeTree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0;
|
||||
return (this->get_bnodetree()->flag & NTREE_COM_GROUPNODE_BUFFER) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the render percentage as a factor.
|
||||
* The compositor uses a factor i.o. a percentage.
|
||||
*/
|
||||
float getRenderPercentageAsFactor() const
|
||||
float get_render_percentage_as_factor() const
|
||||
{
|
||||
return m_rd->size * 0.01f;
|
||||
return rd_->size * 0.01f;
|
||||
}
|
||||
|
||||
Size2f get_render_size() const;
|
||||
|
@@ -16,10 +16,11 @@
|
||||
* Copyright 2021, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_set.hh"
|
||||
|
||||
#include "COM_ConstantFolder.h"
|
||||
#include "COM_ConstantOperation.h"
|
||||
#include "COM_NodeOperationBuilder.h"
|
||||
#include "COM_SetColorOperation.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
#include "COM_SetVectorOperation.h"
|
||||
@@ -43,7 +44,7 @@ ConstantFolder::ConstantFolder(NodeOperationBuilder &operations_builder)
|
||||
static bool is_constant_foldable(NodeOperation *operation)
|
||||
{
|
||||
if (operation->get_flags().can_be_constant && !operation->get_flags().is_constant_operation) {
|
||||
for (int i = 0; i < operation->getNumberOfInputSockets(); i++) {
|
||||
for (int i = 0; i < operation->get_number_of_input_sockets(); i++) {
|
||||
NodeOperation *input = operation->get_input_operation(i);
|
||||
if (!input->get_flags().is_constant_operation ||
|
||||
!static_cast<ConstantOperation *>(input)->can_get_constant_elem()) {
|
||||
@@ -71,17 +72,17 @@ static ConstantOperation *create_constant_operation(DataType data_type, const fl
|
||||
switch (data_type) {
|
||||
case DataType::Color: {
|
||||
SetColorOperation *color_op = new SetColorOperation();
|
||||
color_op->setChannels(constant_elem);
|
||||
color_op->set_channels(constant_elem);
|
||||
return color_op;
|
||||
}
|
||||
case DataType::Vector: {
|
||||
SetVectorOperation *vector_op = new SetVectorOperation();
|
||||
vector_op->setVector(constant_elem);
|
||||
vector_op->set_vector(constant_elem);
|
||||
return vector_op;
|
||||
}
|
||||
case DataType::Value: {
|
||||
SetValueOperation *value_op = new SetValueOperation();
|
||||
value_op->setValue(*constant_elem);
|
||||
value_op->set_value(*constant_elem);
|
||||
return value_op;
|
||||
}
|
||||
default: {
|
||||
@@ -93,7 +94,7 @@ static ConstantOperation *create_constant_operation(DataType data_type, const fl
|
||||
|
||||
ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation)
|
||||
{
|
||||
const DataType data_type = operation->getOutputSocket()->getDataType();
|
||||
const DataType data_type = operation->get_output_socket()->get_data_type();
|
||||
MemoryBuffer fold_buf(data_type, first_elem_area_);
|
||||
Vector<MemoryBuffer *> input_bufs = get_constant_input_buffers(operation);
|
||||
operation->init_data();
|
||||
@@ -101,7 +102,8 @@ ConstantOperation *ConstantFolder::fold_operation(NodeOperation *operation)
|
||||
|
||||
MemoryBuffer *constant_buf = create_constant_buffer(data_type);
|
||||
constant_buf->copy_from(&fold_buf, first_elem_area_);
|
||||
ConstantOperation *constant_op = create_constant_operation(data_type, constant_buf->getBuffer());
|
||||
ConstantOperation *constant_op = create_constant_operation(data_type,
|
||||
constant_buf->get_buffer());
|
||||
operations_builder_.replace_operation_with_constant(operation, constant_op);
|
||||
constant_buffers_.add_new(constant_op, constant_buf);
|
||||
return constant_op;
|
||||
@@ -116,14 +118,15 @@ MemoryBuffer *ConstantFolder::create_constant_buffer(const DataType data_type)
|
||||
|
||||
Vector<MemoryBuffer *> ConstantFolder::get_constant_input_buffers(NodeOperation *operation)
|
||||
{
|
||||
const int num_inputs = operation->getNumberOfInputSockets();
|
||||
const int num_inputs = operation->get_number_of_input_sockets();
|
||||
Vector<MemoryBuffer *> inputs_bufs(num_inputs);
|
||||
for (int i = 0; i < num_inputs; i++) {
|
||||
BLI_assert(operation->get_input_operation(i)->get_flags().is_constant_operation);
|
||||
ConstantOperation *constant_op = static_cast<ConstantOperation *>(
|
||||
operation->get_input_operation(i));
|
||||
MemoryBuffer *constant_buf = constant_buffers_.lookup_or_add_cb(constant_op, [=] {
|
||||
MemoryBuffer *buf = create_constant_buffer(constant_op->getOutputSocket()->getDataType());
|
||||
MemoryBuffer *buf = create_constant_buffer(
|
||||
constant_op->get_output_socket()->get_data_type());
|
||||
constant_op->render(buf, {first_elem_area_}, {});
|
||||
return buf;
|
||||
});
|
||||
@@ -185,8 +188,8 @@ void ConstantFolder::get_operation_output_operations(NodeOperation *operation,
|
||||
{
|
||||
const Vector<Link> &links = operations_builder_.get_links();
|
||||
for (const Link &link : links) {
|
||||
if (&link.from()->getOperation() == operation) {
|
||||
r_outputs.append(&link.to()->getOperation());
|
||||
if (&link.from()->get_operation() == operation) {
|
||||
r_outputs.append(&link.to()->get_operation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,16 +18,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_set.hh"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "COM_NodeOperationBuilder.h"
|
||||
#include "COM_defines.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class NodeOperation;
|
||||
class NodeOperationBuilder;
|
||||
class ConstantOperation;
|
||||
class MemoryBuffer;
|
||||
|
||||
|
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "BKE_node.h"
|
||||
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_NodeOperationBuilder.h"
|
||||
|
||||
#include "COM_AlphaOverNode.h"
|
||||
@@ -62,7 +61,6 @@
|
||||
#include "COM_DistanceMatteNode.h"
|
||||
#include "COM_DoubleEdgeMaskNode.h"
|
||||
#include "COM_EllipseMaskNode.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_FilterNode.h"
|
||||
#include "COM_FlipNode.h"
|
||||
#include "COM_GammaNode.h"
|
||||
@@ -435,8 +433,8 @@ Node *COM_convert_bnode(bNode *b_node)
|
||||
/* TODO(jbakker): make this an std::optional<NodeOperation>. */
|
||||
NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const NodeOperationInput &to)
|
||||
{
|
||||
const DataType src_data_type = from.getDataType();
|
||||
const DataType dst_data_type = to.getDataType();
|
||||
const DataType src_data_type = from.get_data_type();
|
||||
const DataType dst_data_type = to.get_data_type();
|
||||
|
||||
if (src_data_type == DataType::Value && dst_data_type == DataType::Color) {
|
||||
return new ConvertValueToColorOperation();
|
||||
@@ -461,24 +459,24 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const Node
|
||||
}
|
||||
|
||||
void COM_convert_canvas(NodeOperationBuilder &builder,
|
||||
NodeOperationOutput *fromSocket,
|
||||
NodeOperationInput *toSocket)
|
||||
NodeOperationOutput *from_socket,
|
||||
NodeOperationInput *to_socket)
|
||||
{
|
||||
/* Data type conversions are executed before resolutions to ensure convert operations have
|
||||
* resolution. This method have to ensure same datatypes are linked for new operations. */
|
||||
BLI_assert(fromSocket->getDataType() == toSocket->getDataType());
|
||||
BLI_assert(from_socket->get_data_type() == to_socket->get_data_type());
|
||||
|
||||
ResizeMode mode = toSocket->getResizeMode();
|
||||
ResizeMode mode = to_socket->get_resize_mode();
|
||||
BLI_assert(mode != ResizeMode::None);
|
||||
|
||||
NodeOperation *toOperation = &toSocket->getOperation();
|
||||
const float toWidth = toOperation->getWidth();
|
||||
const float toHeight = toOperation->getHeight();
|
||||
NodeOperation *fromOperation = &fromSocket->getOperation();
|
||||
const float fromWidth = fromOperation->getWidth();
|
||||
const float fromHeight = fromOperation->getHeight();
|
||||
bool doCenter = false;
|
||||
bool doScale = false;
|
||||
NodeOperation *to_operation = &to_socket->get_operation();
|
||||
const float to_width = to_operation->get_width();
|
||||
const float to_height = to_operation->get_height();
|
||||
NodeOperation *from_operation = &from_socket->get_operation();
|
||||
const float from_width = from_operation->get_width();
|
||||
const float from_height = from_operation->get_height();
|
||||
bool do_center = false;
|
||||
bool do_scale = false;
|
||||
float scaleX = 0;
|
||||
float scaleY = 0;
|
||||
|
||||
@@ -487,23 +485,23 @@ void COM_convert_canvas(NodeOperationBuilder &builder,
|
||||
case ResizeMode::Align:
|
||||
break;
|
||||
case ResizeMode::Center:
|
||||
doCenter = true;
|
||||
do_center = true;
|
||||
break;
|
||||
case ResizeMode::FitWidth:
|
||||
doCenter = true;
|
||||
doScale = true;
|
||||
scaleX = scaleY = toWidth / fromWidth;
|
||||
do_center = true;
|
||||
do_scale = true;
|
||||
scaleX = scaleY = to_width / from_width;
|
||||
break;
|
||||
case ResizeMode::FitHeight:
|
||||
doCenter = true;
|
||||
doScale = true;
|
||||
scaleX = scaleY = toHeight / fromHeight;
|
||||
do_center = true;
|
||||
do_scale = true;
|
||||
scaleX = scaleY = to_height / from_height;
|
||||
break;
|
||||
case ResizeMode::FitAny:
|
||||
doCenter = true;
|
||||
doScale = true;
|
||||
scaleX = toWidth / fromWidth;
|
||||
scaleY = toHeight / fromHeight;
|
||||
do_center = true;
|
||||
do_scale = true;
|
||||
scaleX = to_width / from_width;
|
||||
scaleY = to_height / from_height;
|
||||
if (scaleX < scaleY) {
|
||||
scaleX = scaleY;
|
||||
}
|
||||
@@ -512,81 +510,82 @@ void COM_convert_canvas(NodeOperationBuilder &builder,
|
||||
}
|
||||
break;
|
||||
case ResizeMode::Stretch:
|
||||
doCenter = true;
|
||||
doScale = true;
|
||||
scaleX = toWidth / fromWidth;
|
||||
scaleY = toHeight / fromHeight;
|
||||
do_center = true;
|
||||
do_scale = true;
|
||||
scaleX = to_width / from_width;
|
||||
scaleY = to_height / from_height;
|
||||
break;
|
||||
}
|
||||
|
||||
float addX = doCenter ? (toWidth - fromWidth) / 2.0f : 0.0f;
|
||||
float addY = doCenter ? (toHeight - fromHeight) / 2.0f : 0.0f;
|
||||
float addX = do_center ? (to_width - from_width) / 2.0f : 0.0f;
|
||||
float addY = do_center ? (to_height - from_height) / 2.0f : 0.0f;
|
||||
NodeOperation *first = nullptr;
|
||||
ScaleOperation *scaleOperation = nullptr;
|
||||
if (doScale) {
|
||||
scaleOperation = new ScaleRelativeOperation(fromSocket->getDataType());
|
||||
scaleOperation->getInputSocket(1)->setResizeMode(ResizeMode::None);
|
||||
scaleOperation->getInputSocket(2)->setResizeMode(ResizeMode::None);
|
||||
first = scaleOperation;
|
||||
ScaleOperation *scale_operation = nullptr;
|
||||
if (do_scale) {
|
||||
scale_operation = new ScaleRelativeOperation(from_socket->get_data_type());
|
||||
scale_operation->get_input_socket(1)->set_resize_mode(ResizeMode::None);
|
||||
scale_operation->get_input_socket(2)->set_resize_mode(ResizeMode::None);
|
||||
first = scale_operation;
|
||||
SetValueOperation *sxop = new SetValueOperation();
|
||||
sxop->setValue(scaleX);
|
||||
builder.addLink(sxop->getOutputSocket(), scaleOperation->getInputSocket(1));
|
||||
sxop->set_value(scaleX);
|
||||
builder.add_link(sxop->get_output_socket(), scale_operation->get_input_socket(1));
|
||||
SetValueOperation *syop = new SetValueOperation();
|
||||
syop->setValue(scaleY);
|
||||
builder.addLink(syop->getOutputSocket(), scaleOperation->getInputSocket(2));
|
||||
builder.addOperation(sxop);
|
||||
builder.addOperation(syop);
|
||||
syop->set_value(scaleY);
|
||||
builder.add_link(syop->get_output_socket(), scale_operation->get_input_socket(2));
|
||||
builder.add_operation(sxop);
|
||||
builder.add_operation(syop);
|
||||
|
||||
rcti scale_canvas = fromOperation->get_canvas();
|
||||
rcti scale_canvas = from_operation->get_canvas();
|
||||
if (builder.context().get_execution_model() == eExecutionModel::FullFrame) {
|
||||
ScaleOperation::scale_area(scale_canvas, scaleX, scaleY);
|
||||
scale_canvas.xmax = scale_canvas.xmin + toOperation->getWidth();
|
||||
scale_canvas.ymax = scale_canvas.ymin + toOperation->getHeight();
|
||||
scale_canvas.xmax = scale_canvas.xmin + to_operation->get_width();
|
||||
scale_canvas.ymax = scale_canvas.ymin + to_operation->get_height();
|
||||
addX = 0;
|
||||
addY = 0;
|
||||
}
|
||||
scaleOperation->set_canvas(scale_canvas);
|
||||
scale_operation->set_canvas(scale_canvas);
|
||||
sxop->set_canvas(scale_canvas);
|
||||
syop->set_canvas(scale_canvas);
|
||||
builder.addOperation(scaleOperation);
|
||||
builder.add_operation(scale_operation);
|
||||
}
|
||||
|
||||
TranslateOperation *translateOperation = new TranslateOperation(toSocket->getDataType());
|
||||
translateOperation->getInputSocket(1)->setResizeMode(ResizeMode::None);
|
||||
translateOperation->getInputSocket(2)->setResizeMode(ResizeMode::None);
|
||||
TranslateOperation *translate_operation = new TranslateOperation(to_socket->get_data_type());
|
||||
translate_operation->get_input_socket(1)->set_resize_mode(ResizeMode::None);
|
||||
translate_operation->get_input_socket(2)->set_resize_mode(ResizeMode::None);
|
||||
if (!first) {
|
||||
first = translateOperation;
|
||||
first = translate_operation;
|
||||
}
|
||||
SetValueOperation *xop = new SetValueOperation();
|
||||
xop->setValue(addX);
|
||||
builder.addLink(xop->getOutputSocket(), translateOperation->getInputSocket(1));
|
||||
xop->set_value(addX);
|
||||
builder.add_link(xop->get_output_socket(), translate_operation->get_input_socket(1));
|
||||
SetValueOperation *yop = new SetValueOperation();
|
||||
yop->setValue(addY);
|
||||
builder.addLink(yop->getOutputSocket(), translateOperation->getInputSocket(2));
|
||||
builder.addOperation(xop);
|
||||
builder.addOperation(yop);
|
||||
yop->set_value(addY);
|
||||
builder.add_link(yop->get_output_socket(), translate_operation->get_input_socket(2));
|
||||
builder.add_operation(xop);
|
||||
builder.add_operation(yop);
|
||||
|
||||
rcti translate_canvas = toOperation->get_canvas();
|
||||
rcti translate_canvas = to_operation->get_canvas();
|
||||
if (mode == ResizeMode::Align) {
|
||||
translate_canvas.xmax = translate_canvas.xmin + fromWidth;
|
||||
translate_canvas.ymax = translate_canvas.ymin + fromHeight;
|
||||
translate_canvas.xmax = translate_canvas.xmin + from_width;
|
||||
translate_canvas.ymax = translate_canvas.ymin + from_height;
|
||||
}
|
||||
translateOperation->set_canvas(translate_canvas);
|
||||
translate_operation->set_canvas(translate_canvas);
|
||||
xop->set_canvas(translate_canvas);
|
||||
yop->set_canvas(translate_canvas);
|
||||
builder.addOperation(translateOperation);
|
||||
builder.add_operation(translate_operation);
|
||||
|
||||
if (doScale) {
|
||||
translateOperation->getInputSocket(0)->setResizeMode(ResizeMode::None);
|
||||
builder.addLink(scaleOperation->getOutputSocket(), translateOperation->getInputSocket(0));
|
||||
if (do_scale) {
|
||||
translate_operation->get_input_socket(0)->set_resize_mode(ResizeMode::None);
|
||||
builder.add_link(scale_operation->get_output_socket(),
|
||||
translate_operation->get_input_socket(0));
|
||||
}
|
||||
|
||||
/* remove previous link and replace */
|
||||
builder.removeInputLink(toSocket);
|
||||
first->getInputSocket(0)->setResizeMode(ResizeMode::None);
|
||||
toSocket->setResizeMode(ResizeMode::None);
|
||||
builder.addLink(fromSocket, first->getInputSocket(0));
|
||||
builder.addLink(translateOperation->getOutputSocket(), toSocket);
|
||||
builder.remove_input_link(to_socket);
|
||||
first->get_input_socket(0)->set_resize_mode(ResizeMode::None);
|
||||
to_socket->set_resize_mode(ResizeMode::None);
|
||||
builder.add_link(from_socket, first->get_input_socket(0));
|
||||
builder.add_link(translate_operation->get_output_socket(), to_socket);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,8 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_NodeOperation.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
# include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
@@ -29,6 +27,7 @@ struct bNode;
|
||||
namespace blender::compositor {
|
||||
|
||||
class Node;
|
||||
class NodeOperation;
|
||||
class NodeOperationInput;
|
||||
class NodeOperationOutput;
|
||||
class NodeOperationBuilder;
|
||||
@@ -66,7 +65,7 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from,
|
||||
* \see InputSocketResizeMode for the possible conversions.
|
||||
*/
|
||||
void COM_convert_canvas(NodeOperationBuilder &builder,
|
||||
NodeOperationOutput *fromSocket,
|
||||
NodeOperationInput *toSocket);
|
||||
NodeOperationOutput *from_socket,
|
||||
NodeOperationInput *to_socket);
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,26 +18,16 @@
|
||||
|
||||
#include "COM_Debug.h"
|
||||
|
||||
#include <map>
|
||||
#include <typeinfo>
|
||||
#include <vector>
|
||||
|
||||
extern "C" {
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_path_util.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#include "BKE_appdir.h"
|
||||
#include "BKE_node.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "IMB_imbuf.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
}
|
||||
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_Node.h"
|
||||
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
#include "COM_ViewerOperation.h"
|
||||
@@ -45,12 +35,12 @@ extern "C" {
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
int DebugInfo::m_file_index = 0;
|
||||
DebugInfo::NodeNameMap DebugInfo::m_node_names;
|
||||
DebugInfo::OpNameMap DebugInfo::m_op_names;
|
||||
std::string DebugInfo::m_current_node_name;
|
||||
std::string DebugInfo::m_current_op_name;
|
||||
DebugInfo::GroupStateMap DebugInfo::m_group_states;
|
||||
int DebugInfo::file_index_ = 0;
|
||||
DebugInfo::NodeNameMap DebugInfo::node_names_;
|
||||
DebugInfo::OpNameMap DebugInfo::op_names_;
|
||||
std::string DebugInfo::current_node_name_;
|
||||
std::string DebugInfo::current_op_name_;
|
||||
DebugInfo::GroupStateMap DebugInfo::group_states_;
|
||||
|
||||
static std::string operation_class_name(const NodeOperation *op)
|
||||
{
|
||||
@@ -63,8 +53,8 @@ static std::string operation_class_name(const NodeOperation *op)
|
||||
|
||||
std::string DebugInfo::node_name(const Node *node)
|
||||
{
|
||||
NodeNameMap::const_iterator it = m_node_names.find(node);
|
||||
if (it != m_node_names.end()) {
|
||||
NodeNameMap::const_iterator it = node_names_.find(node);
|
||||
if (it != node_names_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return "";
|
||||
@@ -72,8 +62,8 @@ std::string DebugInfo::node_name(const Node *node)
|
||||
|
||||
std::string DebugInfo::operation_name(const NodeOperation *op)
|
||||
{
|
||||
OpNameMap::const_iterator it = m_op_names.find(op);
|
||||
if (it != m_op_names.end()) {
|
||||
OpNameMap::const_iterator it = op_names_.find(op);
|
||||
if (it != op_names_.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return "";
|
||||
@@ -90,14 +80,14 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
|
||||
std::string fillcolor = "gainsboro";
|
||||
if (operation->get_flags().is_viewer_operation) {
|
||||
const ViewerOperation *viewer = (const ViewerOperation *)operation;
|
||||
if (viewer->isActiveViewerOutput()) {
|
||||
if (viewer->is_active_viewer_output()) {
|
||||
fillcolor = "lightskyblue1";
|
||||
}
|
||||
else {
|
||||
fillcolor = "lightskyblue3";
|
||||
}
|
||||
}
|
||||
else if (operation->isOutputOperation(system->getContext().isRendering())) {
|
||||
else if (operation->is_output_operation(system->get_context().is_rendering())) {
|
||||
fillcolor = "dodgerblue1";
|
||||
}
|
||||
else if (operation->get_flags().is_set_operation) {
|
||||
@@ -122,16 +112,16 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
|
||||
" [fillcolor=%s,style=filled,shape=record,label=\"{",
|
||||
fillcolor.c_str());
|
||||
|
||||
int totinputs = operation->getNumberOfInputSockets();
|
||||
int totinputs = operation->get_number_of_input_sockets();
|
||||
if (totinputs != 0) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
|
||||
for (int k = 0; k < totinputs; k++) {
|
||||
NodeOperationInput *socket = operation->getInputSocket(k);
|
||||
NodeOperationInput *socket = operation->get_input_socket(k);
|
||||
if (k != 0) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
|
||||
}
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket);
|
||||
switch (socket->getDataType()) {
|
||||
switch (socket->get_data_type()) {
|
||||
case DataType::Value:
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
|
||||
break;
|
||||
@@ -166,20 +156,20 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
|
||||
operation->get_id(),
|
||||
operation->get_canvas().xmin,
|
||||
operation->get_canvas().ymin,
|
||||
operation->getWidth(),
|
||||
operation->getHeight());
|
||||
operation->get_width(),
|
||||
operation->get_height());
|
||||
|
||||
int totoutputs = operation->getNumberOfOutputSockets();
|
||||
int totoutputs = operation->get_number_of_output_sockets();
|
||||
if (totoutputs != 0) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "{");
|
||||
for (int k = 0; k < totoutputs; k++) {
|
||||
NodeOperationOutput *socket = operation->getOutputSocket(k);
|
||||
NodeOperationOutput *socket = operation->get_output_socket(k);
|
||||
if (k != 0) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "|");
|
||||
}
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket);
|
||||
switch (socket->getDataType()) {
|
||||
switch (socket->get_data_type()) {
|
||||
case DataType::Value: {
|
||||
ConstantOperation *constant = operation->get_flags().is_constant_operation ?
|
||||
static_cast<ConstantOperation *>(operation) :
|
||||
@@ -310,25 +300,25 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
|
||||
std::map<NodeOperation *, std::vector<std::string>> op_groups;
|
||||
int index = 0;
|
||||
for (const ExecutionGroup *group : system->m_groups) {
|
||||
for (const ExecutionGroup *group : system->groups_) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "// GROUP: %d\r\n", index);
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "subgraph cluster_%d{\r\n", index);
|
||||
/* used as a check for executing group */
|
||||
if (m_group_states[group] == EG_WAIT) {
|
||||
if (group_states_[group] == EG_WAIT) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=dashed\r\n");
|
||||
}
|
||||
else if (m_group_states[group] == EG_RUNNING) {
|
||||
else if (group_states_[group] == EG_RUNNING) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=firebrick1\r\n");
|
||||
}
|
||||
else if (m_group_states[group] == EG_FINISHED) {
|
||||
else if (group_states_[group] == EG_FINISHED) {
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "style=filled\r\n");
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "color=black\r\n");
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "fillcolor=chartreuse4\r\n");
|
||||
}
|
||||
|
||||
for (NodeOperation *operation : group->m_operations) {
|
||||
for (NodeOperation *operation : group->operations_) {
|
||||
|
||||
sprintf(strbuf, "_%p", group);
|
||||
op_groups[operation].push_back(std::string(strbuf));
|
||||
@@ -342,7 +332,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
}
|
||||
|
||||
/* operations not included in any group */
|
||||
for (NodeOperation *operation : system->m_operations) {
|
||||
for (NodeOperation *operation : system->operations_) {
|
||||
if (op_groups.find(operation) != op_groups.end()) {
|
||||
continue;
|
||||
}
|
||||
@@ -353,10 +343,10 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
system, operation, nullptr, str + len, maxlen > len ? maxlen - len : 0);
|
||||
}
|
||||
|
||||
for (NodeOperation *operation : system->m_operations) {
|
||||
for (NodeOperation *operation : system->operations_) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *read = (ReadBufferOperation *)operation;
|
||||
WriteBufferOperation *write = read->getMemoryProxy()->getWriteBufferOperation();
|
||||
WriteBufferOperation *write = read->get_memory_proxy()->get_write_buffer_operation();
|
||||
std::vector<std::string> &read_groups = op_groups[read];
|
||||
std::vector<std::string> &write_groups = op_groups[write];
|
||||
|
||||
@@ -374,16 +364,16 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
}
|
||||
}
|
||||
|
||||
for (NodeOperation *op : system->m_operations) {
|
||||
for (NodeOperationInput &to : op->m_inputs) {
|
||||
NodeOperationOutput *from = to.getLink();
|
||||
for (NodeOperation *op : system->operations_) {
|
||||
for (NodeOperationInput &to : op->inputs_) {
|
||||
NodeOperationOutput *from = to.get_link();
|
||||
|
||||
if (!from) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string color;
|
||||
switch (from->getDataType()) {
|
||||
switch (from->get_data_type()) {
|
||||
case DataType::Value:
|
||||
color = "gray";
|
||||
break;
|
||||
@@ -395,8 +385,8 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
break;
|
||||
}
|
||||
|
||||
NodeOperation *to_op = &to.getOperation();
|
||||
NodeOperation *from_op = &from->getOperation();
|
||||
NodeOperation *to_op = &to.get_operation();
|
||||
NodeOperation *from_op = &from->get_operation();
|
||||
std::vector<std::string> &from_groups = op_groups[from_op];
|
||||
std::vector<std::string> &to_groups = op_groups[to_op];
|
||||
|
||||
@@ -426,9 +416,9 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
|
||||
}
|
||||
}
|
||||
|
||||
const bool has_execution_groups = system->getContext().get_execution_model() ==
|
||||
const bool has_execution_groups = system->get_context().get_execution_model() ==
|
||||
eExecutionModel::Tiled &&
|
||||
system->m_groups.size() > 0;
|
||||
system->groups_.size() > 0;
|
||||
len += graphviz_legend(str + len, maxlen > len ? maxlen - len : 0, has_execution_groups);
|
||||
|
||||
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "}\r\n");
|
||||
@@ -447,13 +437,13 @@ void DebugInfo::graphviz(const ExecutionSystem *system, StringRefNull name)
|
||||
char filename[FILE_MAX];
|
||||
|
||||
if (name.is_empty()) {
|
||||
BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", m_file_index);
|
||||
BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", file_index_);
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(basename, (name + ".dot").c_str(), sizeof(basename));
|
||||
}
|
||||
BLI_join_dirfile(filename, sizeof(filename), BKE_tempdir_session(), basename);
|
||||
m_file_index++;
|
||||
file_index_++;
|
||||
|
||||
std::cout << "Writing compositor debug to: " << filename << "\n";
|
||||
|
||||
@@ -470,8 +460,8 @@ static std::string get_operations_export_dir()
|
||||
|
||||
void DebugInfo::export_operation(const NodeOperation *op, MemoryBuffer *render)
|
||||
{
|
||||
const int width = render->getWidth();
|
||||
const int height = render->getHeight();
|
||||
const int width = render->get_width();
|
||||
const int height = render->get_height();
|
||||
const int num_channels = render->get_num_channels();
|
||||
|
||||
ImBuf *ibuf = IMB_allocImBuf(width, height, 8 * num_channels, IB_rectfloat);
|
||||
|
@@ -21,9 +21,11 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_defines.h"
|
||||
#include "COM_MemoryBuffer.h"
|
||||
#include "COM_Node.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
@@ -34,6 +36,7 @@ static constexpr bool COM_GRAPHVIZ_SHOW_NODE_NAME = false;
|
||||
static constexpr bool COM_EXPORT_OPERATION_BUFFERS = false;
|
||||
|
||||
class Node;
|
||||
class NodeOperation;
|
||||
class ExecutionSystem;
|
||||
class ExecutionGroup;
|
||||
|
||||
@@ -49,33 +52,33 @@ class DebugInfo {
|
||||
static std::string operation_name(const NodeOperation *op);
|
||||
|
||||
private:
|
||||
static int m_file_index;
|
||||
static int file_index_;
|
||||
/** Map nodes to usable names for debug output. */
|
||||
static NodeNameMap m_node_names;
|
||||
static NodeNameMap node_names_;
|
||||
/** Map operations to usable names for debug output. */
|
||||
static OpNameMap m_op_names;
|
||||
static OpNameMap op_names_;
|
||||
/** Base name for all operations added by a node. */
|
||||
static std::string m_current_node_name;
|
||||
static std::string current_node_name_;
|
||||
/** Base name for automatic sub-operations. */
|
||||
static std::string m_current_op_name;
|
||||
static std::string current_op_name_;
|
||||
/** For visualizing group states. */
|
||||
static GroupStateMap m_group_states;
|
||||
static GroupStateMap group_states_;
|
||||
|
||||
public:
|
||||
static void convert_started()
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_op_names.clear();
|
||||
op_names_.clear();
|
||||
}
|
||||
}
|
||||
|
||||
static void execute_started(const ExecutionSystem *system)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_file_index = 1;
|
||||
m_group_states.clear();
|
||||
for (ExecutionGroup *execution_group : system->m_groups) {
|
||||
m_group_states[execution_group] = EG_WAIT;
|
||||
file_index_ = 1;
|
||||
group_states_.clear();
|
||||
for (ExecutionGroup *execution_group : system->groups_) {
|
||||
group_states_[execution_group] = EG_WAIT;
|
||||
}
|
||||
}
|
||||
if (COM_EXPORT_OPERATION_BUFFERS) {
|
||||
@@ -86,41 +89,41 @@ class DebugInfo {
|
||||
static void node_added(const Node *node)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_node_names[node] = std::string(node->getbNode() ? node->getbNode()->name : "");
|
||||
node_names_[node] = std::string(node->get_bnode() ? node->get_bnode()->name : "");
|
||||
}
|
||||
}
|
||||
|
||||
static void node_to_operations(const Node *node)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_current_node_name = m_node_names[node];
|
||||
current_node_name_ = node_names_[node];
|
||||
}
|
||||
}
|
||||
|
||||
static void operation_added(const NodeOperation *operation)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_op_names[operation] = m_current_node_name;
|
||||
op_names_[operation] = current_node_name_;
|
||||
}
|
||||
};
|
||||
|
||||
static void operation_read_write_buffer(const NodeOperation *operation)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_current_op_name = m_op_names[operation];
|
||||
current_op_name_ = op_names_[operation];
|
||||
}
|
||||
};
|
||||
|
||||
static void execution_group_started(const ExecutionGroup *group)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_group_states[group] = EG_RUNNING;
|
||||
group_states_[group] = EG_RUNNING;
|
||||
}
|
||||
};
|
||||
static void execution_group_finished(const ExecutionGroup *group)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
m_group_states[group] = EG_FINISHED;
|
||||
group_states_[group] = EG_FINISHED;
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -18,10 +18,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_WorkPackage.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
struct WorkPackage;
|
||||
|
||||
/**
|
||||
* \brief Abstract class for device implementations to be used by the Compositor.
|
||||
* devices are queried, initialized and used by the WorkScheduler.
|
||||
|
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "COM_Enums.h"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
|
@@ -16,36 +16,21 @@
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <sstream>
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_ChunkOrder.h"
|
||||
#include "COM_Debug.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
#include "COM_ViewerOperation.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
#include "COM_WriteBufferOperation.h"
|
||||
#include "COM_defines.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_rand.hh"
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags)
|
||||
@@ -70,36 +55,36 @@ std::ostream &operator<<(std::ostream &os, const ExecutionGroupFlags &flags)
|
||||
|
||||
ExecutionGroup::ExecutionGroup(int id)
|
||||
{
|
||||
m_id = id;
|
||||
this->m_bTree = nullptr;
|
||||
this->m_height = 0;
|
||||
this->m_width = 0;
|
||||
this->m_max_read_buffer_offset = 0;
|
||||
this->m_x_chunks_len = 0;
|
||||
this->m_y_chunks_len = 0;
|
||||
this->m_chunks_len = 0;
|
||||
this->m_chunks_finished = 0;
|
||||
BLI_rcti_init(&this->m_viewerBorder, 0, 0, 0, 0);
|
||||
this->m_executionStartTime = 0;
|
||||
id_ = id;
|
||||
bTree_ = nullptr;
|
||||
height_ = 0;
|
||||
width_ = 0;
|
||||
max_read_buffer_offset_ = 0;
|
||||
x_chunks_len_ = 0;
|
||||
y_chunks_len_ = 0;
|
||||
chunks_len_ = 0;
|
||||
chunks_finished_ = 0;
|
||||
BLI_rcti_init(&viewer_border_, 0, 0, 0, 0);
|
||||
execution_start_time_ = 0;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const ExecutionGroup &execution_group)
|
||||
{
|
||||
os << "ExecutionGroup(id=" << execution_group.get_id();
|
||||
os << ",flags={" << execution_group.get_flags() << "}";
|
||||
os << ",operation=" << *execution_group.getOutputOperation() << "";
|
||||
os << ",operation=" << *execution_group.get_output_operation() << "";
|
||||
os << ")";
|
||||
return os;
|
||||
}
|
||||
|
||||
eCompositorPriority ExecutionGroup::getRenderPriority()
|
||||
eCompositorPriority ExecutionGroup::get_render_priority()
|
||||
{
|
||||
return this->getOutputOperation()->getRenderPriority();
|
||||
return this->get_output_operation()->get_render_priority();
|
||||
}
|
||||
|
||||
bool ExecutionGroup::can_contain(NodeOperation &operation)
|
||||
{
|
||||
if (!m_flags.initialized) {
|
||||
if (!flags_.initialized) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -114,7 +99,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
|
||||
}
|
||||
|
||||
/* complex groups don't allow further ops (except read buffer and values, see above) */
|
||||
if (m_flags.complex) {
|
||||
if (flags_.complex) {
|
||||
return false;
|
||||
}
|
||||
/* complex ops can't be added to other groups (except their own, which they initialize, see
|
||||
@@ -126,7 +111,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExecutionGroup::addOperation(NodeOperation *operation)
|
||||
bool ExecutionGroup::add_operation(NodeOperation *operation)
|
||||
{
|
||||
if (!can_contain(*operation)) {
|
||||
return false;
|
||||
@@ -134,34 +119,34 @@ bool ExecutionGroup::addOperation(NodeOperation *operation)
|
||||
|
||||
if (!operation->get_flags().is_read_buffer_operation &&
|
||||
!operation->get_flags().is_write_buffer_operation) {
|
||||
m_flags.complex = operation->get_flags().complex;
|
||||
m_flags.open_cl = operation->get_flags().open_cl;
|
||||
m_flags.single_threaded = operation->get_flags().single_threaded;
|
||||
m_flags.initialized = true;
|
||||
flags_.complex = operation->get_flags().complex;
|
||||
flags_.open_cl = operation->get_flags().open_cl;
|
||||
flags_.single_threaded = operation->get_flags().single_threaded;
|
||||
flags_.initialized = true;
|
||||
}
|
||||
|
||||
m_operations.append(operation);
|
||||
operations_.append(operation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
NodeOperation *ExecutionGroup::getOutputOperation() const
|
||||
NodeOperation *ExecutionGroup::get_output_operation() const
|
||||
{
|
||||
return this
|
||||
->m_operations[0]; /* the first operation of the group is always the output operation. */
|
||||
->operations_[0]; /* the first operation of the group is always the output operation. */
|
||||
}
|
||||
|
||||
void ExecutionGroup::init_work_packages()
|
||||
{
|
||||
m_work_packages.clear();
|
||||
if (this->m_chunks_len != 0) {
|
||||
m_work_packages.resize(this->m_chunks_len);
|
||||
for (unsigned int index = 0; index < m_chunks_len; index++) {
|
||||
m_work_packages[index].type = eWorkPackageType::Tile;
|
||||
m_work_packages[index].state = eWorkPackageState::NotScheduled;
|
||||
m_work_packages[index].execution_group = this;
|
||||
m_work_packages[index].chunk_number = index;
|
||||
determineChunkRect(&m_work_packages[index].rect, index);
|
||||
work_packages_.clear();
|
||||
if (chunks_len_ != 0) {
|
||||
work_packages_.resize(chunks_len_);
|
||||
for (unsigned int index = 0; index < chunks_len_; index++) {
|
||||
work_packages_[index].type = eWorkPackageType::Tile;
|
||||
work_packages_[index].state = eWorkPackageState::NotScheduled;
|
||||
work_packages_[index].execution_group = this;
|
||||
work_packages_[index].chunk_number = index;
|
||||
determine_chunk_rect(&work_packages_[index].rect, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,68 +154,68 @@ void ExecutionGroup::init_work_packages()
|
||||
void ExecutionGroup::init_read_buffer_operations()
|
||||
{
|
||||
unsigned int max_offset = 0;
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation);
|
||||
this->m_read_operations.append(readOperation);
|
||||
max_offset = MAX2(max_offset, readOperation->getOffset());
|
||||
ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation);
|
||||
read_operations_.append(read_operation);
|
||||
max_offset = MAX2(max_offset, read_operation->get_offset());
|
||||
}
|
||||
}
|
||||
max_offset++;
|
||||
this->m_max_read_buffer_offset = max_offset;
|
||||
max_read_buffer_offset_ = max_offset;
|
||||
}
|
||||
|
||||
void ExecutionGroup::initExecution()
|
||||
void ExecutionGroup::init_execution()
|
||||
{
|
||||
init_number_of_chunks();
|
||||
init_work_packages();
|
||||
init_read_buffer_operations();
|
||||
}
|
||||
|
||||
void ExecutionGroup::deinitExecution()
|
||||
void ExecutionGroup::deinit_execution()
|
||||
{
|
||||
m_work_packages.clear();
|
||||
this->m_chunks_len = 0;
|
||||
this->m_x_chunks_len = 0;
|
||||
this->m_y_chunks_len = 0;
|
||||
this->m_read_operations.clear();
|
||||
this->m_bTree = nullptr;
|
||||
work_packages_.clear();
|
||||
chunks_len_ = 0;
|
||||
x_chunks_len_ = 0;
|
||||
y_chunks_len_ = 0;
|
||||
read_operations_.clear();
|
||||
bTree_ = nullptr;
|
||||
}
|
||||
|
||||
void ExecutionGroup::determineResolution(unsigned int resolution[2])
|
||||
void ExecutionGroup::determine_resolution(unsigned int resolution[2])
|
||||
{
|
||||
NodeOperation *operation = this->getOutputOperation();
|
||||
resolution[0] = operation->getWidth();
|
||||
resolution[1] = operation->getHeight();
|
||||
this->setResolution(resolution);
|
||||
BLI_rcti_init(&this->m_viewerBorder, 0, this->m_width, 0, this->m_height);
|
||||
NodeOperation *operation = this->get_output_operation();
|
||||
resolution[0] = operation->get_width();
|
||||
resolution[1] = operation->get_height();
|
||||
this->set_resolution(resolution);
|
||||
BLI_rcti_init(&viewer_border_, 0, width_, 0, height_);
|
||||
}
|
||||
|
||||
void ExecutionGroup::init_number_of_chunks()
|
||||
{
|
||||
if (this->m_flags.single_threaded) {
|
||||
this->m_x_chunks_len = 1;
|
||||
this->m_y_chunks_len = 1;
|
||||
this->m_chunks_len = 1;
|
||||
if (flags_.single_threaded) {
|
||||
x_chunks_len_ = 1;
|
||||
y_chunks_len_ = 1;
|
||||
chunks_len_ = 1;
|
||||
}
|
||||
else {
|
||||
const float chunkSizef = this->m_chunkSize;
|
||||
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
|
||||
this->m_x_chunks_len = ceil(border_width / chunkSizef);
|
||||
this->m_y_chunks_len = ceil(border_height / chunkSizef);
|
||||
this->m_chunks_len = this->m_x_chunks_len * this->m_y_chunks_len;
|
||||
const float chunk_sizef = chunk_size_;
|
||||
const int border_width = BLI_rcti_size_x(&viewer_border_);
|
||||
const int border_height = BLI_rcti_size_y(&viewer_border_);
|
||||
x_chunks_len_ = ceil(border_width / chunk_sizef);
|
||||
y_chunks_len_ = ceil(border_height / chunk_sizef);
|
||||
chunks_len_ = x_chunks_len_ * y_chunks_len_;
|
||||
}
|
||||
}
|
||||
|
||||
blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
{
|
||||
blender::Array<unsigned int> chunk_order(m_chunks_len);
|
||||
for (int chunk_index = 0; chunk_index < this->m_chunks_len; chunk_index++) {
|
||||
blender::Array<unsigned int> chunk_order(chunks_len_);
|
||||
for (int chunk_index = 0; chunk_index < chunks_len_; chunk_index++) {
|
||||
chunk_order[chunk_index] = chunk_index;
|
||||
}
|
||||
|
||||
NodeOperation *operation = this->getOutputOperation();
|
||||
NodeOperation *operation = this->get_output_operation();
|
||||
float centerX = 0.5f;
|
||||
float centerY = 0.5f;
|
||||
ChunkOrdering order_type = ChunkOrdering::Default;
|
||||
@@ -239,11 +224,11 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
ViewerOperation *viewer = (ViewerOperation *)operation;
|
||||
centerX = viewer->getCenterX();
|
||||
centerY = viewer->getCenterY();
|
||||
order_type = viewer->getChunkOrder();
|
||||
order_type = viewer->get_chunk_order();
|
||||
}
|
||||
|
||||
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
|
||||
const int border_width = BLI_rcti_size_x(&viewer_border_);
|
||||
const int border_height = BLI_rcti_size_y(&viewer_border_);
|
||||
int index;
|
||||
switch (order_type) {
|
||||
case ChunkOrdering::Random: {
|
||||
@@ -256,17 +241,17 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
}
|
||||
case ChunkOrdering::CenterOut: {
|
||||
ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f);
|
||||
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
const WorkPackage &work_package = m_work_packages[index];
|
||||
blender::Array<ChunkOrder> chunk_orders(chunks_len_);
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
const WorkPackage &work_package = work_packages_[index];
|
||||
chunk_orders[index].index = index;
|
||||
chunk_orders[index].x = work_package.rect.xmin - this->m_viewerBorder.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - this->m_viewerBorder.ymin;
|
||||
chunk_orders[index].x = work_package.rect.xmin - viewer_border_.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - viewer_border_.ymin;
|
||||
chunk_orders[index].update_distance(&hotspot, 1);
|
||||
}
|
||||
|
||||
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len - 1]);
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
std::sort(&chunk_orders[0], &chunk_orders[chunks_len_ - 1]);
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
chunk_order[index] = chunk_orders[index].index;
|
||||
}
|
||||
|
||||
@@ -279,7 +264,7 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
unsigned int my = border_height / 2;
|
||||
unsigned int bx = mx + 2 * tx;
|
||||
unsigned int by = my + 2 * ty;
|
||||
float addition = this->m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER;
|
||||
float addition = chunks_len_ / COM_RULE_OF_THIRDS_DIVIDER;
|
||||
|
||||
ChunkOrderHotspot hotspots[9]{
|
||||
ChunkOrderHotspot(mx, my, addition * 0),
|
||||
@@ -293,18 +278,18 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
ChunkOrderHotspot(mx, by, addition * 8),
|
||||
};
|
||||
|
||||
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
const WorkPackage &work_package = m_work_packages[index];
|
||||
blender::Array<ChunkOrder> chunk_orders(chunks_len_);
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
const WorkPackage &work_package = work_packages_[index];
|
||||
chunk_orders[index].index = index;
|
||||
chunk_orders[index].x = work_package.rect.xmin - this->m_viewerBorder.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - this->m_viewerBorder.ymin;
|
||||
chunk_orders[index].x = work_package.rect.xmin - viewer_border_.xmin;
|
||||
chunk_orders[index].y = work_package.rect.ymin - viewer_border_.ymin;
|
||||
chunk_orders[index].update_distance(hotspots, 9);
|
||||
}
|
||||
|
||||
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len]);
|
||||
std::sort(&chunk_orders[0], &chunk_orders[chunks_len_]);
|
||||
|
||||
for (index = 0; index < this->m_chunks_len; index++) {
|
||||
for (index = 0; index < chunks_len_; index++) {
|
||||
chunk_order[index] = chunk_orders[index].index;
|
||||
}
|
||||
|
||||
@@ -323,23 +308,23 @@ blender::Array<unsigned int> ExecutionGroup::get_execution_order() const
|
||||
*/
|
||||
void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
{
|
||||
const CompositorContext &context = graph->getContext();
|
||||
const bNodeTree *bTree = context.getbNodeTree();
|
||||
if (this->m_width == 0 || this->m_height == 0) {
|
||||
const CompositorContext &context = graph->get_context();
|
||||
const bNodeTree *bTree = context.get_bnodetree();
|
||||
if (width_ == 0 || height_ == 0) {
|
||||
return;
|
||||
} /** \note Break out... no pixels to calculate. */
|
||||
if (bTree->test_break && bTree->test_break(bTree->tbh)) {
|
||||
return;
|
||||
} /** \note Early break out for blur and preview nodes. */
|
||||
if (this->m_chunks_len == 0) {
|
||||
if (chunks_len_ == 0) {
|
||||
return;
|
||||
} /** \note Early break out. */
|
||||
unsigned int chunk_index;
|
||||
|
||||
this->m_executionStartTime = PIL_check_seconds_timer();
|
||||
execution_start_time_ = PIL_check_seconds_timer();
|
||||
|
||||
this->m_chunks_finished = 0;
|
||||
this->m_bTree = bTree;
|
||||
chunks_finished_ = 0;
|
||||
bTree_ = bTree;
|
||||
|
||||
blender::Array<unsigned int> chunk_order = get_execution_order();
|
||||
|
||||
@@ -348,27 +333,26 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
|
||||
bool breaked = false;
|
||||
bool finished = false;
|
||||
unsigned int startIndex = 0;
|
||||
const int maxNumberEvaluated = BLI_system_thread_count() * 2;
|
||||
unsigned int start_index = 0;
|
||||
const int max_number_evaluated = BLI_system_thread_count() * 2;
|
||||
|
||||
while (!finished && !breaked) {
|
||||
bool startEvaluated = false;
|
||||
bool start_evaluated = false;
|
||||
finished = true;
|
||||
int numberEvaluated = 0;
|
||||
int number_evaluated = 0;
|
||||
|
||||
for (int index = startIndex;
|
||||
index < this->m_chunks_len && numberEvaluated < maxNumberEvaluated;
|
||||
for (int index = start_index; index < chunks_len_ && number_evaluated < max_number_evaluated;
|
||||
index++) {
|
||||
chunk_index = chunk_order[index];
|
||||
int yChunk = chunk_index / this->m_x_chunks_len;
|
||||
int xChunk = chunk_index - (yChunk * this->m_x_chunks_len);
|
||||
const WorkPackage &work_package = m_work_packages[chunk_index];
|
||||
int y_chunk = chunk_index / x_chunks_len_;
|
||||
int x_chunk = chunk_index - (y_chunk * x_chunks_len_);
|
||||
const WorkPackage &work_package = work_packages_[chunk_index];
|
||||
switch (work_package.state) {
|
||||
case eWorkPackageState::NotScheduled: {
|
||||
scheduleChunkWhenPossible(graph, xChunk, yChunk);
|
||||
schedule_chunk_when_possible(graph, x_chunk, y_chunk);
|
||||
finished = false;
|
||||
startEvaluated = true;
|
||||
numberEvaluated++;
|
||||
start_evaluated = true;
|
||||
number_evaluated++;
|
||||
|
||||
if (bTree->update_draw) {
|
||||
bTree->update_draw(bTree->udh);
|
||||
@@ -377,13 +361,13 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
}
|
||||
case eWorkPackageState::Scheduled: {
|
||||
finished = false;
|
||||
startEvaluated = true;
|
||||
numberEvaluated++;
|
||||
start_evaluated = true;
|
||||
number_evaluated++;
|
||||
break;
|
||||
}
|
||||
case eWorkPackageState::Executed: {
|
||||
if (!startEvaluated) {
|
||||
startIndex = index + 1;
|
||||
if (!start_evaluated) {
|
||||
start_index = index + 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -399,139 +383,135 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
|
||||
DebugInfo::graphviz(graph);
|
||||
}
|
||||
|
||||
MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
|
||||
MemoryBuffer **ExecutionGroup::get_input_buffers_opencl(int chunk_number)
|
||||
{
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
WorkPackage &work_package = work_packages_[chunk_number];
|
||||
|
||||
MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(
|
||||
sizeof(MemoryBuffer *) * this->m_max_read_buffer_offset, __func__);
|
||||
MemoryBuffer **memory_buffers = (MemoryBuffer **)MEM_callocN(
|
||||
sizeof(MemoryBuffer *) * max_read_buffer_offset_, __func__);
|
||||
rcti output;
|
||||
for (ReadBufferOperation *readOperation : m_read_operations) {
|
||||
MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
|
||||
this->determineDependingAreaOfInterest(&work_package.rect, readOperation, &output);
|
||||
MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(
|
||||
*memoryProxy, output);
|
||||
memoryBuffers[readOperation->getOffset()] = memoryBuffer;
|
||||
for (ReadBufferOperation *read_operation : read_operations_) {
|
||||
MemoryProxy *memory_proxy = read_operation->get_memory_proxy();
|
||||
this->determine_depending_area_of_interest(&work_package.rect, read_operation, &output);
|
||||
MemoryBuffer *memory_buffer =
|
||||
memory_proxy->get_executor()->construct_consolidated_memory_buffer(*memory_proxy, output);
|
||||
memory_buffers[read_operation->get_offset()] = memory_buffer;
|
||||
}
|
||||
return memoryBuffers;
|
||||
return memory_buffers;
|
||||
}
|
||||
|
||||
MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy,
|
||||
rcti &rect)
|
||||
MemoryBuffer *ExecutionGroup::construct_consolidated_memory_buffer(MemoryProxy &memory_proxy,
|
||||
rcti &rect)
|
||||
{
|
||||
MemoryBuffer *imageBuffer = memoryProxy.getBuffer();
|
||||
MemoryBuffer *result = new MemoryBuffer(&memoryProxy, rect, MemoryBufferState::Temporary);
|
||||
result->fill_from(*imageBuffer);
|
||||
MemoryBuffer *image_buffer = memory_proxy.get_buffer();
|
||||
MemoryBuffer *result = new MemoryBuffer(&memory_proxy, rect, MemoryBufferState::Temporary);
|
||||
result->fill_from(*image_buffer);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ExecutionGroup::finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers)
|
||||
void ExecutionGroup::finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers)
|
||||
{
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
WorkPackage &work_package = work_packages_[chunk_number];
|
||||
if (work_package.state == eWorkPackageState::Scheduled) {
|
||||
work_package.state = eWorkPackageState::Executed;
|
||||
}
|
||||
|
||||
atomic_add_and_fetch_u(&this->m_chunks_finished, 1);
|
||||
if (memoryBuffers) {
|
||||
for (unsigned int index = 0; index < this->m_max_read_buffer_offset; index++) {
|
||||
MemoryBuffer *buffer = memoryBuffers[index];
|
||||
atomic_add_and_fetch_u(&chunks_finished_, 1);
|
||||
if (memory_buffers) {
|
||||
for (unsigned int index = 0; index < max_read_buffer_offset_; index++) {
|
||||
MemoryBuffer *buffer = memory_buffers[index];
|
||||
if (buffer) {
|
||||
if (buffer->isTemporarily()) {
|
||||
memoryBuffers[index] = nullptr;
|
||||
if (buffer->is_temporarily()) {
|
||||
memory_buffers[index] = nullptr;
|
||||
delete buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_freeN(memoryBuffers);
|
||||
MEM_freeN(memory_buffers);
|
||||
}
|
||||
if (this->m_bTree) {
|
||||
if (bTree_) {
|
||||
/* Status report is only performed for top level Execution Groups. */
|
||||
float progress = this->m_chunks_finished;
|
||||
progress /= this->m_chunks_len;
|
||||
this->m_bTree->progress(this->m_bTree->prh, progress);
|
||||
float progress = chunks_finished_;
|
||||
progress /= chunks_len_;
|
||||
bTree_->progress(bTree_->prh, progress);
|
||||
|
||||
char buf[128];
|
||||
BLI_snprintf(buf,
|
||||
sizeof(buf),
|
||||
TIP_("Compositing | Tile %u-%u"),
|
||||
this->m_chunks_finished,
|
||||
this->m_chunks_len);
|
||||
this->m_bTree->stats_draw(this->m_bTree->sdh, buf);
|
||||
BLI_snprintf(
|
||||
buf, sizeof(buf), TIP_("Compositing | Tile %u-%u"), chunks_finished_, chunks_len_);
|
||||
bTree_->stats_draw(bTree_->sdh, buf);
|
||||
}
|
||||
}
|
||||
|
||||
inline void ExecutionGroup::determineChunkRect(rcti *r_rect,
|
||||
const unsigned int xChunk,
|
||||
const unsigned int yChunk) const
|
||||
inline void ExecutionGroup::determine_chunk_rect(rcti *r_rect,
|
||||
const unsigned int x_chunk,
|
||||
const unsigned int y_chunk) const
|
||||
{
|
||||
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
|
||||
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
|
||||
const int border_width = BLI_rcti_size_x(&viewer_border_);
|
||||
const int border_height = BLI_rcti_size_y(&viewer_border_);
|
||||
|
||||
if (this->m_flags.single_threaded) {
|
||||
BLI_rcti_init(
|
||||
r_rect, this->m_viewerBorder.xmin, border_width, this->m_viewerBorder.ymin, border_height);
|
||||
if (flags_.single_threaded) {
|
||||
BLI_rcti_init(r_rect, viewer_border_.xmin, border_width, viewer_border_.ymin, border_height);
|
||||
}
|
||||
else {
|
||||
const unsigned int minx = xChunk * this->m_chunkSize + this->m_viewerBorder.xmin;
|
||||
const unsigned int miny = yChunk * this->m_chunkSize + this->m_viewerBorder.ymin;
|
||||
const unsigned int width = MIN2((unsigned int)this->m_viewerBorder.xmax, this->m_width);
|
||||
const unsigned int height = MIN2((unsigned int)this->m_viewerBorder.ymax, this->m_height);
|
||||
const unsigned int minx = x_chunk * chunk_size_ + viewer_border_.xmin;
|
||||
const unsigned int miny = y_chunk * chunk_size_ + viewer_border_.ymin;
|
||||
const unsigned int width = MIN2((unsigned int)viewer_border_.xmax, width_);
|
||||
const unsigned int height = MIN2((unsigned int)viewer_border_.ymax, height_);
|
||||
BLI_rcti_init(r_rect,
|
||||
MIN2(minx, this->m_width),
|
||||
MIN2(minx + this->m_chunkSize, width),
|
||||
MIN2(miny, this->m_height),
|
||||
MIN2(miny + this->m_chunkSize, height));
|
||||
MIN2(minx, width_),
|
||||
MIN2(minx + chunk_size_, width),
|
||||
MIN2(miny, height_),
|
||||
MIN2(miny + chunk_size_, height));
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionGroup::determineChunkRect(rcti *r_rect, const unsigned int chunkNumber) const
|
||||
void ExecutionGroup::determine_chunk_rect(rcti *r_rect, const unsigned int chunk_number) const
|
||||
{
|
||||
const unsigned int yChunk = chunkNumber / this->m_x_chunks_len;
|
||||
const unsigned int xChunk = chunkNumber - (yChunk * this->m_x_chunks_len);
|
||||
determineChunkRect(r_rect, xChunk, yChunk);
|
||||
const unsigned int y_chunk = chunk_number / x_chunks_len_;
|
||||
const unsigned int x_chunk = chunk_number - (y_chunk * x_chunks_len_);
|
||||
determine_chunk_rect(r_rect, x_chunk, y_chunk);
|
||||
}
|
||||
|
||||
MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect)
|
||||
MemoryBuffer *ExecutionGroup::allocate_output_buffer(rcti &rect)
|
||||
{
|
||||
/* We assume that this method is only called from complex execution groups. */
|
||||
NodeOperation *operation = this->getOutputOperation();
|
||||
NodeOperation *operation = this->get_output_operation();
|
||||
if (operation->get_flags().is_write_buffer_operation) {
|
||||
WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation;
|
||||
WriteBufferOperation *write_operation = (WriteBufferOperation *)operation;
|
||||
MemoryBuffer *buffer = new MemoryBuffer(
|
||||
writeOperation->getMemoryProxy(), rect, MemoryBufferState::Temporary);
|
||||
write_operation->get_memory_proxy(), rect, MemoryBufferState::Temporary);
|
||||
return buffer;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area)
|
||||
bool ExecutionGroup::schedule_area_when_possible(ExecutionSystem *graph, rcti *area)
|
||||
{
|
||||
if (this->m_flags.single_threaded) {
|
||||
return scheduleChunkWhenPossible(graph, 0, 0);
|
||||
if (flags_.single_threaded) {
|
||||
return schedule_chunk_when_possible(graph, 0, 0);
|
||||
}
|
||||
/* Find all chunks inside the rect
|
||||
* determine `minxchunk`, `minychunk`, `maxxchunk`, `maxychunk`
|
||||
* where x and y are chunk-numbers. */
|
||||
|
||||
int indexx, indexy;
|
||||
int minx = max_ii(area->xmin - m_viewerBorder.xmin, 0);
|
||||
int maxx = min_ii(area->xmax - m_viewerBorder.xmin, m_viewerBorder.xmax - m_viewerBorder.xmin);
|
||||
int miny = max_ii(area->ymin - m_viewerBorder.ymin, 0);
|
||||
int maxy = min_ii(area->ymax - m_viewerBorder.ymin, m_viewerBorder.ymax - m_viewerBorder.ymin);
|
||||
int minxchunk = minx / (int)m_chunkSize;
|
||||
int maxxchunk = (maxx + (int)m_chunkSize - 1) / (int)m_chunkSize;
|
||||
int minychunk = miny / (int)m_chunkSize;
|
||||
int maxychunk = (maxy + (int)m_chunkSize - 1) / (int)m_chunkSize;
|
||||
int minx = max_ii(area->xmin - viewer_border_.xmin, 0);
|
||||
int maxx = min_ii(area->xmax - viewer_border_.xmin, viewer_border_.xmax - viewer_border_.xmin);
|
||||
int miny = max_ii(area->ymin - viewer_border_.ymin, 0);
|
||||
int maxy = min_ii(area->ymax - viewer_border_.ymin, viewer_border_.ymax - viewer_border_.ymin);
|
||||
int minxchunk = minx / (int)chunk_size_;
|
||||
int maxxchunk = (maxx + (int)chunk_size_ - 1) / (int)chunk_size_;
|
||||
int minychunk = miny / (int)chunk_size_;
|
||||
int maxychunk = (maxy + (int)chunk_size_ - 1) / (int)chunk_size_;
|
||||
minxchunk = max_ii(minxchunk, 0);
|
||||
minychunk = max_ii(minychunk, 0);
|
||||
maxxchunk = min_ii(maxxchunk, (int)m_x_chunks_len);
|
||||
maxychunk = min_ii(maxychunk, (int)m_y_chunks_len);
|
||||
maxxchunk = min_ii(maxxchunk, (int)x_chunks_len_);
|
||||
maxychunk = min_ii(maxychunk, (int)y_chunks_len_);
|
||||
|
||||
bool result = true;
|
||||
for (indexx = minxchunk; indexx < maxxchunk; indexx++) {
|
||||
for (indexy = minychunk; indexy < maxychunk; indexy++) {
|
||||
if (!scheduleChunkWhenPossible(graph, indexx, indexy)) {
|
||||
if (!schedule_chunk_when_possible(graph, indexx, indexy)) {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
@@ -540,9 +520,9 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
|
||||
bool ExecutionGroup::schedule_chunk(unsigned int chunk_number)
|
||||
{
|
||||
WorkPackage &work_package = m_work_packages[chunkNumber];
|
||||
WorkPackage &work_package = work_packages_[chunk_number];
|
||||
if (work_package.state == eWorkPackageState::NotScheduled) {
|
||||
work_package.state = eWorkPackageState::Scheduled;
|
||||
WorkScheduler::schedule(&work_package);
|
||||
@@ -551,20 +531,20 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
|
||||
const int chunk_x,
|
||||
const int chunk_y)
|
||||
bool ExecutionGroup::schedule_chunk_when_possible(ExecutionSystem *graph,
|
||||
const int chunk_x,
|
||||
const int chunk_y)
|
||||
{
|
||||
if (chunk_x < 0 || chunk_x >= (int)this->m_x_chunks_len) {
|
||||
if (chunk_x < 0 || chunk_x >= (int)x_chunks_len_) {
|
||||
return true;
|
||||
}
|
||||
if (chunk_y < 0 || chunk_y >= (int)this->m_y_chunks_len) {
|
||||
if (chunk_y < 0 || chunk_y >= (int)y_chunks_len_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check if chunk is already executed or scheduled and not yet executed. */
|
||||
const int chunk_index = chunk_y * this->m_x_chunks_len + chunk_x;
|
||||
WorkPackage &work_package = m_work_packages[chunk_index];
|
||||
const int chunk_index = chunk_y * x_chunks_len_ + chunk_x;
|
||||
WorkPackage &work_package = work_packages_[chunk_index];
|
||||
if (work_package.state == eWorkPackageState::Executed) {
|
||||
return true;
|
||||
}
|
||||
@@ -575,52 +555,45 @@ bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph,
|
||||
bool can_be_executed = true;
|
||||
rcti area;
|
||||
|
||||
for (ReadBufferOperation *read_operation : m_read_operations) {
|
||||
for (ReadBufferOperation *read_operation : read_operations_) {
|
||||
BLI_rcti_init(&area, 0, 0, 0, 0);
|
||||
MemoryProxy *memory_proxy = read_operation->getMemoryProxy();
|
||||
determineDependingAreaOfInterest(&work_package.rect, read_operation, &area);
|
||||
ExecutionGroup *group = memory_proxy->getExecutor();
|
||||
MemoryProxy *memory_proxy = read_operation->get_memory_proxy();
|
||||
determine_depending_area_of_interest(&work_package.rect, read_operation, &area);
|
||||
ExecutionGroup *group = memory_proxy->get_executor();
|
||||
|
||||
if (!group->scheduleAreaWhenPossible(graph, &area)) {
|
||||
if (!group->schedule_area_when_possible(graph, &area)) {
|
||||
can_be_executed = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (can_be_executed) {
|
||||
scheduleChunk(chunk_index);
|
||||
schedule_chunk(chunk_index);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ExecutionGroup::determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output)
|
||||
void ExecutionGroup::determine_depending_area_of_interest(rcti *input,
|
||||
ReadBufferOperation *read_operation,
|
||||
rcti *output)
|
||||
{
|
||||
this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output);
|
||||
this->get_output_operation()->determine_depending_area_of_interest(
|
||||
input, read_operation, output);
|
||||
}
|
||||
|
||||
void ExecutionGroup::setViewerBorder(float xmin, float xmax, float ymin, float ymax)
|
||||
void ExecutionGroup::set_viewer_border(float xmin, float xmax, float ymin, float ymax)
|
||||
{
|
||||
const NodeOperation &operation = *this->getOutputOperation();
|
||||
const NodeOperation &operation = *this->get_output_operation();
|
||||
if (operation.get_flags().use_viewer_border) {
|
||||
BLI_rcti_init(&this->m_viewerBorder,
|
||||
xmin * this->m_width,
|
||||
xmax * this->m_width,
|
||||
ymin * this->m_height,
|
||||
ymax * this->m_height);
|
||||
BLI_rcti_init(&viewer_border_, xmin * width_, xmax * width_, ymin * height_, ymax * height_);
|
||||
}
|
||||
}
|
||||
|
||||
void ExecutionGroup::setRenderBorder(float xmin, float xmax, float ymin, float ymax)
|
||||
void ExecutionGroup::set_render_border(float xmin, float xmax, float ymin, float ymax)
|
||||
{
|
||||
const NodeOperation &operation = *this->getOutputOperation();
|
||||
if (operation.isOutputOperation(true) && operation.get_flags().use_render_border) {
|
||||
BLI_rcti_init(&this->m_viewerBorder,
|
||||
xmin * this->m_width,
|
||||
xmax * this->m_width,
|
||||
ymin * this->m_height,
|
||||
ymax * this->m_height);
|
||||
const NodeOperation &operation = *this->get_output_operation();
|
||||
if (operation.is_output_operation(true) && operation.get_flags().use_render_border) {
|
||||
BLI_rcti_init(&viewer_border_, xmin * width_, xmax * width_, ymin * height_, ymax * height_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -22,25 +22,24 @@
|
||||
# include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "COM_CompositorContext.h"
|
||||
#include "COM_Device.h"
|
||||
#include "COM_MemoryProxy.h"
|
||||
#include "COM_Node.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_Enums.h"
|
||||
#include "COM_WorkPackage.h"
|
||||
#include <vector>
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class ExecutionSystem;
|
||||
class NodeOperation;
|
||||
class MemoryProxy;
|
||||
class MemoryBuffer;
|
||||
class ReadBufferOperation;
|
||||
class Device;
|
||||
|
||||
struct ExecutionGroupFlags {
|
||||
bool initialized : 1;
|
||||
@@ -87,84 +86,84 @@ class ExecutionGroup {
|
||||
/**
|
||||
* Id of the execution group. For debugging purposes.
|
||||
*/
|
||||
int m_id;
|
||||
int id_;
|
||||
|
||||
/**
|
||||
* \brief list of operations in this ExecutionGroup
|
||||
*/
|
||||
Vector<NodeOperation *> m_operations;
|
||||
Vector<NodeOperation *> operations_;
|
||||
|
||||
ExecutionGroupFlags m_flags;
|
||||
ExecutionGroupFlags flags_;
|
||||
|
||||
/**
|
||||
* \brief Width of the output
|
||||
*/
|
||||
unsigned int m_width;
|
||||
unsigned int width_;
|
||||
|
||||
/**
|
||||
* \brief Height of the output
|
||||
*/
|
||||
unsigned int m_height;
|
||||
unsigned int height_;
|
||||
|
||||
/**
|
||||
* \brief size of a single chunk, being Width or of height
|
||||
* a chunk is always a square, except at the edges of the MemoryBuffer
|
||||
*/
|
||||
unsigned int m_chunkSize;
|
||||
unsigned int chunk_size_;
|
||||
|
||||
/**
|
||||
* \brief number of chunks in the x-axis
|
||||
*/
|
||||
unsigned int m_x_chunks_len;
|
||||
unsigned int x_chunks_len_;
|
||||
|
||||
/**
|
||||
* \brief number of chunks in the y-axis
|
||||
*/
|
||||
unsigned int m_y_chunks_len;
|
||||
unsigned int y_chunks_len_;
|
||||
|
||||
/**
|
||||
* \brief total number of chunks
|
||||
*/
|
||||
unsigned int m_chunks_len;
|
||||
unsigned int chunks_len_;
|
||||
|
||||
/**
|
||||
* \brief what is the maximum number field of all ReadBufferOperation in this ExecutionGroup.
|
||||
* \note this is used to construct the MemoryBuffers that will be passed during execution.
|
||||
*/
|
||||
unsigned int m_max_read_buffer_offset;
|
||||
unsigned int max_read_buffer_offset_;
|
||||
|
||||
/**
|
||||
* \brief All read operations of this execution group.
|
||||
*/
|
||||
Vector<ReadBufferOperation *> m_read_operations;
|
||||
Vector<ReadBufferOperation *> read_operations_;
|
||||
|
||||
/**
|
||||
* \brief reference to the original bNodeTree,
|
||||
* this field is only set for the 'top' execution group.
|
||||
* \note can only be used to call the callbacks for progress, status and break.
|
||||
*/
|
||||
const bNodeTree *m_bTree;
|
||||
const bNodeTree *bTree_;
|
||||
|
||||
/**
|
||||
* \brief total number of chunks that have been calculated for this ExecutionGroup
|
||||
*/
|
||||
unsigned int m_chunks_finished;
|
||||
unsigned int chunks_finished_;
|
||||
|
||||
/**
|
||||
* \brief m_work_packages holds all unit of work.
|
||||
* \brief work_packages_ holds all unit of work.
|
||||
*/
|
||||
Vector<WorkPackage> m_work_packages;
|
||||
Vector<WorkPackage> work_packages_;
|
||||
|
||||
/**
|
||||
* \brief denotes boundary for border compositing
|
||||
* \note measured in pixel space
|
||||
*/
|
||||
rcti m_viewerBorder;
|
||||
rcti viewer_border_;
|
||||
|
||||
/**
|
||||
* \brief start time of execution
|
||||
*/
|
||||
double m_executionStartTime;
|
||||
double execution_start_time_;
|
||||
|
||||
// methods
|
||||
/**
|
||||
@@ -176,13 +175,14 @@ class ExecutionGroup {
|
||||
/**
|
||||
* \brief Determine the rect (minx, maxx, miny, maxy) of a chunk at a position.
|
||||
*/
|
||||
void determineChunkRect(rcti *r_rect,
|
||||
const unsigned int xChunk,
|
||||
const unsigned int yChunk) const;
|
||||
void determine_chunk_rect(rcti *r_rect,
|
||||
const unsigned int x_chunk,
|
||||
const unsigned int y_chunk) const;
|
||||
|
||||
/**
|
||||
* \brief determine the number of chunks, based on the chunkSize, width and height.
|
||||
* \note The result are stored in the fields numberOfChunks, numberOfXChunks, numberOfYChunks
|
||||
* \brief determine the number of chunks, based on the chunk_size, width and height.
|
||||
* \note The result are stored in the fields number_of_chunks, number_of_xchunks,
|
||||
* number_of_ychunks
|
||||
*/
|
||||
void init_number_of_chunks();
|
||||
|
||||
@@ -191,13 +191,13 @@ class ExecutionGroup {
|
||||
* \note scheduling succeeds when all input requirements are met and the chunks hasn't been
|
||||
* scheduled yet.
|
||||
* \param graph:
|
||||
* \param xChunk:
|
||||
* \param yChunk:
|
||||
* \param x_chunk:
|
||||
* \param y_chunk:
|
||||
* \return [true:false]
|
||||
* true: package(s) are scheduled
|
||||
* false: scheduling is deferred (depending workpackages are scheduled)
|
||||
*/
|
||||
bool scheduleChunkWhenPossible(ExecutionSystem *graph, const int chunk_x, const int chunk_y);
|
||||
bool schedule_chunk_when_possible(ExecutionSystem *graph, const int chunk_x, const int chunk_y);
|
||||
|
||||
/**
|
||||
* \brief try to schedule a specific area.
|
||||
@@ -209,24 +209,24 @@ class ExecutionGroup {
|
||||
* true: package(s) are scheduled
|
||||
* false: scheduling is deferred (depending workpackages are scheduled)
|
||||
*/
|
||||
bool scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area);
|
||||
bool schedule_area_when_possible(ExecutionSystem *graph, rcti *area);
|
||||
|
||||
/**
|
||||
* \brief add a chunk to the WorkScheduler.
|
||||
* \param chunknumber:
|
||||
*/
|
||||
bool scheduleChunk(unsigned int chunkNumber);
|
||||
bool schedule_chunk(unsigned int chunk_number);
|
||||
|
||||
/**
|
||||
* \brief determine the area of interest of a certain input area
|
||||
* \note This method only evaluates a single ReadBufferOperation
|
||||
* \param input: the input area
|
||||
* \param readOperation: The ReadBufferOperation where the area needs to be evaluated
|
||||
* \param read_operation: The ReadBufferOperation where the area needs to be evaluated
|
||||
* \param output: the area needed of the ReadBufferOperation. Result
|
||||
*/
|
||||
void determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output);
|
||||
void determine_depending_area_of_interest(rcti *input,
|
||||
ReadBufferOperation *read_operation,
|
||||
rcti *output);
|
||||
|
||||
/**
|
||||
* Return the execution order of the user visible chunks.
|
||||
@@ -242,12 +242,12 @@ class ExecutionGroup {
|
||||
|
||||
int get_id() const
|
||||
{
|
||||
return m_id;
|
||||
return id_;
|
||||
}
|
||||
|
||||
const ExecutionGroupFlags get_flags() const
|
||||
{
|
||||
return m_flags;
|
||||
return flags_;
|
||||
}
|
||||
|
||||
// methods
|
||||
@@ -259,71 +259,71 @@ class ExecutionGroup {
|
||||
* \param operation:
|
||||
* \return True if the operation was successfully added
|
||||
*/
|
||||
bool addOperation(NodeOperation *operation);
|
||||
bool add_operation(NodeOperation *operation);
|
||||
|
||||
/**
|
||||
* \brief set whether this ExecutionGroup is an output
|
||||
* \param isOutput:
|
||||
* \param is_output:
|
||||
*/
|
||||
void setOutputExecutionGroup(bool is_output)
|
||||
void set_output_execution_group(bool is_output)
|
||||
{
|
||||
this->m_flags.is_output = is_output;
|
||||
flags_.is_output = is_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief determine the resolution of this ExecutionGroup
|
||||
* \param resolution:
|
||||
*/
|
||||
void determineResolution(unsigned int resolution[2]);
|
||||
void determine_resolution(unsigned int resolution[2]);
|
||||
|
||||
/**
|
||||
* \brief set the resolution of this executiongroup
|
||||
* \param resolution:
|
||||
*/
|
||||
void setResolution(unsigned int resolution[2])
|
||||
void set_resolution(unsigned int resolution[2])
|
||||
{
|
||||
this->m_width = resolution[0];
|
||||
this->m_height = resolution[1];
|
||||
width_ = resolution[0];
|
||||
height_ = resolution[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the width of this execution group
|
||||
*/
|
||||
unsigned int getWidth() const
|
||||
unsigned int get_width() const
|
||||
{
|
||||
return m_width;
|
||||
return width_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the height of this execution group
|
||||
*/
|
||||
unsigned int getHeight() const
|
||||
unsigned int get_height() const
|
||||
{
|
||||
return m_height;
|
||||
return height_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the output operation of this ExecutionGroup
|
||||
* \return NodeOperation *output operation
|
||||
*/
|
||||
NodeOperation *getOutputOperation() const;
|
||||
NodeOperation *get_output_operation() const;
|
||||
|
||||
/**
|
||||
* \brief compose multiple chunks into a single chunk
|
||||
* \return Memorybuffer *consolidated chunk
|
||||
*/
|
||||
MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, rcti &rect);
|
||||
MemoryBuffer *construct_consolidated_memory_buffer(MemoryProxy &memory_proxy, rcti &rect);
|
||||
|
||||
/**
|
||||
* \brief initExecution is called just before the execution of the whole graph will be done.
|
||||
* \note The implementation will calculate the chunkSize of this execution group.
|
||||
* \brief init_execution is called just before the execution of the whole graph will be done.
|
||||
* \note The implementation will calculate the chunk_size of this execution group.
|
||||
*/
|
||||
void initExecution();
|
||||
void init_execution();
|
||||
|
||||
/**
|
||||
* \brief get all inputbuffers needed to calculate an chunk
|
||||
* \note all inputbuffers must be executed
|
||||
* \param chunkNumber: the chunk to be calculated
|
||||
* \param chunk_number: the chunk to be calculated
|
||||
* \return (MemoryBuffer **) the inputbuffers
|
||||
*/
|
||||
MemoryBuffer **getInputBuffersCPU();
|
||||
@@ -331,31 +331,31 @@ class ExecutionGroup {
|
||||
/**
|
||||
* \brief get all inputbuffers needed to calculate an chunk
|
||||
* \note all inputbuffers must be executed
|
||||
* \param chunkNumber: the chunk to be calculated
|
||||
* \param chunk_number: the chunk to be calculated
|
||||
* \return (MemoryBuffer **) the inputbuffers
|
||||
*/
|
||||
MemoryBuffer **getInputBuffersOpenCL(int chunkNumber);
|
||||
MemoryBuffer **get_input_buffers_opencl(int chunk_number);
|
||||
|
||||
/**
|
||||
* \brief allocate the outputbuffer of a chunk
|
||||
* \param chunkNumber: the number of the chunk in the ExecutionGroup
|
||||
* \param chunk_number: the number of the chunk in the ExecutionGroup
|
||||
* \param rect: the rect of that chunk
|
||||
* \see determineChunkRect
|
||||
* \see determine_chunk_rect
|
||||
*/
|
||||
MemoryBuffer *allocateOutputBuffer(rcti &rect);
|
||||
MemoryBuffer *allocate_output_buffer(rcti &rect);
|
||||
|
||||
/**
|
||||
* \brief after a chunk is executed the needed resources can be freed or unlocked.
|
||||
* \param chunknumber:
|
||||
* \param memorybuffers:
|
||||
*/
|
||||
void finalizeChunkExecution(int chunkNumber, MemoryBuffer **memoryBuffers);
|
||||
void finalize_chunk_execution(int chunk_number, MemoryBuffer **memory_buffers);
|
||||
|
||||
/**
|
||||
* \brief deinitExecution is called just after execution the whole graph.
|
||||
* \brief deinit_execution is called just after execution the whole graph.
|
||||
* \note It will release all needed resources
|
||||
*/
|
||||
void deinitExecution();
|
||||
void deinit_execution();
|
||||
|
||||
/**
|
||||
* \brief schedule an ExecutionGroup
|
||||
@@ -378,26 +378,26 @@ class ExecutionGroup {
|
||||
/**
|
||||
* \brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
|
||||
*/
|
||||
void determineChunkRect(rcti *r_rect, const unsigned int chunkNumber) const;
|
||||
void determine_chunk_rect(rcti *r_rect, const unsigned int chunk_number) const;
|
||||
|
||||
void setChunksize(int chunksize)
|
||||
void set_chunksize(int chunksize)
|
||||
{
|
||||
this->m_chunkSize = chunksize;
|
||||
chunk_size_ = chunksize;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the Render priority of this ExecutionGroup
|
||||
* \see ExecutionSystem.execute
|
||||
*/
|
||||
eCompositorPriority getRenderPriority();
|
||||
eCompositorPriority get_render_priority();
|
||||
|
||||
/**
|
||||
* \brief set border for viewer operation
|
||||
* \note all the coordinates are assumed to be in normalized space
|
||||
*/
|
||||
void setViewerBorder(float xmin, float xmax, float ymin, float ymax);
|
||||
void set_viewer_border(float xmin, float xmax, float ymin, float ymax);
|
||||
|
||||
void setRenderBorder(float xmin, float xmax, float ymin, float ymax);
|
||||
void set_render_border(float xmin, float xmax, float ymin, float ymax);
|
||||
|
||||
/* allow the DebugInfo class to look at internals */
|
||||
friend class DebugInfo;
|
||||
|
@@ -17,13 +17,14 @@
|
||||
*/
|
||||
|
||||
#include "COM_ExecutionModel.h"
|
||||
#include "COM_CompositorContext.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *> operations)
|
||||
: context_(context), operations_(operations)
|
||||
{
|
||||
const bNodeTree *node_tree = context_.getbNodeTree();
|
||||
const bNodeTree *node_tree = context_.get_bnodetree();
|
||||
|
||||
const rctf *viewer_border = &node_tree->viewer_border;
|
||||
border_.use_viewer_border = (node_tree->flag & NTREE_VIEWER_BORDER) &&
|
||||
@@ -31,10 +32,10 @@ ExecutionModel::ExecutionModel(CompositorContext &context, Span<NodeOperation *>
|
||||
viewer_border->ymin < viewer_border->ymax;
|
||||
border_.viewer_border = viewer_border;
|
||||
|
||||
const RenderData *rd = context_.getRenderData();
|
||||
const RenderData *rd = context_.get_render_data();
|
||||
/* Case when cropping to render border happens is handled in
|
||||
* compositor output and render layer nodes. */
|
||||
border_.use_render_border = context.isRendering() && (rd->mode & R_BORDER) &&
|
||||
border_.use_render_border = context.is_rendering() && (rd->mode & R_BORDER) &&
|
||||
!(rd->mode & R_CROP);
|
||||
border_.render_border = &rd->border;
|
||||
}
|
||||
|
@@ -18,12 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_vector.hh"
|
||||
#include "BLI_span.hh"
|
||||
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
#include <functional>
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
# include "MEM_guardedalloc.h"
|
||||
@@ -31,6 +28,8 @@
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class CompositorContext;
|
||||
class ExecutionSystem;
|
||||
class NodeOperation;
|
||||
|
||||
/**
|
||||
|
@@ -18,14 +18,13 @@
|
||||
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include "COM_Debug.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_FullFrameExecutionModel.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_NodeOperationBuilder.h"
|
||||
#include "COM_TiledExecutionModel.h"
|
||||
#include "COM_WorkPackage.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
@@ -39,45 +38,45 @@ ExecutionSystem::ExecutionSystem(RenderData *rd,
|
||||
bNodeTree *editingtree,
|
||||
bool rendering,
|
||||
bool fastcalculation,
|
||||
const ColorManagedViewSettings *viewSettings,
|
||||
const ColorManagedDisplaySettings *displaySettings,
|
||||
const char *viewName)
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings,
|
||||
const char *view_name)
|
||||
{
|
||||
num_work_threads_ = WorkScheduler::get_num_cpu_threads();
|
||||
this->m_context.setViewName(viewName);
|
||||
this->m_context.setScene(scene);
|
||||
this->m_context.setbNodeTree(editingtree);
|
||||
this->m_context.setPreviewHash(editingtree->previews);
|
||||
this->m_context.setFastCalculation(fastcalculation);
|
||||
context_.set_view_name(view_name);
|
||||
context_.set_scene(scene);
|
||||
context_.set_bnodetree(editingtree);
|
||||
context_.set_preview_hash(editingtree->previews);
|
||||
context_.set_fast_calculation(fastcalculation);
|
||||
/* initialize the CompositorContext */
|
||||
if (rendering) {
|
||||
this->m_context.setQuality((eCompositorQuality)editingtree->render_quality);
|
||||
context_.set_quality((eCompositorQuality)editingtree->render_quality);
|
||||
}
|
||||
else {
|
||||
this->m_context.setQuality((eCompositorQuality)editingtree->edit_quality);
|
||||
context_.set_quality((eCompositorQuality)editingtree->edit_quality);
|
||||
}
|
||||
this->m_context.setRendering(rendering);
|
||||
this->m_context.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
|
||||
(editingtree->flag & NTREE_COM_OPENCL));
|
||||
context_.set_rendering(rendering);
|
||||
context_.setHasActiveOpenCLDevices(WorkScheduler::has_gpu_devices() &&
|
||||
(editingtree->flag & NTREE_COM_OPENCL));
|
||||
|
||||
this->m_context.setRenderData(rd);
|
||||
this->m_context.setViewSettings(viewSettings);
|
||||
this->m_context.setDisplaySettings(displaySettings);
|
||||
context_.set_render_data(rd);
|
||||
context_.set_view_settings(view_settings);
|
||||
context_.set_display_settings(display_settings);
|
||||
|
||||
BLI_mutex_init(&work_mutex_);
|
||||
BLI_condition_init(&work_finished_cond_);
|
||||
|
||||
{
|
||||
NodeOperationBuilder builder(&m_context, editingtree, this);
|
||||
builder.convertToOperations(this);
|
||||
NodeOperationBuilder builder(&context_, editingtree, this);
|
||||
builder.convert_to_operations(this);
|
||||
}
|
||||
|
||||
switch (m_context.get_execution_model()) {
|
||||
switch (context_.get_execution_model()) {
|
||||
case eExecutionModel::Tiled:
|
||||
execution_model_ = new TiledExecutionModel(m_context, m_operations, m_groups);
|
||||
execution_model_ = new TiledExecutionModel(context_, operations_, groups_);
|
||||
break;
|
||||
case eExecutionModel::FullFrame:
|
||||
execution_model_ = new FullFrameExecutionModel(m_context, active_buffers_, m_operations);
|
||||
execution_model_ = new FullFrameExecutionModel(context_, active_buffers_, operations_);
|
||||
break;
|
||||
default:
|
||||
BLI_assert_msg(0, "Non implemented execution model");
|
||||
@@ -92,28 +91,28 @@ ExecutionSystem::~ExecutionSystem()
|
||||
|
||||
delete execution_model_;
|
||||
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
delete operation;
|
||||
}
|
||||
this->m_operations.clear();
|
||||
operations_.clear();
|
||||
|
||||
for (ExecutionGroup *group : m_groups) {
|
||||
for (ExecutionGroup *group : groups_) {
|
||||
delete group;
|
||||
}
|
||||
this->m_groups.clear();
|
||||
groups_.clear();
|
||||
}
|
||||
|
||||
void ExecutionSystem::set_operations(const Vector<NodeOperation *> &operations,
|
||||
const Vector<ExecutionGroup *> &groups)
|
||||
{
|
||||
m_operations = operations;
|
||||
m_groups = groups;
|
||||
operations_ = operations;
|
||||
groups_ = groups;
|
||||
}
|
||||
|
||||
void ExecutionSystem::execute()
|
||||
{
|
||||
DebugInfo::execute_started(this);
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
op->init_data();
|
||||
}
|
||||
execution_model_->execute(*this);
|
||||
@@ -185,7 +184,7 @@ void ExecutionSystem::execute_work(const rcti &work_rect,
|
||||
|
||||
bool ExecutionSystem::is_breaked() const
|
||||
{
|
||||
const bNodeTree *btree = m_context.getbNodeTree();
|
||||
const bNodeTree *btree = context_.get_bnodetree();
|
||||
return btree->test_break(btree->tbh);
|
||||
}
|
||||
|
||||
|
@@ -16,22 +16,23 @@
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*/
|
||||
|
||||
class ExecutionGroup;
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BKE_text.h"
|
||||
#include <functional>
|
||||
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_Node.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "atomic_ops.h"
|
||||
|
||||
#include "BLI_index_range.hh"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "COM_CompositorContext.h"
|
||||
#include "COM_SharedOperationBuffers.h"
|
||||
|
||||
#include "DNA_color_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
#include "atomic_ops.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
@@ -63,8 +64,8 @@ namespace blender::compositor {
|
||||
* based on settings; like MixNode. based on the selected Mixtype a different operation will be
|
||||
* used. for more information see the page about creating new Nodes. [@subpage newnode]
|
||||
*
|
||||
* \see ExecutionSystem.convertToOperations
|
||||
* \see Node.convertToOperations
|
||||
* \see ExecutionSystem.convert_to_operations
|
||||
* \see Node.convert_to_operations
|
||||
* \see NodeOperation base class for all operations in the system
|
||||
*
|
||||
* \section EM_Step3 Step3: add additional conversions to the operation system
|
||||
@@ -88,7 +89,7 @@ namespace blender::compositor {
|
||||
* Bottom left of the images are aligned.
|
||||
*
|
||||
* \see COM_convert_data_type Datatype conversions
|
||||
* \see Converter.convertResolution Image size conversions
|
||||
* \see Converter.convert_resolution Image size conversions
|
||||
*
|
||||
* \section EM_Step4 Step4: group operations in executions groups
|
||||
* ExecutionGroup are groups of operations that are calculated as being one bigger operation.
|
||||
@@ -111,14 +112,16 @@ namespace blender::compositor {
|
||||
* |cFAA | |cFAA | |cFAA | |cFAA |
|
||||
* +------+ +------+ +-------+ +-------+
|
||||
* </pre>
|
||||
* \see ExecutionSystem.groupOperations method doing this step
|
||||
* \see ExecutionSystem.addReadWriteBufferOperations
|
||||
* \see NodeOperation.isComplex
|
||||
* \see ExecutionSystem.group_operations method doing this step
|
||||
* \see ExecutionSystem.add_read_write_buffer_operations
|
||||
* \see NodeOperation.is_complex
|
||||
* \see ExecutionGroup class representing the ExecutionGroup
|
||||
*/
|
||||
|
||||
/* Forward declarations. */
|
||||
class ExecutionGroup;
|
||||
class ExecutionModel;
|
||||
class NodeOperation;
|
||||
|
||||
/**
|
||||
* \brief the ExecutionSystem contains the whole compositor tree.
|
||||
@@ -134,17 +137,17 @@ class ExecutionSystem {
|
||||
/**
|
||||
* \brief the context used during execution
|
||||
*/
|
||||
CompositorContext m_context;
|
||||
CompositorContext context_;
|
||||
|
||||
/**
|
||||
* \brief vector of operations
|
||||
*/
|
||||
Vector<NodeOperation *> m_operations;
|
||||
Vector<NodeOperation *> operations_;
|
||||
|
||||
/**
|
||||
* \brief vector of groups
|
||||
*/
|
||||
Vector<ExecutionGroup *> m_groups;
|
||||
Vector<ExecutionGroup *> groups_;
|
||||
|
||||
/**
|
||||
* Active execution model implementation.
|
||||
@@ -172,9 +175,9 @@ class ExecutionSystem {
|
||||
bNodeTree *editingtree,
|
||||
bool rendering,
|
||||
bool fastcalculation,
|
||||
const ColorManagedViewSettings *viewSettings,
|
||||
const ColorManagedDisplaySettings *displaySettings,
|
||||
const char *viewName);
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings,
|
||||
const char *view_name);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@@ -195,9 +198,9 @@ class ExecutionSystem {
|
||||
/**
|
||||
* \brief get the reference to the compositor context
|
||||
*/
|
||||
const CompositorContext &getContext() const
|
||||
const CompositorContext &get_context() const
|
||||
{
|
||||
return this->m_context;
|
||||
return context_;
|
||||
}
|
||||
|
||||
SharedOperationBuffers &get_active_buffers()
|
||||
|
@@ -17,14 +17,13 @@
|
||||
*/
|
||||
|
||||
#include "COM_FullFrameExecutionModel.h"
|
||||
#include "COM_Debug.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
#include "COM_ViewerOperation.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "COM_Debug.h"
|
||||
#include "COM_ViewerOperation.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
# include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
@@ -39,7 +38,7 @@ FullFrameExecutionModel::FullFrameExecutionModel(CompositorContext &context,
|
||||
num_operations_finished_(0)
|
||||
{
|
||||
priorities_.append(eCompositorPriority::High);
|
||||
if (!context.isFastCalculation()) {
|
||||
if (!context.is_fast_calculation()) {
|
||||
priorities_.append(eCompositorPriority::Medium);
|
||||
priorities_.append(eCompositorPriority::Low);
|
||||
}
|
||||
@@ -47,7 +46,7 @@ FullFrameExecutionModel::FullFrameExecutionModel(CompositorContext &context,
|
||||
|
||||
void FullFrameExecutionModel::execute(ExecutionSystem &exec_system)
|
||||
{
|
||||
const bNodeTree *node_tree = this->context_.getbNodeTree();
|
||||
const bNodeTree *node_tree = this->context_.get_bnodetree();
|
||||
node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Initializing execution"));
|
||||
|
||||
DebugInfo::graphviz(&exec_system, "compositor_prior_rendering");
|
||||
@@ -58,14 +57,14 @@ void FullFrameExecutionModel::execute(ExecutionSystem &exec_system)
|
||||
|
||||
void FullFrameExecutionModel::determine_areas_to_render_and_reads()
|
||||
{
|
||||
const bool is_rendering = context_.isRendering();
|
||||
const bNodeTree *node_tree = context_.getbNodeTree();
|
||||
const bool is_rendering = context_.is_rendering();
|
||||
const bNodeTree *node_tree = context_.get_bnodetree();
|
||||
|
||||
rcti area;
|
||||
for (eCompositorPriority priority : priorities_) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
op->setbNodeTree(node_tree);
|
||||
if (op->isOutputOperation(is_rendering) && op->getRenderPriority() == priority) {
|
||||
op->set_bnodetree(node_tree);
|
||||
if (op->is_output_operation(is_rendering) && op->get_render_priority() == priority) {
|
||||
get_output_render_area(op, area);
|
||||
determine_areas_to_render(op, area);
|
||||
determine_reads(op);
|
||||
@@ -82,7 +81,7 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation
|
||||
const int output_x,
|
||||
const int output_y)
|
||||
{
|
||||
const int num_inputs = op->getNumberOfInputSockets();
|
||||
const int num_inputs = op->get_number_of_input_sockets();
|
||||
Vector<MemoryBuffer *> inputs_buffers(num_inputs);
|
||||
for (int i = 0; i < num_inputs; i++) {
|
||||
NodeOperation *input = op->get_input_operation(i);
|
||||
@@ -93,7 +92,7 @@ Vector<MemoryBuffer *> FullFrameExecutionModel::get_input_buffers(NodeOperation
|
||||
rcti rect = buf->get_rect();
|
||||
BLI_rcti_translate(&rect, offset_x, offset_y);
|
||||
inputs_buffers[i] = new MemoryBuffer(
|
||||
buf->getBuffer(), buf->get_num_channels(), rect, buf->is_a_single_elem());
|
||||
buf->get_buffer(), buf->get_num_channels(), rect, buf->is_a_single_elem());
|
||||
}
|
||||
return inputs_buffers;
|
||||
}
|
||||
@@ -103,9 +102,10 @@ MemoryBuffer *FullFrameExecutionModel::create_operation_buffer(NodeOperation *op
|
||||
const int output_y)
|
||||
{
|
||||
rcti rect;
|
||||
BLI_rcti_init(&rect, output_x, output_x + op->getWidth(), output_y, output_y + op->getHeight());
|
||||
BLI_rcti_init(
|
||||
&rect, output_x, output_x + op->get_width(), output_y, output_y + op->get_height());
|
||||
|
||||
const DataType data_type = op->getOutputSocket(0)->getDataType();
|
||||
const DataType data_type = op->get_output_socket(0)->get_data_type();
|
||||
const bool is_a_single_elem = op->get_flags().is_constant_operation;
|
||||
return new MemoryBuffer(data_type, rect, is_a_single_elem);
|
||||
}
|
||||
@@ -116,9 +116,9 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op)
|
||||
constexpr int output_x = 0;
|
||||
constexpr int output_y = 0;
|
||||
|
||||
const bool has_outputs = op->getNumberOfOutputSockets() > 0;
|
||||
const bool has_outputs = op->get_number_of_output_sockets() > 0;
|
||||
MemoryBuffer *op_buf = has_outputs ? create_operation_buffer(op, output_x, output_y) : nullptr;
|
||||
if (op->getWidth() > 0 && op->getHeight() > 0) {
|
||||
if (op->get_width() > 0 && op->get_height() > 0) {
|
||||
Vector<MemoryBuffer *> input_bufs = get_input_buffers(op, output_x, output_y);
|
||||
const int op_offset_x = output_x - op->get_canvas().xmin;
|
||||
const int op_offset_y = output_y - op->get_canvas().ymin;
|
||||
@@ -142,19 +142,19 @@ void FullFrameExecutionModel::render_operation(NodeOperation *op)
|
||||
*/
|
||||
void FullFrameExecutionModel::render_operations()
|
||||
{
|
||||
const bool is_rendering = context_.isRendering();
|
||||
const bool is_rendering = context_.is_rendering();
|
||||
|
||||
WorkScheduler::start(this->context_);
|
||||
for (eCompositorPriority priority : priorities_) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
const bool has_size = op->getWidth() > 0 && op->getHeight() > 0;
|
||||
const bool is_priority_output = op->isOutputOperation(is_rendering) &&
|
||||
op->getRenderPriority() == priority;
|
||||
const bool has_size = op->get_width() > 0 && op->get_height() > 0;
|
||||
const bool is_priority_output = op->is_output_operation(is_rendering) &&
|
||||
op->get_render_priority() == priority;
|
||||
if (is_priority_output && has_size) {
|
||||
render_output_dependencies(op);
|
||||
render_operation(op);
|
||||
}
|
||||
else if (is_priority_output && !has_size && op->isActiveViewerOutput()) {
|
||||
else if (is_priority_output && !has_size && op->is_active_viewer_output()) {
|
||||
static_cast<ViewerOperation *>(op)->clear_display_buffer();
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ static Vector<NodeOperation *> get_operation_dependencies(NodeOperation *operati
|
||||
Vector<NodeOperation *> outputs(next_outputs);
|
||||
next_outputs.clear();
|
||||
for (NodeOperation *output : outputs) {
|
||||
for (int i = 0; i < output->getNumberOfInputSockets(); i++) {
|
||||
for (int i = 0; i < output->get_number_of_input_sockets(); i++) {
|
||||
next_outputs.append(output->get_input_operation(i));
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ static Vector<NodeOperation *> get_operation_dependencies(NodeOperation *operati
|
||||
|
||||
void FullFrameExecutionModel::render_output_dependencies(NodeOperation *output_op)
|
||||
{
|
||||
BLI_assert(output_op->isOutputOperation(context_.isRendering()));
|
||||
BLI_assert(output_op->is_output_operation(context_.is_rendering()));
|
||||
Vector<NodeOperation *> dependencies = get_operation_dependencies(output_op);
|
||||
for (NodeOperation *op : dependencies) {
|
||||
if (!active_buffers_.is_operation_rendered(op)) {
|
||||
@@ -206,7 +206,7 @@ void FullFrameExecutionModel::render_output_dependencies(NodeOperation *output_o
|
||||
void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op,
|
||||
const rcti &output_area)
|
||||
{
|
||||
BLI_assert(output_op->isOutputOperation(context_.isRendering()));
|
||||
BLI_assert(output_op->is_output_operation(context_.is_rendering()));
|
||||
|
||||
Vector<std::pair<NodeOperation *, const rcti>> stack;
|
||||
stack.append({output_op, output_area});
|
||||
@@ -221,7 +221,7 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op
|
||||
|
||||
active_buffers_.register_area(operation, render_area);
|
||||
|
||||
const int num_inputs = operation->getNumberOfInputSockets();
|
||||
const int num_inputs = operation->get_number_of_input_sockets();
|
||||
for (int i = 0; i < num_inputs; i++) {
|
||||
NodeOperation *input_op = operation->get_input_operation(i);
|
||||
rcti input_area;
|
||||
@@ -241,13 +241,13 @@ void FullFrameExecutionModel::determine_areas_to_render(NodeOperation *output_op
|
||||
*/
|
||||
void FullFrameExecutionModel::determine_reads(NodeOperation *output_op)
|
||||
{
|
||||
BLI_assert(output_op->isOutputOperation(context_.isRendering()));
|
||||
BLI_assert(output_op->is_output_operation(context_.is_rendering()));
|
||||
|
||||
Vector<NodeOperation *> stack;
|
||||
stack.append(output_op);
|
||||
while (stack.size() > 0) {
|
||||
NodeOperation *operation = stack.pop_last();
|
||||
const int num_inputs = operation->getNumberOfInputSockets();
|
||||
const int num_inputs = operation->get_number_of_input_sockets();
|
||||
for (int i = 0; i < num_inputs; i++) {
|
||||
NodeOperation *input_op = operation->get_input_operation(i);
|
||||
if (!active_buffers_.has_registered_reads(input_op)) {
|
||||
@@ -264,7 +264,7 @@ void FullFrameExecutionModel::determine_reads(NodeOperation *output_op)
|
||||
*/
|
||||
void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, rcti &r_area)
|
||||
{
|
||||
BLI_assert(output_op->isOutputOperation(context_.isRendering()));
|
||||
BLI_assert(output_op->is_output_operation(context_.is_rendering()));
|
||||
|
||||
/* By default return operation bounds (no border). */
|
||||
rcti canvas = output_op->get_canvas();
|
||||
@@ -279,8 +279,8 @@ void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, r
|
||||
const rctf *norm_border = has_viewer_border ? border_.viewer_border : border_.render_border;
|
||||
|
||||
/* Return de-normalized border within canvas. */
|
||||
const int w = output_op->getWidth();
|
||||
const int h = output_op->getHeight();
|
||||
const int w = output_op->get_width();
|
||||
const int h = output_op->get_height();
|
||||
r_area.xmin = canvas.xmin + norm_border->xmin * w;
|
||||
r_area.xmax = canvas.xmin + norm_border->xmax * w;
|
||||
r_area.ymin = canvas.ymin + norm_border->ymin * h;
|
||||
@@ -291,7 +291,7 @@ void FullFrameExecutionModel::get_output_render_area(NodeOperation *output_op, r
|
||||
void FullFrameExecutionModel::operation_finished(NodeOperation *operation)
|
||||
{
|
||||
/* Report inputs reads so that buffers may be freed/reused. */
|
||||
const int num_inputs = operation->getNumberOfInputSockets();
|
||||
const int num_inputs = operation->get_number_of_input_sockets();
|
||||
for (int i = 0; i < num_inputs; i++) {
|
||||
active_buffers_.read_finished(operation->get_input_operation(i));
|
||||
}
|
||||
@@ -302,7 +302,7 @@ void FullFrameExecutionModel::operation_finished(NodeOperation *operation)
|
||||
|
||||
void FullFrameExecutionModel::update_progress_bar()
|
||||
{
|
||||
const bNodeTree *tree = context_.getbNodeTree();
|
||||
const bNodeTree *tree = context_.get_bnodetree();
|
||||
if (tree) {
|
||||
const float progress = num_operations_finished_ / static_cast<float>(operations_.size());
|
||||
tree->progress(tree->prh, progress);
|
||||
|
@@ -18,6 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "COM_Enums.h"
|
||||
#include "COM_ExecutionModel.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
@@ -27,7 +30,11 @@
|
||||
namespace blender::compositor {
|
||||
|
||||
/* Forward declarations. */
|
||||
class ExecutionGroup;
|
||||
class CompositorContext;
|
||||
class ExecutionSystem;
|
||||
class MemoryBuffer;
|
||||
class NodeOperation;
|
||||
class SharedOperationBuffers;
|
||||
|
||||
/**
|
||||
* Fully renders operations in order from inputs to outputs.
|
||||
|
@@ -18,9 +18,10 @@
|
||||
|
||||
#include "COM_MemoryBuffer.h"
|
||||
|
||||
#include "COM_MemoryProxy.h"
|
||||
|
||||
#include "IMB_colormanagement.h"
|
||||
#include "IMB_imbuf_types.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#define ASSERT_BUFFER_CONTAINS_AREA(buf, area) \
|
||||
BLI_assert(BLI_rcti_inside_rcti(&(buf)->get_rect(), &(area)))
|
||||
@@ -43,32 +44,32 @@ static rcti create_rect(const int width, const int height)
|
||||
return rect;
|
||||
}
|
||||
|
||||
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state)
|
||||
MemoryBuffer::MemoryBuffer(MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state)
|
||||
{
|
||||
m_rect = rect;
|
||||
this->m_is_a_single_elem = false;
|
||||
this->m_memoryProxy = memoryProxy;
|
||||
this->m_num_channels = COM_data_type_num_channels(memoryProxy->getDataType());
|
||||
this->m_buffer = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer");
|
||||
rect_ = rect;
|
||||
is_a_single_elem_ = false;
|
||||
memory_proxy_ = memory_proxy;
|
||||
num_channels_ = COM_data_type_num_channels(memory_proxy->get_data_type());
|
||||
buffer_ = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
|
||||
owns_data_ = true;
|
||||
this->m_state = state;
|
||||
this->m_datatype = memoryProxy->getDataType();
|
||||
state_ = state;
|
||||
datatype_ = memory_proxy->get_data_type();
|
||||
|
||||
set_strides();
|
||||
}
|
||||
|
||||
MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect, bool is_a_single_elem)
|
||||
MemoryBuffer::MemoryBuffer(DataType data_type, const rcti &rect, bool is_a_single_elem)
|
||||
{
|
||||
m_rect = rect;
|
||||
this->m_is_a_single_elem = is_a_single_elem;
|
||||
this->m_memoryProxy = nullptr;
|
||||
this->m_num_channels = COM_data_type_num_channels(dataType);
|
||||
this->m_buffer = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer");
|
||||
rect_ = rect;
|
||||
is_a_single_elem_ = is_a_single_elem;
|
||||
memory_proxy_ = nullptr;
|
||||
num_channels_ = COM_data_type_num_channels(data_type);
|
||||
buffer_ = (float *)MEM_mallocN_aligned(
|
||||
sizeof(float) * buffer_len() * num_channels_, 16, "COM_MemoryBuffer");
|
||||
owns_data_ = true;
|
||||
this->m_state = MemoryBufferState::Temporary;
|
||||
this->m_datatype = dataType;
|
||||
state_ = MemoryBufferState::Temporary;
|
||||
datatype_ = data_type;
|
||||
|
||||
set_strides();
|
||||
}
|
||||
@@ -92,55 +93,54 @@ MemoryBuffer::MemoryBuffer(float *buffer,
|
||||
const rcti &rect,
|
||||
const bool is_a_single_elem)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_is_a_single_elem = is_a_single_elem;
|
||||
m_memoryProxy = nullptr;
|
||||
m_num_channels = num_channels;
|
||||
m_datatype = COM_num_channels_data_type(num_channels);
|
||||
m_buffer = buffer;
|
||||
rect_ = rect;
|
||||
is_a_single_elem_ = is_a_single_elem;
|
||||
memory_proxy_ = nullptr;
|
||||
num_channels_ = num_channels;
|
||||
datatype_ = COM_num_channels_data_type(num_channels);
|
||||
buffer_ = buffer;
|
||||
owns_data_ = false;
|
||||
m_state = MemoryBufferState::Temporary;
|
||||
state_ = MemoryBufferState::Temporary;
|
||||
|
||||
set_strides();
|
||||
}
|
||||
|
||||
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src)
|
||||
: MemoryBuffer(src.m_datatype, src.m_rect, false)
|
||||
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src) : MemoryBuffer(src.datatype_, src.rect_, false)
|
||||
{
|
||||
m_memoryProxy = src.m_memoryProxy;
|
||||
memory_proxy_ = src.memory_proxy_;
|
||||
/* src may be single elem buffer */
|
||||
fill_from(src);
|
||||
}
|
||||
|
||||
void MemoryBuffer::set_strides()
|
||||
{
|
||||
if (m_is_a_single_elem) {
|
||||
if (is_a_single_elem_) {
|
||||
this->elem_stride = 0;
|
||||
this->row_stride = 0;
|
||||
}
|
||||
else {
|
||||
this->elem_stride = m_num_channels;
|
||||
this->row_stride = getWidth() * m_num_channels;
|
||||
this->elem_stride = num_channels_;
|
||||
this->row_stride = get_width() * num_channels_;
|
||||
}
|
||||
to_positive_x_stride_ = m_rect.xmin < 0 ? -m_rect.xmin + 1 : (m_rect.xmin == 0 ? 1 : 0);
|
||||
to_positive_y_stride_ = m_rect.ymin < 0 ? -m_rect.ymin + 1 : (m_rect.ymin == 0 ? 1 : 0);
|
||||
to_positive_x_stride_ = rect_.xmin < 0 ? -rect_.xmin + 1 : (rect_.xmin == 0 ? 1 : 0);
|
||||
to_positive_y_stride_ = rect_.ymin < 0 ? -rect_.ymin + 1 : (rect_.ymin == 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
void MemoryBuffer::clear()
|
||||
{
|
||||
memset(m_buffer, 0, buffer_len() * m_num_channels * sizeof(float));
|
||||
memset(buffer_, 0, buffer_len() * num_channels_ * sizeof(float));
|
||||
}
|
||||
|
||||
BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs)
|
||||
{
|
||||
return iterate_with(inputs, m_rect);
|
||||
return iterate_with(inputs, rect_);
|
||||
}
|
||||
|
||||
BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, const rcti &area)
|
||||
{
|
||||
BuffersIteratorBuilder<float> builder(m_buffer, m_rect, area, elem_stride);
|
||||
BuffersIteratorBuilder<float> builder(buffer_, rect_, area, elem_stride);
|
||||
for (MemoryBuffer *input : inputs) {
|
||||
builder.add_input(input->getBuffer(), input->get_rect(), input->elem_stride);
|
||||
builder.add_input(input->get_buffer(), input->get_rect(), input->elem_stride);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
@@ -152,20 +152,20 @@ BuffersIterator<float> MemoryBuffer::iterate_with(Span<MemoryBuffer *> inputs, c
|
||||
MemoryBuffer *MemoryBuffer::inflate() const
|
||||
{
|
||||
BLI_assert(is_a_single_elem());
|
||||
MemoryBuffer *inflated = new MemoryBuffer(this->m_datatype, this->m_rect, false);
|
||||
inflated->copy_from(this, this->m_rect);
|
||||
MemoryBuffer *inflated = new MemoryBuffer(datatype_, rect_, false);
|
||||
inflated->copy_from(this, rect_);
|
||||
return inflated;
|
||||
}
|
||||
|
||||
float MemoryBuffer::get_max_value() const
|
||||
{
|
||||
float result = this->m_buffer[0];
|
||||
float result = buffer_[0];
|
||||
const unsigned int size = this->buffer_len();
|
||||
unsigned int i;
|
||||
|
||||
const float *fp_src = this->m_buffer;
|
||||
const float *fp_src = buffer_;
|
||||
|
||||
for (i = 0; i < size; i++, fp_src += this->m_num_channels) {
|
||||
for (i = 0; i < size; i++, fp_src += num_channels_) {
|
||||
float value = *fp_src;
|
||||
if (value > result) {
|
||||
result = value;
|
||||
@@ -180,10 +180,10 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
|
||||
rcti rect_clamp;
|
||||
|
||||
/* first clamp the rect by the bounds or we get un-initialized values */
|
||||
BLI_rcti_isect(&rect, &this->m_rect, &rect_clamp);
|
||||
BLI_rcti_isect(&rect, &rect_, &rect_clamp);
|
||||
|
||||
if (!BLI_rcti_is_empty(&rect_clamp)) {
|
||||
MemoryBuffer temp_buffer(this->m_datatype, rect_clamp);
|
||||
MemoryBuffer temp_buffer(datatype_, rect_clamp);
|
||||
temp_buffer.fill_from(*this);
|
||||
return temp_buffer.get_max_value();
|
||||
}
|
||||
@@ -194,9 +194,9 @@ float MemoryBuffer::get_max_value(const rcti &rect) const
|
||||
|
||||
MemoryBuffer::~MemoryBuffer()
|
||||
{
|
||||
if (this->m_buffer && owns_data_) {
|
||||
MEM_freeN(this->m_buffer);
|
||||
this->m_buffer = nullptr;
|
||||
if (buffer_ && owns_data_) {
|
||||
MEM_freeN(buffer_);
|
||||
buffer_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ void MemoryBuffer::copy_from(const MemoryBuffer *src,
|
||||
void MemoryBuffer::copy_from(const uchar *src, const rcti &area)
|
||||
{
|
||||
const int elem_stride = this->get_num_channels();
|
||||
const int row_stride = elem_stride * getWidth();
|
||||
const int row_stride = elem_stride * get_width();
|
||||
copy_from(src, area, 0, this->get_num_channels(), elem_stride, row_stride, 0);
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ static void colorspace_to_scene_linear(MemoryBuffer *buf, const rcti &area, Colo
|
||||
const int height = BLI_rcti_size_y(&area);
|
||||
float *out = buf->get_elem(area.xmin, area.ymin);
|
||||
/* If area allows continuous memory do conversion in one step. Otherwise per row. */
|
||||
if (buf->getWidth() == width) {
|
||||
if (buf->get_width() == width) {
|
||||
IMB_colormanagement_colorspace_to_scene_linear(
|
||||
out, width, height, buf->get_num_channels(), colorspace, false);
|
||||
}
|
||||
@@ -397,30 +397,28 @@ void MemoryBuffer::fill(const rcti &area,
|
||||
void MemoryBuffer::fill_from(const MemoryBuffer &src)
|
||||
{
|
||||
rcti overlap;
|
||||
overlap.xmin = MAX2(this->m_rect.xmin, src.m_rect.xmin);
|
||||
overlap.xmax = MIN2(this->m_rect.xmax, src.m_rect.xmax);
|
||||
overlap.ymin = MAX2(this->m_rect.ymin, src.m_rect.ymin);
|
||||
overlap.ymax = MIN2(this->m_rect.ymax, src.m_rect.ymax);
|
||||
overlap.xmin = MAX2(rect_.xmin, src.rect_.xmin);
|
||||
overlap.xmax = MIN2(rect_.xmax, src.rect_.xmax);
|
||||
overlap.ymin = MAX2(rect_.ymin, src.rect_.ymin);
|
||||
overlap.ymax = MIN2(rect_.ymax, src.rect_.ymax);
|
||||
copy_from(&src, overlap);
|
||||
}
|
||||
|
||||
void MemoryBuffer::writePixel(int x, int y, const float color[4])
|
||||
void MemoryBuffer::write_pixel(int x, int y, const float color[4])
|
||||
{
|
||||
if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
|
||||
y < this->m_rect.ymax) {
|
||||
if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
|
||||
const int offset = get_coords_offset(x, y);
|
||||
memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels);
|
||||
memcpy(&buffer_[offset], color, sizeof(float) * num_channels_);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryBuffer::addPixel(int x, int y, const float color[4])
|
||||
void MemoryBuffer::add_pixel(int x, int y, const float color[4])
|
||||
{
|
||||
if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
|
||||
y < this->m_rect.ymax) {
|
||||
if (x >= rect_.xmin && x < rect_.xmax && y >= rect_.ymin && y < rect_.ymax) {
|
||||
const int offset = get_coords_offset(x, y);
|
||||
float *dst = &this->m_buffer[offset];
|
||||
float *dst = &buffer_[offset];
|
||||
const float *src = color;
|
||||
for (int i = 0; i < this->m_num_channels; i++, dst++, src++) {
|
||||
for (int i = 0; i < num_channels_; i++, dst++, src++) {
|
||||
*dst += *src;
|
||||
}
|
||||
}
|
||||
@@ -435,11 +433,11 @@ static void read_ewa_elem(void *userdata, int x, int y, float result[4])
|
||||
void MemoryBuffer::read_elem_filtered(
|
||||
const float x, const float y, float dx[2], float dy[2], float *out) const
|
||||
{
|
||||
BLI_assert(this->m_datatype == DataType::Color);
|
||||
BLI_assert(datatype_ == DataType::Color);
|
||||
|
||||
const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}};
|
||||
|
||||
float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight();
|
||||
float inv_width = 1.0f / (float)this->get_width(), inv_height = 1.0f / (float)this->get_height();
|
||||
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
|
||||
* but compositor uses pixel space. For now let's just divide the values and
|
||||
* switch compositor to normalized space for EWA later.
|
||||
@@ -448,8 +446,8 @@ void MemoryBuffer::read_elem_filtered(
|
||||
float du_normal[2] = {deriv[0][0] * inv_width, deriv[0][1] * inv_height};
|
||||
float dv_normal[2] = {deriv[1][0] * inv_width, deriv[1][1] * inv_height};
|
||||
|
||||
BLI_ewa_filter(this->getWidth(),
|
||||
this->getHeight(),
|
||||
BLI_ewa_filter(this->get_width(),
|
||||
this->get_height(),
|
||||
false,
|
||||
true,
|
||||
uv_normal,
|
||||
@@ -470,12 +468,13 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2])
|
||||
{
|
||||
if (m_is_a_single_elem) {
|
||||
memcpy(result, m_buffer, sizeof(float) * this->m_num_channels);
|
||||
if (is_a_single_elem_) {
|
||||
memcpy(result, buffer_, sizeof(float) * num_channels_);
|
||||
}
|
||||
else {
|
||||
BLI_assert(this->m_datatype == DataType::Color);
|
||||
float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight();
|
||||
BLI_assert(datatype_ == DataType::Color);
|
||||
float inv_width = 1.0f / (float)this->get_width(),
|
||||
inv_height = 1.0f / (float)this->get_height();
|
||||
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
|
||||
* but compositor uses pixel space. For now let's just divide the values and
|
||||
* switch compositor to normalized space for EWA later.
|
||||
@@ -484,8 +483,8 @@ void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivat
|
||||
float du_normal[2] = {derivatives[0][0] * inv_width, derivatives[0][1] * inv_height};
|
||||
float dv_normal[2] = {derivatives[1][0] * inv_width, derivatives[1][1] * inv_height};
|
||||
|
||||
BLI_ewa_filter(this->getWidth(),
|
||||
this->getHeight(),
|
||||
BLI_ewa_filter(this->get_width(),
|
||||
this->get_height(),
|
||||
false,
|
||||
true,
|
||||
uv_normal,
|
||||
|
@@ -21,12 +21,13 @@
|
||||
#include "COM_BufferArea.h"
|
||||
#include "COM_BufferRange.h"
|
||||
#include "COM_BuffersIterator.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_MemoryProxy.h"
|
||||
#include "COM_Enums.h"
|
||||
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_interp.h"
|
||||
#include "BLI_rect.h"
|
||||
|
||||
struct ImBuf;
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
/**
|
||||
@@ -76,38 +77,38 @@ class MemoryBuffer {
|
||||
/**
|
||||
* \brief proxy of the memory (same for all chunks in the same buffer)
|
||||
*/
|
||||
MemoryProxy *m_memoryProxy;
|
||||
MemoryProxy *memory_proxy_;
|
||||
|
||||
/**
|
||||
* \brief the type of buffer DataType::Value, DataType::Vector, DataType::Color
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
/**
|
||||
* \brief region of this buffer inside relative to the MemoryProxy
|
||||
*/
|
||||
rcti m_rect;
|
||||
rcti rect_;
|
||||
|
||||
/**
|
||||
* \brief state of the buffer
|
||||
*/
|
||||
MemoryBufferState m_state;
|
||||
MemoryBufferState state_;
|
||||
|
||||
/**
|
||||
* \brief the actual float buffer/data
|
||||
*/
|
||||
float *m_buffer;
|
||||
float *buffer_;
|
||||
|
||||
/**
|
||||
* \brief the number of channels of a single value in the buffer.
|
||||
* For value buffers this is 1, vector 3 and color 4
|
||||
*/
|
||||
uint8_t m_num_channels;
|
||||
uint8_t num_channels_;
|
||||
|
||||
/**
|
||||
* Whether buffer is a single element in memory.
|
||||
*/
|
||||
bool m_is_a_single_elem;
|
||||
bool is_a_single_elem_;
|
||||
|
||||
/**
|
||||
* Whether MemoryBuffer owns buffer data.
|
||||
@@ -124,12 +125,12 @@ class MemoryBuffer {
|
||||
/**
|
||||
* \brief construct new temporarily MemoryBuffer for an area
|
||||
*/
|
||||
MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state);
|
||||
MemoryBuffer(MemoryProxy *memory_proxy, const rcti &rect, MemoryBufferState state);
|
||||
|
||||
/**
|
||||
* \brief construct new temporarily MemoryBuffer for an area
|
||||
*/
|
||||
MemoryBuffer(DataType datatype, const rcti &rect, bool is_a_single_elem = false);
|
||||
MemoryBuffer(DataType data_type, const rcti &rect, bool is_a_single_elem = false);
|
||||
|
||||
MemoryBuffer(
|
||||
float *buffer, int num_channels, int width, int height, bool is_a_single_elem = false);
|
||||
@@ -152,21 +153,21 @@ class MemoryBuffer {
|
||||
*/
|
||||
bool is_a_single_elem() const
|
||||
{
|
||||
return m_is_a_single_elem;
|
||||
return is_a_single_elem_;
|
||||
}
|
||||
|
||||
float &operator[](int index)
|
||||
{
|
||||
BLI_assert(m_is_a_single_elem ? index < m_num_channels :
|
||||
index < get_coords_offset(getWidth(), getHeight()));
|
||||
return m_buffer[index];
|
||||
BLI_assert(is_a_single_elem_ ? index < num_channels_ :
|
||||
index < get_coords_offset(get_width(), get_height()));
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
const float &operator[](int index) const
|
||||
{
|
||||
BLI_assert(m_is_a_single_elem ? index < m_num_channels :
|
||||
index < get_coords_offset(getWidth(), getHeight()));
|
||||
return m_buffer[index];
|
||||
BLI_assert(is_a_single_elem_ ? index < num_channels_ :
|
||||
index < get_coords_offset(get_width(), get_height()));
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,7 +175,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
intptr_t get_coords_offset(int x, int y) const
|
||||
{
|
||||
return ((intptr_t)y - m_rect.ymin) * row_stride + ((intptr_t)x - m_rect.xmin) * elem_stride;
|
||||
return ((intptr_t)y - rect_.ymin) * row_stride + ((intptr_t)x - rect_.xmin) * elem_stride;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +184,7 @@ class MemoryBuffer {
|
||||
float *get_elem(int x, int y)
|
||||
{
|
||||
BLI_assert(has_coords(x, y));
|
||||
return m_buffer + get_coords_offset(x, y);
|
||||
return buffer_ + get_coords_offset(x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -192,7 +193,7 @@ class MemoryBuffer {
|
||||
const float *get_elem(int x, int y) const
|
||||
{
|
||||
BLI_assert(has_coords(x, y));
|
||||
return m_buffer + get_coords_offset(x, y);
|
||||
return buffer_ + get_coords_offset(x, y);
|
||||
}
|
||||
|
||||
void read_elem(int x, int y, float *out) const
|
||||
@@ -218,21 +219,19 @@ class MemoryBuffer {
|
||||
void read_elem_bilinear(float x, float y, float *out) const
|
||||
{
|
||||
/* Only clear past +/-1 borders to be able to smooth edges. */
|
||||
if (x <= m_rect.xmin - 1.0f || x >= m_rect.xmax || y <= m_rect.ymin - 1.0f ||
|
||||
y >= m_rect.ymax) {
|
||||
if (x <= rect_.xmin - 1.0f || x >= rect_.xmax || y <= rect_.ymin - 1.0f || y >= rect_.ymax) {
|
||||
clear_elem(out);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_is_a_single_elem) {
|
||||
if (x >= m_rect.xmin && x < m_rect.xmax - 1.0f && y >= m_rect.ymin &&
|
||||
y < m_rect.ymax - 1.0f) {
|
||||
memcpy(out, m_buffer, get_elem_bytes_len());
|
||||
if (is_a_single_elem_) {
|
||||
if (x >= rect_.xmin && x < rect_.xmax - 1.0f && y >= rect_.ymin && y < rect_.ymax - 1.0f) {
|
||||
memcpy(out, buffer_, get_elem_bytes_len());
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do sampling at borders to smooth edges. */
|
||||
const float last_x = getWidth() - 1.0f;
|
||||
const float last_x = get_width() - 1.0f;
|
||||
const float rel_x = get_relative_x(x);
|
||||
float single_x = 0.0f;
|
||||
if (rel_x < 0.0f) {
|
||||
@@ -242,7 +241,7 @@ class MemoryBuffer {
|
||||
single_x = rel_x - last_x;
|
||||
}
|
||||
|
||||
const float last_y = getHeight() - 1.0f;
|
||||
const float last_y = get_height() - 1.0f;
|
||||
const float rel_y = get_relative_y(y);
|
||||
float single_y = 0.0f;
|
||||
if (rel_y < 0.0f) {
|
||||
@@ -252,15 +251,15 @@ class MemoryBuffer {
|
||||
single_y = rel_y - last_y;
|
||||
}
|
||||
|
||||
BLI_bilinear_interpolation_fl(m_buffer, out, 1, 1, m_num_channels, single_x, single_y);
|
||||
BLI_bilinear_interpolation_fl(buffer_, out, 1, 1, num_channels_, single_x, single_y);
|
||||
return;
|
||||
}
|
||||
|
||||
BLI_bilinear_interpolation_fl(m_buffer,
|
||||
BLI_bilinear_interpolation_fl(buffer_,
|
||||
out,
|
||||
getWidth(),
|
||||
getHeight(),
|
||||
m_num_channels,
|
||||
get_width(),
|
||||
get_height(),
|
||||
num_channels_,
|
||||
get_relative_x(x),
|
||||
get_relative_y(y));
|
||||
}
|
||||
@@ -287,8 +286,8 @@ class MemoryBuffer {
|
||||
*/
|
||||
float &get_value(int x, int y, int channel)
|
||||
{
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels);
|
||||
return m_buffer[get_coords_offset(x, y) + channel];
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
|
||||
return buffer_[get_coords_offset(x, y) + channel];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,8 +295,8 @@ class MemoryBuffer {
|
||||
*/
|
||||
const float &get_value(int x, int y, int channel) const
|
||||
{
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < m_num_channels);
|
||||
return m_buffer[get_coords_offset(x, y) + channel];
|
||||
BLI_assert(has_coords(x, y) && channel >= 0 && channel < num_channels_);
|
||||
return buffer_[get_coords_offset(x, y) + channel];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +305,7 @@ class MemoryBuffer {
|
||||
const float *get_row_end(int y) const
|
||||
{
|
||||
BLI_assert(has_y(y));
|
||||
return m_buffer + (is_a_single_elem() ? m_num_channels : get_coords_offset(getWidth(), y));
|
||||
return buffer_ + (is_a_single_elem() ? num_channels_ : get_coords_offset(get_width(), y));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +314,7 @@ class MemoryBuffer {
|
||||
*/
|
||||
int get_memory_width() const
|
||||
{
|
||||
return is_a_single_elem() ? 1 : getWidth();
|
||||
return is_a_single_elem() ? 1 : get_width();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -324,17 +323,17 @@ class MemoryBuffer {
|
||||
*/
|
||||
int get_memory_height() const
|
||||
{
|
||||
return is_a_single_elem() ? 1 : getHeight();
|
||||
return is_a_single_elem() ? 1 : get_height();
|
||||
}
|
||||
|
||||
uint8_t get_num_channels() const
|
||||
{
|
||||
return this->m_num_channels;
|
||||
return num_channels_;
|
||||
}
|
||||
|
||||
uint8_t get_elem_bytes_len() const
|
||||
{
|
||||
return this->m_num_channels * sizeof(float);
|
||||
return num_channels_ * sizeof(float);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,22 +341,22 @@ class MemoryBuffer {
|
||||
*/
|
||||
BufferRange<float> as_range()
|
||||
{
|
||||
return BufferRange<float>(m_buffer, 0, buffer_len(), elem_stride);
|
||||
return BufferRange<float>(buffer_, 0, buffer_len(), elem_stride);
|
||||
}
|
||||
|
||||
BufferRange<const float> as_range() const
|
||||
{
|
||||
return BufferRange<const float>(m_buffer, 0, buffer_len(), elem_stride);
|
||||
return BufferRange<const float>(buffer_, 0, buffer_len(), elem_stride);
|
||||
}
|
||||
|
||||
BufferArea<float> get_buffer_area(const rcti &area)
|
||||
{
|
||||
return BufferArea<float>(m_buffer, getWidth(), area, elem_stride);
|
||||
return BufferArea<float>(buffer_, get_width(), area, elem_stride);
|
||||
}
|
||||
|
||||
BufferArea<const float> get_buffer_area(const rcti &area) const
|
||||
{
|
||||
return BufferArea<const float>(m_buffer, getWidth(), area, elem_stride);
|
||||
return BufferArea<const float>(buffer_, get_width(), area, elem_stride);
|
||||
}
|
||||
|
||||
BuffersIterator<float> iterate_with(Span<MemoryBuffer *> inputs);
|
||||
@@ -367,25 +366,25 @@ class MemoryBuffer {
|
||||
* \brief get the data of this MemoryBuffer
|
||||
* \note buffer should already be available in memory
|
||||
*/
|
||||
float *getBuffer()
|
||||
float *get_buffer()
|
||||
{
|
||||
return this->m_buffer;
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
float *release_ownership_buffer()
|
||||
{
|
||||
owns_data_ = false;
|
||||
return this->m_buffer;
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
MemoryBuffer *inflate() const;
|
||||
|
||||
inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
|
||||
{
|
||||
const int w = getWidth();
|
||||
const int h = getHeight();
|
||||
x = x - m_rect.xmin;
|
||||
y = y - m_rect.ymin;
|
||||
const int w = get_width();
|
||||
const int h = get_height();
|
||||
x = x - rect_.xmin;
|
||||
y = y - rect_.ymin;
|
||||
|
||||
switch (extend_x) {
|
||||
case MemoryBufferExtend::Clip:
|
||||
@@ -425,8 +424,8 @@ class MemoryBuffer {
|
||||
break;
|
||||
}
|
||||
|
||||
x = x + m_rect.xmin;
|
||||
y = y + m_rect.ymin;
|
||||
x = x + rect_.xmin;
|
||||
y = y + rect_.ymin;
|
||||
}
|
||||
|
||||
inline void wrap_pixel(float &x,
|
||||
@@ -434,10 +433,10 @@ class MemoryBuffer {
|
||||
MemoryBufferExtend extend_x,
|
||||
MemoryBufferExtend extend_y) const
|
||||
{
|
||||
const float w = (float)getWidth();
|
||||
const float h = (float)getHeight();
|
||||
x = x - m_rect.xmin;
|
||||
y = y - m_rect.ymin;
|
||||
const float w = (float)get_width();
|
||||
const float h = (float)get_height();
|
||||
x = x - rect_.xmin;
|
||||
y = y - rect_.ymin;
|
||||
|
||||
switch (extend_x) {
|
||||
case MemoryBufferExtend::Clip:
|
||||
@@ -477,8 +476,8 @@ class MemoryBuffer {
|
||||
break;
|
||||
}
|
||||
|
||||
x = x + m_rect.xmin;
|
||||
y = y + m_rect.ymin;
|
||||
x = x + rect_.xmin;
|
||||
y = y + rect_.ymin;
|
||||
}
|
||||
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. For applying #MemoryBufferExtend
|
||||
@@ -489,28 +488,28 @@ class MemoryBuffer {
|
||||
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
|
||||
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip)
|
||||
{
|
||||
bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < m_rect.xmin || x >= m_rect.xmax));
|
||||
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < m_rect.ymin || y >= m_rect.ymax));
|
||||
bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < rect_.xmin || x >= rect_.xmax));
|
||||
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < rect_.ymin || y >= rect_.ymax));
|
||||
if (clip_x || clip_y) {
|
||||
/* clip result outside rect is zero */
|
||||
memset(result, 0, this->m_num_channels * sizeof(float));
|
||||
memset(result, 0, num_channels_ * sizeof(float));
|
||||
}
|
||||
else {
|
||||
int u = x;
|
||||
int v = y;
|
||||
this->wrap_pixel(u, v, extend_x, extend_y);
|
||||
const int offset = get_coords_offset(u, v);
|
||||
float *buffer = &this->m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * this->m_num_channels);
|
||||
float *buffer = &buffer_[offset];
|
||||
memcpy(result, buffer, sizeof(float) * num_channels_);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
inline void readNoCheck(float *result,
|
||||
int x,
|
||||
int y,
|
||||
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
|
||||
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip)
|
||||
inline void read_no_check(float *result,
|
||||
int x,
|
||||
int y,
|
||||
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
|
||||
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip)
|
||||
{
|
||||
int u = x;
|
||||
int v = y;
|
||||
@@ -519,38 +518,38 @@ class MemoryBuffer {
|
||||
const int offset = get_coords_offset(u, v);
|
||||
|
||||
BLI_assert(offset >= 0);
|
||||
BLI_assert(offset < this->buffer_len() * this->m_num_channels);
|
||||
BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < m_rect.xmin || u >= m_rect.xmax)) &&
|
||||
!(extend_y == MemoryBufferExtend::Clip && (v < m_rect.ymin || v >= m_rect.ymax)));
|
||||
float *buffer = &this->m_buffer[offset];
|
||||
memcpy(result, buffer, sizeof(float) * this->m_num_channels);
|
||||
BLI_assert(offset < this->buffer_len() * num_channels_);
|
||||
BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < rect_.xmin || u >= rect_.xmax)) &&
|
||||
!(extend_y == MemoryBufferExtend::Clip && (v < rect_.ymin || v >= rect_.ymax)));
|
||||
float *buffer = &buffer_[offset];
|
||||
memcpy(result, buffer, sizeof(float) * num_channels_);
|
||||
}
|
||||
|
||||
void writePixel(int x, int y, const float color[4]);
|
||||
void addPixel(int x, int y, const float color[4]);
|
||||
inline void readBilinear(float *result,
|
||||
float x,
|
||||
float y,
|
||||
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
|
||||
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) const
|
||||
void write_pixel(int x, int y, const float color[4]);
|
||||
void add_pixel(int x, int y, const float color[4]);
|
||||
inline void read_bilinear(float *result,
|
||||
float x,
|
||||
float y,
|
||||
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip,
|
||||
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) const
|
||||
{
|
||||
float u = x;
|
||||
float v = y;
|
||||
this->wrap_pixel(u, v, extend_x, extend_y);
|
||||
if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= getWidth())) ||
|
||||
(extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= getHeight()))) {
|
||||
copy_vn_fl(result, this->m_num_channels, 0.0f);
|
||||
if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= get_width())) ||
|
||||
(extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= get_height()))) {
|
||||
copy_vn_fl(result, num_channels_, 0.0f);
|
||||
return;
|
||||
}
|
||||
if (m_is_a_single_elem) {
|
||||
memcpy(result, m_buffer, sizeof(float) * this->m_num_channels);
|
||||
if (is_a_single_elem_) {
|
||||
memcpy(result, buffer_, sizeof(float) * num_channels_);
|
||||
}
|
||||
else {
|
||||
BLI_bilinear_interpolation_wrap_fl(this->m_buffer,
|
||||
BLI_bilinear_interpolation_wrap_fl(buffer_,
|
||||
result,
|
||||
getWidth(),
|
||||
getHeight(),
|
||||
this->m_num_channels,
|
||||
get_width(),
|
||||
get_height(),
|
||||
num_channels_,
|
||||
u,
|
||||
v,
|
||||
extend_x == MemoryBufferExtend::Repeat,
|
||||
@@ -563,9 +562,9 @@ class MemoryBuffer {
|
||||
/**
|
||||
* \brief is this MemoryBuffer a temporarily buffer (based on an area, not on a chunk)
|
||||
*/
|
||||
inline bool isTemporarily() const
|
||||
inline bool is_temporarily() const
|
||||
{
|
||||
return this->m_state == MemoryBufferState::Temporary;
|
||||
return state_ == MemoryBufferState::Temporary;
|
||||
}
|
||||
|
||||
void copy_from(const MemoryBuffer *src, const rcti &area);
|
||||
@@ -618,8 +617,8 @@ class MemoryBuffer {
|
||||
void fill(const rcti &area, const float *value);
|
||||
void fill(const rcti &area, int channel_offset, const float *value, int value_size);
|
||||
/**
|
||||
* \brief add the content from otherBuffer to this MemoryBuffer
|
||||
* \param otherBuffer: source buffer
|
||||
* \brief add the content from other_buffer to this MemoryBuffer
|
||||
* \param other_buffer: source buffer
|
||||
*
|
||||
* \note take care when running this on a new buffer since it won't fill in
|
||||
* uninitialized values in areas where the buffers don't overlap.
|
||||
@@ -631,23 +630,23 @@ class MemoryBuffer {
|
||||
*/
|
||||
const rcti &get_rect() const
|
||||
{
|
||||
return this->m_rect;
|
||||
return rect_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the width of this MemoryBuffer
|
||||
*/
|
||||
const int getWidth() const
|
||||
const int get_width() const
|
||||
{
|
||||
return BLI_rcti_size_x(&m_rect);
|
||||
return BLI_rcti_size_x(&rect_);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the height of this MemoryBuffer
|
||||
*/
|
||||
const int getHeight() const
|
||||
const int get_height() const
|
||||
{
|
||||
return BLI_rcti_size_y(&m_rect);
|
||||
return BLI_rcti_size_y(&rect_);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -667,17 +666,17 @@ class MemoryBuffer {
|
||||
|
||||
void clear_elem(float *out) const
|
||||
{
|
||||
memset(out, 0, this->m_num_channels * sizeof(float));
|
||||
memset(out, 0, num_channels_ * sizeof(float));
|
||||
}
|
||||
|
||||
template<typename T> T get_relative_x(T x) const
|
||||
{
|
||||
return x - m_rect.xmin;
|
||||
return x - rect_.xmin;
|
||||
}
|
||||
|
||||
template<typename T> T get_relative_y(T y) const
|
||||
{
|
||||
return y - m_rect.ymin;
|
||||
return y - rect_.ymin;
|
||||
}
|
||||
|
||||
template<typename T> bool has_coords(T x, T y) const
|
||||
@@ -687,12 +686,12 @@ class MemoryBuffer {
|
||||
|
||||
template<typename T> bool has_x(T x) const
|
||||
{
|
||||
return x >= m_rect.xmin && x < m_rect.xmax;
|
||||
return x >= rect_.xmin && x < rect_.xmax;
|
||||
}
|
||||
|
||||
template<typename T> bool has_y(T y) const
|
||||
{
|
||||
return y >= m_rect.ymin && y < m_rect.ymax;
|
||||
return y >= rect_.ymin && y < rect_.ymax;
|
||||
}
|
||||
|
||||
/* Fast `floor(..)` functions. The caller should check result is within buffer bounds.
|
||||
|
@@ -17,18 +17,15 @@
|
||||
*/
|
||||
|
||||
#include "COM_MemoryProxy.h"
|
||||
|
||||
#include "COM_MemoryBuffer.h"
|
||||
|
||||
#include "BLI_rect.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
MemoryProxy::MemoryProxy(DataType datatype)
|
||||
{
|
||||
this->m_writeBufferOperation = nullptr;
|
||||
this->m_executor = nullptr;
|
||||
this->m_datatype = datatype;
|
||||
write_buffer_operation_ = nullptr;
|
||||
executor_ = nullptr;
|
||||
datatype_ = datatype;
|
||||
}
|
||||
|
||||
void MemoryProxy::allocate(unsigned int width, unsigned int height)
|
||||
@@ -39,14 +36,14 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height)
|
||||
result.ymin = 0;
|
||||
result.ymax = height;
|
||||
|
||||
this->m_buffer = new MemoryBuffer(this, result, MemoryBufferState::Default);
|
||||
buffer_ = new MemoryBuffer(this, result, MemoryBufferState::Default);
|
||||
}
|
||||
|
||||
void MemoryProxy::free()
|
||||
{
|
||||
if (this->m_buffer) {
|
||||
delete this->m_buffer;
|
||||
this->m_buffer = nullptr;
|
||||
if (buffer_) {
|
||||
delete buffer_;
|
||||
buffer_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -42,22 +42,22 @@ class MemoryProxy {
|
||||
/**
|
||||
* \brief reference to the output operation of the executiongroup
|
||||
*/
|
||||
WriteBufferOperation *m_writeBufferOperation;
|
||||
WriteBufferOperation *write_buffer_operation_;
|
||||
|
||||
/**
|
||||
* \brief reference to the executor. the Execution group that can fill a chunk
|
||||
*/
|
||||
ExecutionGroup *m_executor;
|
||||
ExecutionGroup *executor_;
|
||||
|
||||
/**
|
||||
* \brief the allocated memory
|
||||
*/
|
||||
MemoryBuffer *m_buffer;
|
||||
MemoryBuffer *buffer_;
|
||||
|
||||
/**
|
||||
* \brief datatype of this MemoryProxy
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
public:
|
||||
MemoryProxy(DataType type);
|
||||
@@ -66,35 +66,35 @@ class MemoryProxy {
|
||||
* \brief set the ExecutionGroup that can be scheduled to calculate a certain chunk.
|
||||
* \param group: the ExecutionGroup to set
|
||||
*/
|
||||
void setExecutor(ExecutionGroup *executor)
|
||||
void set_executor(ExecutionGroup *executor)
|
||||
{
|
||||
this->m_executor = executor;
|
||||
executor_ = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the ExecutionGroup that can be scheduled to calculate a certain chunk.
|
||||
*/
|
||||
ExecutionGroup *getExecutor() const
|
||||
ExecutionGroup *get_executor() const
|
||||
{
|
||||
return this->m_executor;
|
||||
return executor_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the WriteBufferOperation that is responsible for writing to this MemoryProxy
|
||||
* \param operation:
|
||||
*/
|
||||
void setWriteBufferOperation(WriteBufferOperation *operation)
|
||||
void set_write_buffer_operation(WriteBufferOperation *operation)
|
||||
{
|
||||
this->m_writeBufferOperation = operation;
|
||||
write_buffer_operation_ = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the WriteBufferOperation that is responsible for writing to this MemoryProxy
|
||||
* \return WriteBufferOperation
|
||||
*/
|
||||
WriteBufferOperation *getWriteBufferOperation() const
|
||||
WriteBufferOperation *get_write_buffer_operation() const
|
||||
{
|
||||
return this->m_writeBufferOperation;
|
||||
return write_buffer_operation_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -110,14 +110,14 @@ class MemoryProxy {
|
||||
/**
|
||||
* \brief get the allocated memory
|
||||
*/
|
||||
inline MemoryBuffer *getBuffer()
|
||||
inline MemoryBuffer *get_buffer()
|
||||
{
|
||||
return this->m_buffer;
|
||||
return buffer_;
|
||||
}
|
||||
|
||||
inline DataType getDataType()
|
||||
inline DataType get_data_type()
|
||||
{
|
||||
return this->m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
|
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "RE_pipeline.h"
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
void MetaData::add(const blender::StringRef key, const blender::StringRef value)
|
||||
@@ -31,9 +29,9 @@ void MetaData::add(const blender::StringRef key, const blender::StringRef value)
|
||||
entries_.add(key, value);
|
||||
}
|
||||
|
||||
void MetaData::addCryptomatteEntry(const blender::StringRef layer_name,
|
||||
const blender::StringRefNull key,
|
||||
const blender::StringRef value)
|
||||
void MetaData::add_cryptomatte_entry(const blender::StringRef layer_name,
|
||||
const blender::StringRefNull key,
|
||||
const blender::StringRef value)
|
||||
{
|
||||
add(blender::bke::cryptomatte::BKE_cryptomatte_meta_data_key(layer_name, key), value);
|
||||
}
|
||||
@@ -42,7 +40,7 @@ void MetaData::addCryptomatteEntry(const blender::StringRef layer_name,
|
||||
*
|
||||
* When a conversion happens it will also add the cryptomatte name key with the given
|
||||
* `layer_name`. */
|
||||
void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name)
|
||||
void MetaData::replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name)
|
||||
{
|
||||
std::string cryptomatte_hash = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_HASH, "");
|
||||
std::string cryptomatte_conversion = entries_.pop_default(META_DATA_KEY_CRYPTOMATTE_CONVERSION,
|
||||
@@ -51,27 +49,28 @@ void MetaData::replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_
|
||||
|
||||
if (cryptomatte_hash.length() || cryptomatte_conversion.length() ||
|
||||
cryptomatte_manifest.length()) {
|
||||
addCryptomatteEntry(layer_name, "name", layer_name);
|
||||
add_cryptomatte_entry(layer_name, "name", layer_name);
|
||||
}
|
||||
if (cryptomatte_hash.length()) {
|
||||
addCryptomatteEntry(layer_name, "hash", cryptomatte_hash);
|
||||
add_cryptomatte_entry(layer_name, "hash", cryptomatte_hash);
|
||||
}
|
||||
if (cryptomatte_conversion.length()) {
|
||||
addCryptomatteEntry(layer_name, "conversion", cryptomatte_conversion);
|
||||
add_cryptomatte_entry(layer_name, "conversion", cryptomatte_conversion);
|
||||
}
|
||||
if (cryptomatte_manifest.length()) {
|
||||
addCryptomatteEntry(layer_name, "manifest", cryptomatte_manifest);
|
||||
add_cryptomatte_entry(layer_name, "manifest", cryptomatte_manifest);
|
||||
}
|
||||
}
|
||||
|
||||
void MetaData::addToRenderResult(RenderResult *render_result) const
|
||||
void MetaData::add_to_render_result(RenderResult *render_result) const
|
||||
{
|
||||
for (Map<std::string, std::string>::Item entry : entries_.items()) {
|
||||
BKE_render_result_stamp_data(render_result, entry.key.c_str(), entry.value.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void MetaDataExtractCallbackData::addMetaData(blender::StringRef key, blender::StringRefNull value)
|
||||
void MetaDataExtractCallbackData::add_meta_data(blender::StringRef key,
|
||||
blender::StringRefNull value)
|
||||
{
|
||||
if (!meta_data) {
|
||||
meta_data = std::make_unique<MetaData>();
|
||||
@@ -79,7 +78,7 @@ void MetaDataExtractCallbackData::addMetaData(blender::StringRef key, blender::S
|
||||
meta_data->add(key, value);
|
||||
}
|
||||
|
||||
void MetaDataExtractCallbackData::setCryptomatteKeys(blender::StringRef cryptomatte_layer_name)
|
||||
void MetaDataExtractCallbackData::set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name)
|
||||
{
|
||||
manifest_key = blender::bke::cryptomatte::BKE_cryptomatte_meta_data_key(cryptomatte_layer_name,
|
||||
"manifest");
|
||||
@@ -97,13 +96,13 @@ void MetaDataExtractCallbackData::extract_cryptomatte_meta_data(void *_data,
|
||||
MetaDataExtractCallbackData *data = static_cast<MetaDataExtractCallbackData *>(_data);
|
||||
blender::StringRefNull key(propname);
|
||||
if (key == data->hash_key) {
|
||||
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_HASH, propvalue);
|
||||
data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_HASH, propvalue);
|
||||
}
|
||||
else if (key == data->conversion_key) {
|
||||
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_CONVERSION, propvalue);
|
||||
data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_CONVERSION, propvalue);
|
||||
}
|
||||
else if (key == data->manifest_key) {
|
||||
data->addMetaData(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue);
|
||||
data->add_meta_data(META_DATA_KEY_CRYPTOMATTE_MANIFEST, propvalue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -44,14 +44,14 @@ constexpr blender::StringRef META_DATA_KEY_CRYPTOMATTE_NAME("cryptomatte/{hash}/
|
||||
class MetaData {
|
||||
private:
|
||||
Map<std::string, std::string> entries_;
|
||||
void addCryptomatteEntry(const blender::StringRef layer_name,
|
||||
const blender::StringRefNull key,
|
||||
const blender::StringRef value);
|
||||
void add_cryptomatte_entry(const blender::StringRef layer_name,
|
||||
const blender::StringRefNull key,
|
||||
const blender::StringRef value);
|
||||
|
||||
public:
|
||||
void add(const blender::StringRef key, const blender::StringRef value);
|
||||
void replaceHashNeutralCryptomatteKeys(const blender::StringRef layer_name);
|
||||
void addToRenderResult(RenderResult *render_result) const;
|
||||
void replace_hash_neutral_cryptomatte_keys(const blender::StringRef layer_name);
|
||||
void add_to_render_result(RenderResult *render_result) const;
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MetaData")
|
||||
#endif
|
||||
@@ -63,8 +63,8 @@ struct MetaDataExtractCallbackData {
|
||||
std::string conversion_key;
|
||||
std::string manifest_key;
|
||||
|
||||
void addMetaData(blender::StringRef key, blender::StringRefNull value);
|
||||
void setCryptomatteKeys(blender::StringRef cryptomatte_layer_name);
|
||||
void add_meta_data(blender::StringRef key, blender::StringRefNull value);
|
||||
void set_cryptomatte_keys(blender::StringRef cryptomatte_layer_name);
|
||||
/* C type callback function (StampCallback). */
|
||||
static void extract_cryptomatte_meta_data(void *_data,
|
||||
const char *propname,
|
||||
|
@@ -18,6 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_array.h"
|
||||
|
||||
#include "COM_MultiThreadedOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
@@ -16,20 +16,10 @@
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "BKE_node.h"
|
||||
|
||||
#include "RNA_access.h"
|
||||
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_TranslateOperation.h"
|
||||
|
||||
#include "COM_SocketProxyNode.h"
|
||||
|
||||
#include "COM_defines.h"
|
||||
|
||||
#include "COM_Node.h" /* own include */
|
||||
|
||||
namespace blender::compositor {
|
||||
@@ -38,14 +28,14 @@ namespace blender::compositor {
|
||||
**** Node ****
|
||||
**************/
|
||||
|
||||
Node::Node(bNode *editorNode, bool create_sockets)
|
||||
: m_editorNodeTree(nullptr),
|
||||
m_editorNode(editorNode),
|
||||
m_inActiveGroup(false),
|
||||
m_instanceKey(NODE_INSTANCE_KEY_NONE)
|
||||
Node::Node(bNode *editor_node, bool create_sockets)
|
||||
: editor_node_tree_(nullptr),
|
||||
editor_node_(editor_node),
|
||||
in_active_group_(false),
|
||||
instance_key_(NODE_INSTANCE_KEY_NONE)
|
||||
{
|
||||
if (create_sockets) {
|
||||
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
|
||||
bNodeSocket *input = (bNodeSocket *)editor_node->inputs.first;
|
||||
while (input != nullptr) {
|
||||
DataType dt = DataType::Value;
|
||||
if (input->type == SOCK_RGBA) {
|
||||
@@ -55,10 +45,10 @@ Node::Node(bNode *editorNode, bool create_sockets)
|
||||
dt = DataType::Vector;
|
||||
}
|
||||
|
||||
this->addInputSocket(dt, input);
|
||||
this->add_input_socket(dt, input);
|
||||
input = input->next;
|
||||
}
|
||||
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
|
||||
bNodeSocket *output = (bNodeSocket *)editor_node->outputs.first;
|
||||
while (output != nullptr) {
|
||||
DataType dt = DataType::Value;
|
||||
if (output->type == SOCK_RGBA) {
|
||||
@@ -68,7 +58,7 @@ Node::Node(bNode *editorNode, bool create_sockets)
|
||||
dt = DataType::Vector;
|
||||
}
|
||||
|
||||
this->addOutputSocket(dt, output);
|
||||
this->add_output_socket(dt, output);
|
||||
output = output->next;
|
||||
}
|
||||
}
|
||||
@@ -84,43 +74,43 @@ Node::~Node()
|
||||
}
|
||||
}
|
||||
|
||||
void Node::addInputSocket(DataType datatype)
|
||||
void Node::add_input_socket(DataType datatype)
|
||||
{
|
||||
this->addInputSocket(datatype, nullptr);
|
||||
this->add_input_socket(datatype, nullptr);
|
||||
}
|
||||
|
||||
void Node::addInputSocket(DataType datatype, bNodeSocket *bSocket)
|
||||
void Node::add_input_socket(DataType datatype, bNodeSocket *bSocket)
|
||||
{
|
||||
NodeInput *socket = new NodeInput(this, bSocket, datatype);
|
||||
this->inputs.append(socket);
|
||||
}
|
||||
|
||||
void Node::addOutputSocket(DataType datatype)
|
||||
void Node::add_output_socket(DataType datatype)
|
||||
{
|
||||
this->addOutputSocket(datatype, nullptr);
|
||||
this->add_output_socket(datatype, nullptr);
|
||||
}
|
||||
void Node::addOutputSocket(DataType datatype, bNodeSocket *bSocket)
|
||||
void Node::add_output_socket(DataType datatype, bNodeSocket *bSocket)
|
||||
{
|
||||
NodeOutput *socket = new NodeOutput(this, bSocket, datatype);
|
||||
outputs.append(socket);
|
||||
}
|
||||
|
||||
NodeOutput *Node::getOutputSocket(unsigned int index) const
|
||||
NodeOutput *Node::get_output_socket(unsigned int index) const
|
||||
{
|
||||
return outputs[index];
|
||||
}
|
||||
|
||||
NodeInput *Node::getInputSocket(unsigned int index) const
|
||||
NodeInput *Node::get_input_socket(unsigned int index) const
|
||||
{
|
||||
return inputs[index];
|
||||
}
|
||||
|
||||
bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
|
||||
bNodeSocket *Node::get_editor_input_socket(int editor_node_input_socket_index)
|
||||
{
|
||||
bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first;
|
||||
bNodeSocket *bSock = (bNodeSocket *)this->get_bnode()->inputs.first;
|
||||
int index = 0;
|
||||
while (bSock != nullptr) {
|
||||
if (index == editorNodeInputSocketIndex) {
|
||||
if (index == editor_node_input_socket_index) {
|
||||
return bSock;
|
||||
}
|
||||
index++;
|
||||
@@ -128,12 +118,12 @@ bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex)
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex)
|
||||
bNodeSocket *Node::get_editor_output_socket(int editor_node_output_socket_index)
|
||||
{
|
||||
bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->outputs.first;
|
||||
bNodeSocket *bSock = (bNodeSocket *)this->get_bnode()->outputs.first;
|
||||
int index = 0;
|
||||
while (bSock != nullptr) {
|
||||
if (index == editorNodeOutputSocketIndex) {
|
||||
if (index == editor_node_output_socket_index) {
|
||||
return bSock;
|
||||
}
|
||||
index++;
|
||||
@@ -147,33 +137,33 @@ bNodeSocket *Node::getEditorOutputSocket(int editorNodeOutputSocketIndex)
|
||||
*******************/
|
||||
|
||||
NodeInput::NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype)
|
||||
: m_node(node), m_editorSocket(b_socket), m_datatype(datatype), m_link(nullptr)
|
||||
: node_(node), editor_socket_(b_socket), datatype_(datatype), link_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeInput::setLink(NodeOutput *link)
|
||||
void NodeInput::set_link(NodeOutput *link)
|
||||
{
|
||||
m_link = link;
|
||||
link_ = link;
|
||||
}
|
||||
|
||||
float NodeInput::getEditorValueFloat() const
|
||||
float NodeInput::get_editor_value_float() const
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
|
||||
RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr);
|
||||
return RNA_float_get(&ptr, "default_value");
|
||||
}
|
||||
|
||||
void NodeInput::getEditorValueColor(float *value) const
|
||||
void NodeInput::get_editor_value_color(float *value) const
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
|
||||
RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr);
|
||||
return RNA_float_get_array(&ptr, "default_value", value);
|
||||
}
|
||||
|
||||
void NodeInput::getEditorValueVector(float *value) const
|
||||
void NodeInput::get_editor_value_vector(float *value) const
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
|
||||
RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr);
|
||||
return RNA_float_get_array(&ptr, "default_value", value);
|
||||
}
|
||||
|
||||
@@ -182,28 +172,28 @@ void NodeInput::getEditorValueVector(float *value) const
|
||||
********************/
|
||||
|
||||
NodeOutput::NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype)
|
||||
: m_node(node), m_editorSocket(b_socket), m_datatype(datatype)
|
||||
: node_(node), editor_socket_(b_socket), datatype_(datatype)
|
||||
{
|
||||
}
|
||||
|
||||
float NodeOutput::getEditorValueFloat()
|
||||
float NodeOutput::get_editor_value_float()
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
|
||||
RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr);
|
||||
return RNA_float_get(&ptr, "default_value");
|
||||
}
|
||||
|
||||
void NodeOutput::getEditorValueColor(float *value)
|
||||
void NodeOutput::get_editor_value_color(float *value)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
|
||||
RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr);
|
||||
return RNA_float_get_array(&ptr, "default_value", value);
|
||||
}
|
||||
|
||||
void NodeOutput::getEditorValueVector(float *value)
|
||||
void NodeOutput::get_editor_value_vector(float *value)
|
||||
{
|
||||
PointerRNA ptr;
|
||||
RNA_pointer_create((ID *)getNode()->getbNodeTree(), &RNA_NodeSocket, getbNodeSocket(), &ptr);
|
||||
RNA_pointer_create((ID *)get_node()->get_bnodetree(), &RNA_NodeSocket, get_bnode_socket(), &ptr);
|
||||
return RNA_float_get_array(&ptr, "default_value", value);
|
||||
}
|
||||
|
||||
|
@@ -22,9 +22,6 @@
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
/* common node includes
|
||||
* added here so node files don't have to include themselves
|
||||
*/
|
||||
@@ -44,22 +41,22 @@ class Node {
|
||||
/**
|
||||
* \brief stores the reference to the SDNA bNode struct
|
||||
*/
|
||||
bNodeTree *m_editorNodeTree;
|
||||
bNodeTree *editor_node_tree_;
|
||||
|
||||
/**
|
||||
* \brief stores the reference to the SDNA bNode struct
|
||||
*/
|
||||
bNode *m_editorNode;
|
||||
bNode *editor_node_;
|
||||
|
||||
/**
|
||||
* \brief Is this node part of the active group
|
||||
*/
|
||||
bool m_inActiveGroup;
|
||||
bool in_active_group_;
|
||||
|
||||
/**
|
||||
* \brief Instance key to identify the node in an instance hash table
|
||||
*/
|
||||
bNodeInstanceKey m_instanceKey;
|
||||
bNodeInstanceKey instance_key_;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -73,23 +70,23 @@ class Node {
|
||||
Vector<NodeOutput *> outputs;
|
||||
|
||||
public:
|
||||
Node(bNode *editorNode, bool create_sockets = true);
|
||||
Node(bNode *editor_node, bool create_sockets = true);
|
||||
virtual ~Node();
|
||||
|
||||
/**
|
||||
* \brief get the reference to the SDNA bNode struct
|
||||
*/
|
||||
bNode *getbNode() const
|
||||
bNode *get_bnode() const
|
||||
{
|
||||
return m_editorNode;
|
||||
return editor_node_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get the reference to the SDNA bNodeTree struct
|
||||
*/
|
||||
bNodeTree *getbNodeTree() const
|
||||
bNodeTree *get_bnodetree() const
|
||||
{
|
||||
return m_editorNodeTree;
|
||||
return editor_node_tree_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,24 +95,24 @@ class Node {
|
||||
* node for highlight during execution.
|
||||
* \param bNode:
|
||||
*/
|
||||
void setbNode(bNode *node)
|
||||
void set_bnode(bNode *node)
|
||||
{
|
||||
this->m_editorNode = node;
|
||||
editor_node_ = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief set the reference to the bNodeTree
|
||||
* \param bNodeTree:
|
||||
*/
|
||||
void setbNodeTree(bNodeTree *nodetree)
|
||||
void set_bnodetree(bNodeTree *nodetree)
|
||||
{
|
||||
this->m_editorNodeTree = nodetree;
|
||||
editor_node_tree_ = nodetree;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief get access to the vector of input sockets
|
||||
*/
|
||||
const Vector<NodeInput *> &getInputSockets() const
|
||||
const Vector<NodeInput *> &get_input_sockets() const
|
||||
{
|
||||
return this->inputs;
|
||||
}
|
||||
@@ -123,7 +120,7 @@ class Node {
|
||||
/**
|
||||
* \brief get access to the vector of input sockets
|
||||
*/
|
||||
const Vector<NodeOutput *> &getOutputSockets() const
|
||||
const Vector<NodeOutput *> &get_output_sockets() const
|
||||
{
|
||||
return this->outputs;
|
||||
}
|
||||
@@ -133,22 +130,22 @@ class Node {
|
||||
* \param index:
|
||||
* the index of the needed outputsocket
|
||||
*/
|
||||
NodeOutput *getOutputSocket(const unsigned int index = 0) const;
|
||||
NodeOutput *get_output_socket(const unsigned int index = 0) const;
|
||||
|
||||
/**
|
||||
* get the reference to a certain inputsocket
|
||||
* \param index:
|
||||
* the index of the needed inputsocket
|
||||
*/
|
||||
NodeInput *getInputSocket(const unsigned int index) const;
|
||||
NodeInput *get_input_socket(const unsigned int index) const;
|
||||
|
||||
/**
|
||||
* \brief Is this node in the active group (the group that is being edited)
|
||||
* \param isInActiveGroup:
|
||||
* \param is_in_active_group:
|
||||
*/
|
||||
void setIsInActiveGroup(bool value)
|
||||
void set_is_in_active_group(bool value)
|
||||
{
|
||||
this->m_inActiveGroup = value;
|
||||
in_active_group_ = value;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,9 +154,9 @@ class Node {
|
||||
* the active group will be the main tree (all nodes that are not part of a group will be active)
|
||||
* \return bool [false:true]
|
||||
*/
|
||||
inline bool isInActiveGroup() const
|
||||
inline bool is_in_active_group() const
|
||||
{
|
||||
return this->m_inActiveGroup;
|
||||
return in_active_group_;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -170,16 +167,16 @@ class Node {
|
||||
* \param system: the ExecutionSystem where the operations need to be added
|
||||
* \param context: reference to the CompositorContext
|
||||
*/
|
||||
virtual void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const = 0;
|
||||
virtual void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const = 0;
|
||||
|
||||
void setInstanceKey(bNodeInstanceKey instance_key)
|
||||
void set_instance_key(bNodeInstanceKey instance_key)
|
||||
{
|
||||
m_instanceKey = instance_key;
|
||||
instance_key_ = instance_key;
|
||||
}
|
||||
bNodeInstanceKey getInstanceKey() const
|
||||
bNodeInstanceKey get_instance_key() const
|
||||
{
|
||||
return m_instanceKey;
|
||||
return instance_key_;
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -188,19 +185,19 @@ class Node {
|
||||
* \note may only be called in an constructor
|
||||
* \param socket: the NodeInput to add
|
||||
*/
|
||||
void addInputSocket(DataType datatype);
|
||||
void addInputSocket(DataType datatype, bNodeSocket *socket);
|
||||
void add_input_socket(DataType datatype);
|
||||
void add_input_socket(DataType datatype, bNodeSocket *socket);
|
||||
|
||||
/**
|
||||
* \brief add an NodeOutput to the collection of output-sockets
|
||||
* \note may only be called in an constructor
|
||||
* \param socket: the NodeOutput to add
|
||||
*/
|
||||
void addOutputSocket(DataType datatype);
|
||||
void addOutputSocket(DataType datatype, bNodeSocket *socket);
|
||||
void add_output_socket(DataType datatype);
|
||||
void add_output_socket(DataType datatype, bNodeSocket *socket);
|
||||
|
||||
bNodeSocket *getEditorInputSocket(int editorNodeInputSocketIndex);
|
||||
bNodeSocket *getEditorOutputSocket(int editorNodeOutputSocketIndex);
|
||||
bNodeSocket *get_editor_input_socket(int editor_node_input_socket_index);
|
||||
bNodeSocket *get_editor_output_socket(int editor_node_output_socket_index);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -209,46 +206,46 @@ class Node {
|
||||
*/
|
||||
class NodeInput {
|
||||
private:
|
||||
Node *m_node;
|
||||
bNodeSocket *m_editorSocket;
|
||||
Node *node_;
|
||||
bNodeSocket *editor_socket_;
|
||||
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
/**
|
||||
* \brief link connected to this NodeInput.
|
||||
* An input socket can only have a single link
|
||||
*/
|
||||
NodeOutput *m_link;
|
||||
NodeOutput *link_;
|
||||
|
||||
public:
|
||||
NodeInput(Node *node, bNodeSocket *b_socket, DataType datatype);
|
||||
|
||||
Node *getNode() const
|
||||
Node *get_node() const
|
||||
{
|
||||
return this->m_node;
|
||||
return node_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
DataType get_data_type() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
bNodeSocket *getbNodeSocket() const
|
||||
bNodeSocket *get_bnode_socket() const
|
||||
{
|
||||
return this->m_editorSocket;
|
||||
return editor_socket_;
|
||||
}
|
||||
|
||||
void setLink(NodeOutput *link);
|
||||
bool isLinked() const
|
||||
void set_link(NodeOutput *link);
|
||||
bool is_linked() const
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
NodeOutput *getLink()
|
||||
NodeOutput *get_link()
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
|
||||
float getEditorValueFloat() const;
|
||||
void getEditorValueColor(float *value) const;
|
||||
void getEditorValueVector(float *value) const;
|
||||
float get_editor_value_float() const;
|
||||
void get_editor_value_color(float *value) const;
|
||||
void get_editor_value_vector(float *value) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -257,30 +254,30 @@ class NodeInput {
|
||||
*/
|
||||
class NodeOutput {
|
||||
private:
|
||||
Node *m_node;
|
||||
bNodeSocket *m_editorSocket;
|
||||
Node *node_;
|
||||
bNodeSocket *editor_socket_;
|
||||
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
public:
|
||||
NodeOutput(Node *node, bNodeSocket *b_socket, DataType datatype);
|
||||
|
||||
Node *getNode() const
|
||||
Node *get_node() const
|
||||
{
|
||||
return this->m_node;
|
||||
return node_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
DataType get_data_type() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
bNodeSocket *getbNodeSocket() const
|
||||
bNodeSocket *get_bnode_socket() const
|
||||
{
|
||||
return this->m_editorSocket;
|
||||
return editor_socket_;
|
||||
}
|
||||
|
||||
float getEditorValueFloat();
|
||||
void getEditorValueColor(float *value);
|
||||
void getEditorValueVector(float *value);
|
||||
float get_editor_value_float();
|
||||
void get_editor_value_color(float *value);
|
||||
void get_editor_value_vector(float *value);
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,9 +18,7 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "COM_Debug.h"
|
||||
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_Node.h"
|
||||
#include "COM_NodeOperationBuilder.h"
|
||||
#include "COM_SetColorOperation.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
@@ -31,136 +29,137 @@
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
NodeConverter::NodeConverter(NodeOperationBuilder *builder) : m_builder(builder)
|
||||
NodeConverter::NodeConverter(NodeOperationBuilder *builder) : builder_(builder)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeConverter::addOperation(NodeOperation *operation)
|
||||
void NodeConverter::add_operation(NodeOperation *operation)
|
||||
{
|
||||
m_builder->addOperation(operation);
|
||||
builder_->add_operation(operation);
|
||||
}
|
||||
|
||||
void NodeConverter::mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket)
|
||||
void NodeConverter::map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
|
||||
{
|
||||
m_builder->mapInputSocket(node_socket, operation_socket);
|
||||
builder_->map_input_socket(node_socket, operation_socket);
|
||||
}
|
||||
|
||||
void NodeConverter::mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
|
||||
void NodeConverter::map_output_socket(NodeOutput *node_socket,
|
||||
NodeOperationOutput *operation_socket)
|
||||
{
|
||||
m_builder->mapOutputSocket(node_socket, operation_socket);
|
||||
builder_->map_output_socket(node_socket, operation_socket);
|
||||
}
|
||||
|
||||
void NodeConverter::addLink(NodeOperationOutput *from, NodeOperationInput *to)
|
||||
void NodeConverter::add_link(NodeOperationOutput *from, NodeOperationInput *to)
|
||||
{
|
||||
m_builder->addLink(from, to);
|
||||
builder_->add_link(from, to);
|
||||
}
|
||||
|
||||
void NodeConverter::addPreview(NodeOperationOutput *output)
|
||||
void NodeConverter::add_preview(NodeOperationOutput *output)
|
||||
{
|
||||
m_builder->addPreview(output);
|
||||
builder_->add_preview(output);
|
||||
}
|
||||
|
||||
void NodeConverter::addNodeInputPreview(NodeInput *input)
|
||||
void NodeConverter::add_node_input_preview(NodeInput *input)
|
||||
{
|
||||
m_builder->addNodeInputPreview(input);
|
||||
builder_->add_node_input_preview(input);
|
||||
}
|
||||
|
||||
NodeOperation *NodeConverter::setInvalidOutput(NodeOutput *output)
|
||||
NodeOperation *NodeConverter::set_invalid_output(NodeOutput *output)
|
||||
{
|
||||
/* this is a really bad situation - bring on the pink! - so artists know this is bad */
|
||||
const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f};
|
||||
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
operation->setChannels(warning_color);
|
||||
operation->set_channels(warning_color);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->add_operation(operation);
|
||||
builder_->map_output_socket(output, operation->get_output_socket());
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
||||
NodeOperationOutput *NodeConverter::addInputProxy(NodeInput *input, bool use_conversion)
|
||||
NodeOperationOutput *NodeConverter::add_input_proxy(NodeInput *input, bool use_conversion)
|
||||
{
|
||||
SocketProxyOperation *proxy = new SocketProxyOperation(input->getDataType(), use_conversion);
|
||||
m_builder->addOperation(proxy);
|
||||
SocketProxyOperation *proxy = new SocketProxyOperation(input->get_data_type(), use_conversion);
|
||||
builder_->add_operation(proxy);
|
||||
|
||||
m_builder->mapInputSocket(input, proxy->getInputSocket(0));
|
||||
builder_->map_input_socket(input, proxy->get_input_socket(0));
|
||||
|
||||
return proxy->getOutputSocket();
|
||||
return proxy->get_output_socket();
|
||||
}
|
||||
|
||||
NodeOperationInput *NodeConverter::addOutputProxy(NodeOutput *output, bool use_conversion)
|
||||
NodeOperationInput *NodeConverter::add_output_proxy(NodeOutput *output, bool use_conversion)
|
||||
{
|
||||
SocketProxyOperation *proxy = new SocketProxyOperation(output->getDataType(), use_conversion);
|
||||
m_builder->addOperation(proxy);
|
||||
SocketProxyOperation *proxy = new SocketProxyOperation(output->get_data_type(), use_conversion);
|
||||
builder_->add_operation(proxy);
|
||||
|
||||
m_builder->mapOutputSocket(output, proxy->getOutputSocket());
|
||||
builder_->map_output_socket(output, proxy->get_output_socket());
|
||||
|
||||
return proxy->getInputSocket(0);
|
||||
return proxy->get_input_socket(0);
|
||||
}
|
||||
|
||||
void NodeConverter::addInputValue(NodeOperationInput *input, float value)
|
||||
void NodeConverter::add_input_value(NodeOperationInput *input, float value)
|
||||
{
|
||||
SetValueOperation *operation = new SetValueOperation();
|
||||
operation->setValue(value);
|
||||
operation->set_value(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->addLink(operation->getOutputSocket(), input);
|
||||
builder_->add_operation(operation);
|
||||
builder_->add_link(operation->get_output_socket(), input);
|
||||
}
|
||||
|
||||
void NodeConverter::addInputColor(NodeOperationInput *input, const float value[4])
|
||||
void NodeConverter::add_input_color(NodeOperationInput *input, const float value[4])
|
||||
{
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
operation->setChannels(value);
|
||||
operation->set_channels(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->addLink(operation->getOutputSocket(), input);
|
||||
builder_->add_operation(operation);
|
||||
builder_->add_link(operation->get_output_socket(), input);
|
||||
}
|
||||
|
||||
void NodeConverter::addInputVector(NodeOperationInput *input, const float value[3])
|
||||
void NodeConverter::add_input_vector(NodeOperationInput *input, const float value[3])
|
||||
{
|
||||
SetVectorOperation *operation = new SetVectorOperation();
|
||||
operation->setVector(value);
|
||||
operation->set_vector(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->addLink(operation->getOutputSocket(), input);
|
||||
builder_->add_operation(operation);
|
||||
builder_->add_link(operation->get_output_socket(), input);
|
||||
}
|
||||
|
||||
void NodeConverter::addOutputValue(NodeOutput *output, float value)
|
||||
void NodeConverter::add_output_value(NodeOutput *output, float value)
|
||||
{
|
||||
SetValueOperation *operation = new SetValueOperation();
|
||||
operation->setValue(value);
|
||||
operation->set_value(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->add_operation(operation);
|
||||
builder_->map_output_socket(output, operation->get_output_socket());
|
||||
}
|
||||
|
||||
void NodeConverter::addOutputColor(NodeOutput *output, const float value[4])
|
||||
void NodeConverter::add_output_color(NodeOutput *output, const float value[4])
|
||||
{
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
operation->setChannels(value);
|
||||
operation->set_channels(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->add_operation(operation);
|
||||
builder_->map_output_socket(output, operation->get_output_socket());
|
||||
}
|
||||
|
||||
void NodeConverter::addOutputVector(NodeOutput *output, const float value[3])
|
||||
void NodeConverter::add_output_vector(NodeOutput *output, const float value[3])
|
||||
{
|
||||
SetVectorOperation *operation = new SetVectorOperation();
|
||||
operation->setVector(value);
|
||||
operation->set_vector(value);
|
||||
|
||||
m_builder->addOperation(operation);
|
||||
m_builder->mapOutputSocket(output, operation->getOutputSocket());
|
||||
builder_->add_operation(operation);
|
||||
builder_->map_output_socket(output, operation->get_output_socket());
|
||||
}
|
||||
|
||||
void NodeConverter::registerViewer(ViewerOperation *viewer)
|
||||
void NodeConverter::register_viewer(ViewerOperation *viewer)
|
||||
{
|
||||
m_builder->registerViewer(viewer);
|
||||
builder_->register_viewer(viewer);
|
||||
}
|
||||
|
||||
ViewerOperation *NodeConverter::active_viewer() const
|
||||
{
|
||||
return m_builder->active_viewer();
|
||||
return builder_->active_viewer();
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -36,7 +36,7 @@ class ViewerOperation;
|
||||
|
||||
/**
|
||||
* Interface type for converting a \a Node into \a NodeOperation.
|
||||
* This is passed to \a Node::convertToOperation methods and allows them
|
||||
* This is passed to \a Node::convert_to_operation methods and allows them
|
||||
* to register any number of operations, create links between them,
|
||||
* and map original node sockets to their inputs or outputs.
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ class NodeConverter {
|
||||
* Insert a new operation into the operations graph.
|
||||
* The operation must be created by the node.
|
||||
*/
|
||||
void addOperation(NodeOperation *operation);
|
||||
void add_operation(NodeOperation *operation);
|
||||
|
||||
/**
|
||||
* Map input socket of the node to an operation socket.
|
||||
@@ -57,7 +57,7 @@ class NodeConverter {
|
||||
*
|
||||
* \note A \a Node input can be mapped to multiple \a NodeOperation inputs.
|
||||
*/
|
||||
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
|
||||
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket);
|
||||
/**
|
||||
* Map output socket of the node to an operation socket.
|
||||
* Links between nodes will then generate equivalent links between
|
||||
@@ -66,57 +66,57 @@ class NodeConverter {
|
||||
* \note A \a Node output can only be mapped to one \a NodeOperation output.
|
||||
* Any existing operation output mapping will be replaced.
|
||||
*/
|
||||
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
|
||||
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
|
||||
|
||||
/**
|
||||
* Create a proxy operation for a node input.
|
||||
* This operation will be removed later and replaced
|
||||
* by direct links between the connected operations.
|
||||
*/
|
||||
NodeOperationOutput *addInputProxy(NodeInput *input, bool use_conversion);
|
||||
NodeOperationOutput *add_input_proxy(NodeInput *input, bool use_conversion);
|
||||
/**
|
||||
* Create a proxy operation for a node output.
|
||||
* This operation will be removed later and replaced
|
||||
* by direct links between the connected operations.
|
||||
*/
|
||||
NodeOperationInput *addOutputProxy(NodeOutput *output, bool use_conversion);
|
||||
NodeOperationInput *add_output_proxy(NodeOutput *output, bool use_conversion);
|
||||
|
||||
/** Define a constant input value. */
|
||||
void addInputValue(NodeOperationInput *input, float value);
|
||||
void add_input_value(NodeOperationInput *input, float value);
|
||||
/** Define a constant input color. */
|
||||
void addInputColor(NodeOperationInput *input, const float value[4]);
|
||||
void add_input_color(NodeOperationInput *input, const float value[4]);
|
||||
/** Define a constant input vector. */
|
||||
void addInputVector(NodeOperationInput *input, const float value[3]);
|
||||
void add_input_vector(NodeOperationInput *input, const float value[3]);
|
||||
|
||||
/** Define a constant output value. */
|
||||
void addOutputValue(NodeOutput *output, float value);
|
||||
void add_output_value(NodeOutput *output, float value);
|
||||
/** Define a constant output color. */
|
||||
void addOutputColor(NodeOutput *output, const float value[4]);
|
||||
void add_output_color(NodeOutput *output, const float value[4]);
|
||||
/** Define a constant output vector. */
|
||||
void addOutputVector(NodeOutput *output, const float value[3]);
|
||||
void add_output_vector(NodeOutput *output, const float value[3]);
|
||||
|
||||
/** Add an explicit link between two operations. */
|
||||
void addLink(NodeOperationOutput *from, NodeOperationInput *to);
|
||||
void add_link(NodeOperationOutput *from, NodeOperationInput *to);
|
||||
|
||||
/** Add a preview operation for a operation output. */
|
||||
void addPreview(NodeOperationOutput *output);
|
||||
void add_preview(NodeOperationOutput *output);
|
||||
/** Add a preview operation for a node input. */
|
||||
void addNodeInputPreview(NodeInput *input);
|
||||
void add_node_input_preview(NodeInput *input);
|
||||
|
||||
/**
|
||||
* When a node has no valid data
|
||||
* \note missing image / group pointer, or missing renderlayer from EXR
|
||||
*/
|
||||
NodeOperation *setInvalidOutput(NodeOutput *output);
|
||||
NodeOperation *set_invalid_output(NodeOutput *output);
|
||||
|
||||
/** Define a viewer operation as the active output, if possible */
|
||||
void registerViewer(ViewerOperation *viewer);
|
||||
void register_viewer(ViewerOperation *viewer);
|
||||
/** The currently active viewer output operation */
|
||||
ViewerOperation *active_viewer() const;
|
||||
|
||||
private:
|
||||
/** The internal builder for storing the results of the graph construction. */
|
||||
NodeOperationBuilder *m_builder;
|
||||
NodeOperationBuilder *builder_;
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
MEM_CXX_CLASS_ALLOC_FUNCS("COM:NodeCompiler")
|
||||
|
@@ -18,17 +18,12 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
#include "BKE_node.h"
|
||||
|
||||
#include "COM_CompositorContext.h"
|
||||
#include "COM_Converter.h"
|
||||
#include "COM_Debug.h"
|
||||
#include "COM_Node.h"
|
||||
#include "COM_SocketProxyNode.h"
|
||||
|
||||
#include "COM_NodeGraph.h" /* own include */
|
||||
@@ -41,8 +36,8 @@ namespace blender::compositor {
|
||||
|
||||
NodeGraph::~NodeGraph()
|
||||
{
|
||||
while (m_nodes.size()) {
|
||||
delete m_nodes.pop_last();
|
||||
while (nodes_.size()) {
|
||||
delete nodes_.pop_last();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,21 +71,21 @@ void NodeGraph::add_node(Node *node,
|
||||
bNodeInstanceKey key,
|
||||
bool is_active_group)
|
||||
{
|
||||
node->setbNodeTree(b_ntree);
|
||||
node->setInstanceKey(key);
|
||||
node->setIsInActiveGroup(is_active_group);
|
||||
node->set_bnodetree(b_ntree);
|
||||
node->set_instance_key(key);
|
||||
node->set_is_in_active_group(is_active_group);
|
||||
|
||||
m_nodes.append(node);
|
||||
nodes_.append(node);
|
||||
|
||||
DebugInfo::node_added(node);
|
||||
}
|
||||
|
||||
void NodeGraph::add_link(NodeOutput *fromSocket, NodeInput *toSocket)
|
||||
void NodeGraph::add_link(NodeOutput *from_socket, NodeInput *to_socket)
|
||||
{
|
||||
m_links.append(Link(fromSocket, toSocket));
|
||||
links_.append(Link(from_socket, to_socket));
|
||||
|
||||
/* register with the input */
|
||||
toSocket->setLink(fromSocket);
|
||||
to_socket->set_link(from_socket);
|
||||
}
|
||||
|
||||
void NodeGraph::add_bNodeTree(const CompositorContext &context,
|
||||
@@ -98,7 +93,7 @@ void NodeGraph::add_bNodeTree(const CompositorContext &context,
|
||||
bNodeTree *tree,
|
||||
bNodeInstanceKey parent_key)
|
||||
{
|
||||
const bNodeTree *basetree = context.getbNodeTree();
|
||||
const bNodeTree *basetree = context.get_bnodetree();
|
||||
|
||||
/* Update viewers in the active edit-tree as well the base tree (for backdrop). */
|
||||
bool is_active_group = (parent_key.value == basetree->active_viewer_key.value);
|
||||
@@ -109,7 +104,7 @@ void NodeGraph::add_bNodeTree(const CompositorContext &context,
|
||||
add_bNode(context, tree, node, key, is_active_group);
|
||||
}
|
||||
|
||||
NodeRange node_range(m_nodes.begin() + nodes_start, m_nodes.end());
|
||||
NodeRange node_range(nodes_.begin() + nodes_start, nodes_.end());
|
||||
/* Add all node-links of the tree to the link list. */
|
||||
for (bNodeLink *nodelink = (bNodeLink *)tree->links.first; nodelink; nodelink = nodelink->next) {
|
||||
add_bNodeLink(node_range, nodelink);
|
||||
@@ -129,7 +124,7 @@ void NodeGraph::add_bNode(const CompositorContext &context,
|
||||
}
|
||||
|
||||
/* replace slow nodes with proxies for fast execution */
|
||||
if (context.isFastCalculation() && !COM_bnode_is_fast_node(*b_node)) {
|
||||
if (context.is_fast_calculation() && !COM_bnode_is_fast_node(*b_node)) {
|
||||
add_proxies_skip(b_ntree, b_node, key, is_active_group);
|
||||
return;
|
||||
}
|
||||
@@ -154,8 +149,8 @@ NodeOutput *NodeGraph::find_output(const NodeRange &node_range, bNodeSocket *b_s
|
||||
{
|
||||
for (Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
|
||||
Node *node = *it;
|
||||
for (NodeOutput *output : node->getOutputSockets()) {
|
||||
if (output->getbNodeSocket() == b_socket) {
|
||||
for (NodeOutput *output : node->get_output_sockets()) {
|
||||
if (output->get_bnode_socket() == b_socket) {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
@@ -185,8 +180,8 @@ void NodeGraph::add_bNodeLink(const NodeRange &node_range, bNodeLink *b_nodelink
|
||||
|
||||
for (Vector<Node *>::iterator it = node_range.first; it != node_range.second; ++it) {
|
||||
Node *node = *it;
|
||||
for (NodeInput *input : node->getInputSockets()) {
|
||||
if (input->getbNodeSocket() == b_nodelink->tosock && !input->isLinked()) {
|
||||
for (NodeInput *input : node->get_input_sockets()) {
|
||||
if (input->get_bnode_socket() == b_nodelink->tosock && !input->is_linked()) {
|
||||
add_link(output, input);
|
||||
}
|
||||
}
|
||||
@@ -263,7 +258,7 @@ void NodeGraph::add_proxies_group_outputs(const CompositorContext &context,
|
||||
b_sock_io = b_sock_io->next) {
|
||||
bNodeSocket *b_sock_group = find_b_node_output(b_node, b_sock_io->identifier);
|
||||
if (b_sock_group) {
|
||||
if (context.isGroupnodeBufferEnabled() &&
|
||||
if (context.is_groupnode_buffer_enabled() &&
|
||||
context.get_execution_model() == eExecutionModel::Tiled) {
|
||||
SocketBufferNode *buffer = new SocketBufferNode(b_node_io, b_sock_io, b_sock_group);
|
||||
add_node(buffer, b_group_tree, key, is_active_group);
|
||||
@@ -284,13 +279,13 @@ void NodeGraph::add_proxies_group(const CompositorContext &context,
|
||||
|
||||
/* missing node group datablock can happen with library linking */
|
||||
if (!b_group_tree) {
|
||||
/* This error case its handled in convertToOperations()
|
||||
/* This error case its handled in convert_to_operations()
|
||||
* so we don't get un-converted sockets. */
|
||||
return;
|
||||
}
|
||||
|
||||
/* use node list size before adding proxies, so they can be connected in add_bNodeTree */
|
||||
int nodes_start = m_nodes.size();
|
||||
int nodes_start = nodes_.size();
|
||||
|
||||
/* create proxy nodes for group input/output nodes */
|
||||
for (bNode *b_node_io = (bNode *)b_group_tree->nodes.first; b_node_io;
|
||||
|
@@ -18,11 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
@@ -52,19 +47,19 @@ class NodeGraph {
|
||||
};
|
||||
|
||||
private:
|
||||
Vector<Node *> m_nodes;
|
||||
Vector<Link> m_links;
|
||||
Vector<Node *> nodes_;
|
||||
Vector<Link> links_;
|
||||
|
||||
public:
|
||||
~NodeGraph();
|
||||
|
||||
const Vector<Node *> &nodes() const
|
||||
{
|
||||
return m_nodes;
|
||||
return nodes_;
|
||||
}
|
||||
const Vector<Link> &links() const
|
||||
{
|
||||
return m_links;
|
||||
return links_;
|
||||
}
|
||||
|
||||
void from_bNodeTree(const CompositorContext &context, bNodeTree *tree);
|
||||
@@ -76,7 +71,7 @@ class NodeGraph {
|
||||
static bNodeSocket *find_b_node_output(bNode *b_node, const char *identifier);
|
||||
|
||||
void add_node(Node *node, bNodeTree *b_ntree, bNodeInstanceKey key, bool is_active_group);
|
||||
void add_link(NodeOutput *fromSocket, NodeInput *toSocket);
|
||||
void add_link(NodeOutput *from_socket, NodeInput *to_socket);
|
||||
|
||||
void add_bNodeTree(const CompositorContext &context,
|
||||
int nodes_start,
|
||||
|
@@ -17,13 +17,10 @@
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <typeinfo>
|
||||
|
||||
#include "COM_BufferOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
#include "COM_defines.h"
|
||||
|
||||
#include "COM_NodeOperation.h" /* own include */
|
||||
|
||||
@@ -37,20 +34,20 @@ NodeOperation::NodeOperation()
|
||||
{
|
||||
canvas_input_index_ = 0;
|
||||
canvas_ = COM_AREA_NONE;
|
||||
this->m_btree = nullptr;
|
||||
btree_ = nullptr;
|
||||
}
|
||||
|
||||
/** Get constant value when operation is constant, otherwise return default_value. */
|
||||
float NodeOperation::get_constant_value_default(float default_value)
|
||||
{
|
||||
BLI_assert(m_outputs.size() > 0 && getOutputSocket()->getDataType() == DataType::Value);
|
||||
BLI_assert(outputs_.size() > 0 && get_output_socket()->get_data_type() == DataType::Value);
|
||||
return *get_constant_elem_default(&default_value);
|
||||
}
|
||||
|
||||
/** Get constant elem when operation is constant, otherwise return default_elem. */
|
||||
const float *NodeOperation::get_constant_elem_default(const float *default_elem)
|
||||
{
|
||||
BLI_assert(m_outputs.size() > 0);
|
||||
BLI_assert(outputs_.size() > 0);
|
||||
if (get_flags().is_constant_operation) {
|
||||
return static_cast<ConstantOperation *>(this)->get_constant_elem();
|
||||
}
|
||||
@@ -75,25 +72,25 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
|
||||
}
|
||||
|
||||
hash_params(canvas_.ymin, canvas_.ymax);
|
||||
if (m_outputs.size() > 0) {
|
||||
BLI_assert(m_outputs.size() == 1);
|
||||
hash_param(this->getOutputSocket()->getDataType());
|
||||
if (outputs_.size() > 0) {
|
||||
BLI_assert(outputs_.size() == 1);
|
||||
hash_param(this->get_output_socket()->get_data_type());
|
||||
}
|
||||
NodeOperationHash hash;
|
||||
hash.params_hash_ = params_hash_;
|
||||
|
||||
hash.parents_hash_ = 0;
|
||||
for (NodeOperationInput &socket : m_inputs) {
|
||||
if (!socket.isConnected()) {
|
||||
for (NodeOperationInput &socket : inputs_) {
|
||||
if (!socket.is_connected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
NodeOperation &input = socket.getLink()->getOperation();
|
||||
NodeOperation &input = socket.get_link()->get_operation();
|
||||
const bool is_constant = input.get_flags().is_constant_operation;
|
||||
combine_hashes(hash.parents_hash_, get_default_hash(is_constant));
|
||||
if (is_constant) {
|
||||
const float *elem = ((ConstantOperation *)&input)->get_constant_elem();
|
||||
const int num_channels = COM_data_type_num_channels(socket.getDataType());
|
||||
const int num_channels = COM_data_type_num_channels(socket.get_data_type());
|
||||
for (const int i : IndexRange(num_channels)) {
|
||||
combine_hashes(hash.parents_hash_, get_default_hash(elem[i]));
|
||||
}
|
||||
@@ -109,31 +106,31 @@ std::optional<NodeOperationHash> NodeOperation::generate_hash()
|
||||
return hash;
|
||||
}
|
||||
|
||||
NodeOperationOutput *NodeOperation::getOutputSocket(unsigned int index)
|
||||
NodeOperationOutput *NodeOperation::get_output_socket(unsigned int index)
|
||||
{
|
||||
return &m_outputs[index];
|
||||
return &outputs_[index];
|
||||
}
|
||||
|
||||
NodeOperationInput *NodeOperation::getInputSocket(unsigned int index)
|
||||
NodeOperationInput *NodeOperation::get_input_socket(unsigned int index)
|
||||
{
|
||||
return &m_inputs[index];
|
||||
return &inputs_[index];
|
||||
}
|
||||
|
||||
void NodeOperation::addInputSocket(DataType datatype, ResizeMode resize_mode)
|
||||
void NodeOperation::add_input_socket(DataType datatype, ResizeMode resize_mode)
|
||||
{
|
||||
m_inputs.append(NodeOperationInput(this, datatype, resize_mode));
|
||||
inputs_.append(NodeOperationInput(this, datatype, resize_mode));
|
||||
}
|
||||
|
||||
void NodeOperation::addOutputSocket(DataType datatype)
|
||||
void NodeOperation::add_output_socket(DataType datatype)
|
||||
{
|
||||
m_outputs.append(NodeOperationOutput(this, datatype));
|
||||
outputs_.append(NodeOperationOutput(this, datatype));
|
||||
}
|
||||
|
||||
void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
unsigned int used_canvas_index = 0;
|
||||
if (canvas_input_index_ == RESOLUTION_INPUT_ANY) {
|
||||
for (NodeOperationInput &input : m_inputs) {
|
||||
for (NodeOperationInput &input : inputs_) {
|
||||
rcti any_area = COM_AREA_NONE;
|
||||
const bool determined = input.determine_canvas(preferred_area, any_area);
|
||||
if (determined) {
|
||||
@@ -143,8 +140,8 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
used_canvas_index += 1;
|
||||
}
|
||||
}
|
||||
else if (canvas_input_index_ < m_inputs.size()) {
|
||||
NodeOperationInput &input = m_inputs[canvas_input_index_];
|
||||
else if (canvas_input_index_ < inputs_.size()) {
|
||||
NodeOperationInput &input = inputs_[canvas_input_index_];
|
||||
input.determine_canvas(preferred_area, r_area);
|
||||
used_canvas_index = canvas_input_index_;
|
||||
}
|
||||
@@ -155,12 +152,12 @@ void NodeOperation::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
|
||||
rcti unused_area;
|
||||
const rcti &local_preferred_area = r_area;
|
||||
for (unsigned int index = 0; index < m_inputs.size(); index++) {
|
||||
for (unsigned int index = 0; index < inputs_.size(); index++) {
|
||||
if (index == used_canvas_index) {
|
||||
continue;
|
||||
}
|
||||
NodeOperationInput &input = m_inputs[index];
|
||||
if (input.isConnected()) {
|
||||
NodeOperationInput &input = inputs_[index];
|
||||
if (input.is_connected()) {
|
||||
input.determine_canvas(local_preferred_area, unused_area);
|
||||
}
|
||||
}
|
||||
@@ -175,32 +172,32 @@ void NodeOperation::init_data()
|
||||
{
|
||||
/* Pass. */
|
||||
}
|
||||
void NodeOperation::initExecution()
|
||||
void NodeOperation::init_execution()
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void NodeOperation::initMutex()
|
||||
void NodeOperation::init_mutex()
|
||||
{
|
||||
BLI_mutex_init(&this->m_mutex);
|
||||
BLI_mutex_init(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::lockMutex()
|
||||
void NodeOperation::lock_mutex()
|
||||
{
|
||||
BLI_mutex_lock(&this->m_mutex);
|
||||
BLI_mutex_lock(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::unlockMutex()
|
||||
void NodeOperation::unlock_mutex()
|
||||
{
|
||||
BLI_mutex_unlock(&this->m_mutex);
|
||||
BLI_mutex_unlock(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::deinitMutex()
|
||||
void NodeOperation::deinit_mutex()
|
||||
{
|
||||
BLI_mutex_end(&this->m_mutex);
|
||||
BLI_mutex_end(&mutex_);
|
||||
}
|
||||
|
||||
void NodeOperation::deinitExecution()
|
||||
void NodeOperation::deinit_execution()
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
@@ -222,52 +219,52 @@ const rcti &NodeOperation::get_canvas() const
|
||||
*/
|
||||
void NodeOperation::unset_canvas()
|
||||
{
|
||||
BLI_assert(m_inputs.size() == 0);
|
||||
BLI_assert(inputs_.size() == 0);
|
||||
flags.is_canvas_set = false;
|
||||
}
|
||||
|
||||
SocketReader *NodeOperation::getInputSocketReader(unsigned int inputSocketIndex)
|
||||
SocketReader *NodeOperation::get_input_socket_reader(unsigned int index)
|
||||
{
|
||||
return this->getInputSocket(inputSocketIndex)->getReader();
|
||||
return this->get_input_socket(index)->get_reader();
|
||||
}
|
||||
|
||||
NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex)
|
||||
NodeOperation *NodeOperation::get_input_operation(int index)
|
||||
{
|
||||
NodeOperationInput *input = getInputSocket(inputSocketIndex);
|
||||
if (input && input->isConnected()) {
|
||||
return &input->getLink()->getOperation();
|
||||
NodeOperationInput *input = get_input_socket(index);
|
||||
if (input && input->is_connected()) {
|
||||
return &input->get_link()->get_operation();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool NodeOperation::determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output)
|
||||
bool NodeOperation::determine_depending_area_of_interest(rcti *input,
|
||||
ReadBufferOperation *read_operation,
|
||||
rcti *output)
|
||||
{
|
||||
if (m_inputs.size() == 0) {
|
||||
if (inputs_.size() == 0) {
|
||||
BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax);
|
||||
return false;
|
||||
}
|
||||
|
||||
rcti tempOutput;
|
||||
rcti temp_output;
|
||||
bool first = true;
|
||||
for (int i = 0; i < getNumberOfInputSockets(); i++) {
|
||||
NodeOperation *inputOperation = this->getInputOperation(i);
|
||||
if (inputOperation &&
|
||||
inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) {
|
||||
for (int i = 0; i < get_number_of_input_sockets(); i++) {
|
||||
NodeOperation *input_operation = this->get_input_operation(i);
|
||||
if (input_operation && input_operation->determine_depending_area_of_interest(
|
||||
input, read_operation, &temp_output)) {
|
||||
if (first) {
|
||||
output->xmin = tempOutput.xmin;
|
||||
output->ymin = tempOutput.ymin;
|
||||
output->xmax = tempOutput.xmax;
|
||||
output->ymax = tempOutput.ymax;
|
||||
output->xmin = temp_output.xmin;
|
||||
output->ymin = temp_output.ymin;
|
||||
output->xmax = temp_output.xmax;
|
||||
output->ymax = temp_output.ymax;
|
||||
first = false;
|
||||
}
|
||||
else {
|
||||
output->xmin = MIN2(output->xmin, tempOutput.xmin);
|
||||
output->ymin = MIN2(output->ymin, tempOutput.ymin);
|
||||
output->xmax = MAX2(output->xmax, tempOutput.xmax);
|
||||
output->ymax = MAX2(output->ymax, tempOutput.ymax);
|
||||
output->xmin = MIN2(output->xmin, temp_output.xmin);
|
||||
output->ymin = MIN2(output->ymin, temp_output.ymin);
|
||||
output->xmax = MAX2(output->xmax, temp_output.xmax);
|
||||
output->ymax = MAX2(output->ymax, temp_output.ymax);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -300,7 +297,7 @@ void NodeOperation::get_area_of_interest(const int input_idx,
|
||||
else {
|
||||
/* Non full-frame operations never implement this method. To ensure correctness assume
|
||||
* whole area is used. */
|
||||
NodeOperation *input_op = getInputOperation(input_idx);
|
||||
NodeOperation *input_op = get_input_operation(input_idx);
|
||||
r_input_area = input_op->get_canvas();
|
||||
}
|
||||
}
|
||||
@@ -309,8 +306,8 @@ void NodeOperation::get_area_of_interest(NodeOperation *input_op,
|
||||
const rcti &output_area,
|
||||
rcti &r_input_area)
|
||||
{
|
||||
for (int i = 0; i < getNumberOfInputSockets(); i++) {
|
||||
if (input_op == getInputOperation(i)) {
|
||||
for (int i = 0; i < get_number_of_input_sockets(); i++) {
|
||||
if (input_op == get_input_operation(i)) {
|
||||
get_area_of_interest(i, output_area, r_input_area);
|
||||
return;
|
||||
}
|
||||
@@ -343,11 +340,11 @@ void NodeOperation::render_full_frame(MemoryBuffer *output_buf,
|
||||
Span<rcti> areas,
|
||||
Span<MemoryBuffer *> inputs_bufs)
|
||||
{
|
||||
initExecution();
|
||||
init_execution();
|
||||
for (const rcti &area : areas) {
|
||||
update_memory_buffer(output_buf, area, inputs_bufs);
|
||||
}
|
||||
deinitExecution();
|
||||
deinit_execution();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,18 +356,18 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf,
|
||||
{
|
||||
Vector<NodeOperationOutput *> orig_input_links = replace_inputs_with_buffers(inputs_bufs);
|
||||
|
||||
initExecution();
|
||||
const bool is_output_operation = getNumberOfOutputSockets() == 0;
|
||||
init_execution();
|
||||
const bool is_output_operation = get_number_of_output_sockets() == 0;
|
||||
if (!is_output_operation && output_buf->is_a_single_elem()) {
|
||||
float *output_elem = output_buf->get_elem(0, 0);
|
||||
readSampled(output_elem, 0, 0, PixelSampler::Nearest);
|
||||
read_sampled(output_elem, 0, 0, PixelSampler::Nearest);
|
||||
}
|
||||
else {
|
||||
for (const rcti &rect : areas) {
|
||||
exec_system_->execute_work(rect, [=](const rcti &split_rect) {
|
||||
rcti tile_rect = split_rect;
|
||||
if (is_output_operation) {
|
||||
executeRegion(&tile_rect, 0);
|
||||
execute_region(&tile_rect, 0);
|
||||
}
|
||||
else {
|
||||
render_tile(output_buf, &tile_rect);
|
||||
@@ -378,7 +375,7 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf,
|
||||
});
|
||||
}
|
||||
}
|
||||
deinitExecution();
|
||||
deinit_execution();
|
||||
|
||||
remove_buffers_and_restore_original_inputs(orig_input_links);
|
||||
}
|
||||
@@ -386,7 +383,7 @@ void NodeOperation::render_full_frame_fallback(MemoryBuffer *output_buf,
|
||||
void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect)
|
||||
{
|
||||
const bool is_complex = get_flags().complex;
|
||||
void *tile_data = is_complex ? initializeTileData(tile_rect) : nullptr;
|
||||
void *tile_data = is_complex ? initialize_tile_data(tile_rect) : nullptr;
|
||||
const int elem_stride = output_buf->elem_stride;
|
||||
for (int y = tile_rect->ymin; y < tile_rect->ymax; y++) {
|
||||
float *output_elem = output_buf->get_elem(tile_rect->xmin, y);
|
||||
@@ -398,13 +395,13 @@ void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect)
|
||||
}
|
||||
else {
|
||||
for (int x = tile_rect->xmin; x < tile_rect->xmax; x++) {
|
||||
readSampled(output_elem, x, y, PixelSampler::Nearest);
|
||||
read_sampled(output_elem, x, y, PixelSampler::Nearest);
|
||||
output_elem += elem_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tile_data) {
|
||||
deinitializeTileData(tile_rect, tile_data);
|
||||
deinitialize_tile_data(tile_rect, tile_data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,14 +411,15 @@ void NodeOperation::render_tile(MemoryBuffer *output_buf, rcti *tile_rect)
|
||||
Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers(
|
||||
Span<MemoryBuffer *> inputs_bufs)
|
||||
{
|
||||
BLI_assert(inputs_bufs.size() == getNumberOfInputSockets());
|
||||
BLI_assert(inputs_bufs.size() == get_number_of_input_sockets());
|
||||
Vector<NodeOperationOutput *> orig_links(inputs_bufs.size());
|
||||
for (int i = 0; i < inputs_bufs.size(); i++) {
|
||||
NodeOperationInput *input_socket = getInputSocket(i);
|
||||
BufferOperation *buffer_op = new BufferOperation(inputs_bufs[i], input_socket->getDataType());
|
||||
orig_links[i] = input_socket->getLink();
|
||||
input_socket->setLink(buffer_op->getOutputSocket());
|
||||
buffer_op->initExecution();
|
||||
NodeOperationInput *input_socket = get_input_socket(i);
|
||||
BufferOperation *buffer_op = new BufferOperation(inputs_bufs[i],
|
||||
input_socket->get_data_type());
|
||||
orig_links[i] = input_socket->get_link();
|
||||
input_socket->set_link(buffer_op->get_output_socket());
|
||||
buffer_op->init_execution();
|
||||
}
|
||||
return orig_links;
|
||||
}
|
||||
@@ -429,14 +427,14 @@ Vector<NodeOperationOutput *> NodeOperation::replace_inputs_with_buffers(
|
||||
void NodeOperation::remove_buffers_and_restore_original_inputs(
|
||||
Span<NodeOperationOutput *> original_inputs_links)
|
||||
{
|
||||
BLI_assert(original_inputs_links.size() == getNumberOfInputSockets());
|
||||
BLI_assert(original_inputs_links.size() == get_number_of_input_sockets());
|
||||
for (int i = 0; i < original_inputs_links.size(); i++) {
|
||||
NodeOperation *buffer_op = get_input_operation(i);
|
||||
BLI_assert(buffer_op != nullptr);
|
||||
BLI_assert(typeid(*buffer_op) == typeid(BufferOperation));
|
||||
buffer_op->deinitExecution();
|
||||
NodeOperationInput *input_socket = getInputSocket(i);
|
||||
input_socket->setLink(original_inputs_links[i]);
|
||||
buffer_op->deinit_execution();
|
||||
NodeOperationInput *input_socket = get_input_socket(i);
|
||||
input_socket->set_link(original_inputs_links[i]);
|
||||
delete buffer_op;
|
||||
}
|
||||
}
|
||||
@@ -447,15 +445,17 @@ void NodeOperation::remove_buffers_and_restore_original_inputs(
|
||||
**** OpInput ****
|
||||
*****************/
|
||||
|
||||
NodeOperationInput::NodeOperationInput(NodeOperation *op, DataType datatype, ResizeMode resizeMode)
|
||||
: m_operation(op), m_datatype(datatype), m_resizeMode(resizeMode), m_link(nullptr)
|
||||
NodeOperationInput::NodeOperationInput(NodeOperation *op,
|
||||
DataType datatype,
|
||||
ResizeMode resize_mode)
|
||||
: operation_(op), datatype_(datatype), resize_mode_(resize_mode), link_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SocketReader *NodeOperationInput::getReader()
|
||||
SocketReader *NodeOperationInput::get_reader()
|
||||
{
|
||||
if (isConnected()) {
|
||||
return &m_link->getOperation();
|
||||
if (is_connected()) {
|
||||
return &link_->get_operation();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@@ -466,8 +466,8 @@ SocketReader *NodeOperationInput::getReader()
|
||||
*/
|
||||
bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
if (m_link) {
|
||||
m_link->determine_canvas(preferred_area, r_area);
|
||||
if (link_) {
|
||||
link_->determine_canvas(preferred_area, r_area);
|
||||
return !BLI_rcti_is_empty(&r_area);
|
||||
}
|
||||
return false;
|
||||
@@ -478,13 +478,13 @@ bool NodeOperationInput::determine_canvas(const rcti &preferred_area, rcti &r_ar
|
||||
******************/
|
||||
|
||||
NodeOperationOutput::NodeOperationOutput(NodeOperation *op, DataType datatype)
|
||||
: m_operation(op), m_datatype(datatype)
|
||||
: operation_(op), datatype_(datatype)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeOperationOutput::determine_canvas(const rcti &preferred_area, rcti &r_area)
|
||||
{
|
||||
NodeOperation &operation = getOperation();
|
||||
NodeOperation &operation = get_operation();
|
||||
if (operation.get_flags().is_canvas_set) {
|
||||
r_area = operation.get_canvas();
|
||||
}
|
||||
@@ -561,9 +561,9 @@ std::ostream &operator<<(std::ostream &os, const NodeOperation &node_operation)
|
||||
os << ",flags={" << flags << "}";
|
||||
if (flags.is_read_buffer_operation) {
|
||||
const ReadBufferOperation *read_operation = (const ReadBufferOperation *)&node_operation;
|
||||
const MemoryProxy *proxy = read_operation->getMemoryProxy();
|
||||
const MemoryProxy *proxy = read_operation->get_memory_proxy();
|
||||
if (proxy) {
|
||||
const WriteBufferOperation *write_operation = proxy->getWriteBufferOperation();
|
||||
const WriteBufferOperation *write_operation = proxy->get_write_buffer_operation();
|
||||
if (write_operation) {
|
||||
os << ",write=" << (NodeOperation &)*write_operation;
|
||||
}
|
||||
|
@@ -18,32 +18,32 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <list>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
#include "BLI_hash.hh"
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_math_vector.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "BLI_span.hh"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "COM_Enums.h"
|
||||
#include "COM_MemoryBuffer.h"
|
||||
#include "COM_MemoryProxy.h"
|
||||
#include "COM_MetaData.h"
|
||||
#include "COM_Node.h"
|
||||
|
||||
#include "clew.h"
|
||||
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class OpenCLDevice;
|
||||
class ReadBufferOperation;
|
||||
class WriteBufferOperation;
|
||||
class ExecutionSystem;
|
||||
|
||||
class NodeOperation;
|
||||
class NodeOperationOutput;
|
||||
|
||||
typedef NodeOperation SocketReader;
|
||||
|
||||
/**
|
||||
@@ -83,56 +83,56 @@ enum class ResizeMode {
|
||||
|
||||
class NodeOperationInput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
NodeOperation *operation_;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
/** Resize mode of this socket */
|
||||
ResizeMode m_resizeMode;
|
||||
ResizeMode resize_mode_;
|
||||
|
||||
/** Connected output */
|
||||
NodeOperationOutput *m_link;
|
||||
NodeOperationOutput *link_;
|
||||
|
||||
public:
|
||||
NodeOperationInput(NodeOperation *op,
|
||||
DataType datatype,
|
||||
ResizeMode resizeMode = ResizeMode::Center);
|
||||
ResizeMode resize_mode = ResizeMode::Center);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
NodeOperation &get_operation() const
|
||||
{
|
||||
return *m_operation;
|
||||
return *operation_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
DataType get_data_type() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
|
||||
void setLink(NodeOperationOutput *link)
|
||||
void set_link(NodeOperationOutput *link)
|
||||
{
|
||||
m_link = link;
|
||||
link_ = link;
|
||||
}
|
||||
NodeOperationOutput *getLink() const
|
||||
NodeOperationOutput *get_link() const
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
bool isConnected() const
|
||||
bool is_connected() const
|
||||
{
|
||||
return m_link;
|
||||
return link_;
|
||||
}
|
||||
|
||||
void setResizeMode(ResizeMode resizeMode)
|
||||
void set_resize_mode(ResizeMode resize_mode)
|
||||
{
|
||||
this->m_resizeMode = resizeMode;
|
||||
resize_mode_ = resize_mode;
|
||||
}
|
||||
ResizeMode getResizeMode() const
|
||||
ResizeMode get_resize_mode() const
|
||||
{
|
||||
return this->m_resizeMode;
|
||||
return resize_mode_;
|
||||
}
|
||||
|
||||
SocketReader *getReader();
|
||||
SocketReader *get_reader();
|
||||
|
||||
bool determine_canvas(const rcti &preferred_area, rcti &r_area);
|
||||
|
||||
@@ -143,23 +143,23 @@ class NodeOperationInput {
|
||||
|
||||
class NodeOperationOutput {
|
||||
private:
|
||||
NodeOperation *m_operation;
|
||||
NodeOperation *operation_;
|
||||
|
||||
/** Datatype of this socket. Is used for automatically data transformation.
|
||||
* \section data-conversion
|
||||
*/
|
||||
DataType m_datatype;
|
||||
DataType datatype_;
|
||||
|
||||
public:
|
||||
NodeOperationOutput(NodeOperation *op, DataType datatype);
|
||||
|
||||
NodeOperation &getOperation() const
|
||||
NodeOperation &get_operation() const
|
||||
{
|
||||
return *m_operation;
|
||||
return *operation_;
|
||||
}
|
||||
DataType getDataType() const
|
||||
DataType get_data_type() const
|
||||
{
|
||||
return m_datatype;
|
||||
return datatype_;
|
||||
}
|
||||
|
||||
void determine_canvas(const rcti &preferred_area, rcti &r_area);
|
||||
@@ -314,10 +314,10 @@ struct NodeOperationHash {
|
||||
*/
|
||||
class NodeOperation {
|
||||
private:
|
||||
int m_id;
|
||||
std::string m_name;
|
||||
Vector<NodeOperationInput> m_inputs;
|
||||
Vector<NodeOperationOutput> m_outputs;
|
||||
int id_;
|
||||
std::string name_;
|
||||
Vector<NodeOperationInput> inputs_;
|
||||
Vector<NodeOperationOutput> outputs_;
|
||||
|
||||
size_t params_hash_;
|
||||
bool is_hash_output_params_implemented_;
|
||||
@@ -334,16 +334,16 @@ class NodeOperation {
|
||||
* \note only use when you really know what you are doing.
|
||||
* this mutex is used to share data among chunks in the same operation
|
||||
* \see TonemapOperation for an example of usage
|
||||
* \see NodeOperation.initMutex initializes this mutex
|
||||
* \see NodeOperation.deinitMutex deinitializes this mutex
|
||||
* \see NodeOperation.getMutex retrieve a pointer to this mutex.
|
||||
* \see NodeOperation.init_mutex initializes this mutex
|
||||
* \see NodeOperation.deinit_mutex deinitializes this mutex
|
||||
* \see NodeOperation.get_mutex retrieve a pointer to this mutex.
|
||||
*/
|
||||
ThreadMutex m_mutex;
|
||||
ThreadMutex mutex_;
|
||||
|
||||
/**
|
||||
* \brief reference to the editing bNodeTree, used for break and update callback
|
||||
*/
|
||||
const bNodeTree *m_btree;
|
||||
const bNodeTree *btree_;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -367,22 +367,22 @@ class NodeOperation {
|
||||
|
||||
void set_name(const std::string name)
|
||||
{
|
||||
m_name = name;
|
||||
name_ = name;
|
||||
}
|
||||
|
||||
const std::string get_name() const
|
||||
{
|
||||
return m_name;
|
||||
return name_;
|
||||
}
|
||||
|
||||
void set_id(const int id)
|
||||
{
|
||||
m_id = id;
|
||||
id_ = id;
|
||||
}
|
||||
|
||||
const int get_id() const
|
||||
{
|
||||
return m_id;
|
||||
return id_;
|
||||
}
|
||||
|
||||
float get_constant_value_default(float default_value);
|
||||
@@ -395,28 +395,23 @@ class NodeOperation {
|
||||
|
||||
std::optional<NodeOperationHash> generate_hash();
|
||||
|
||||
unsigned int getNumberOfInputSockets() const
|
||||
unsigned int get_number_of_input_sockets() const
|
||||
{
|
||||
return m_inputs.size();
|
||||
return inputs_.size();
|
||||
}
|
||||
unsigned int getNumberOfOutputSockets() const
|
||||
unsigned int get_number_of_output_sockets() const
|
||||
{
|
||||
return m_outputs.size();
|
||||
return outputs_.size();
|
||||
}
|
||||
NodeOperationOutput *getOutputSocket(unsigned int index = 0);
|
||||
NodeOperationInput *getInputSocket(unsigned int index);
|
||||
NodeOperationOutput *get_output_socket(unsigned int index = 0);
|
||||
NodeOperationInput *get_input_socket(unsigned int index);
|
||||
|
||||
NodeOperation *get_input_operation(int index)
|
||||
{
|
||||
/* TODO: Rename protected getInputOperation to get_input_operation and make it public replacing
|
||||
* this method. */
|
||||
return getInputOperation(index);
|
||||
}
|
||||
NodeOperation *get_input_operation(int index);
|
||||
|
||||
virtual void determine_canvas(const rcti &preferred_area, rcti &r_area);
|
||||
|
||||
/**
|
||||
* \brief isOutputOperation determines whether this operation is an output of the
|
||||
* \brief is_output_operation determines whether this operation is an output of the
|
||||
* ExecutionSystem during rendering or editing.
|
||||
*
|
||||
* Default behavior if not overridden, this operation will not be evaluated as being an output
|
||||
@@ -430,7 +425,7 @@ class NodeOperation {
|
||||
*
|
||||
* \return bool the result of this method
|
||||
*/
|
||||
virtual bool isOutputOperation(bool /*rendering*/) const
|
||||
virtual bool is_output_operation(bool /*rendering*/) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -440,9 +435,9 @@ class NodeOperation {
|
||||
execution_model_ = model;
|
||||
}
|
||||
|
||||
void setbNodeTree(const bNodeTree *tree)
|
||||
void set_bnodetree(const bNodeTree *tree)
|
||||
{
|
||||
this->m_btree = tree;
|
||||
btree_ = tree;
|
||||
}
|
||||
|
||||
void set_execution_system(ExecutionSystem *system)
|
||||
@@ -452,20 +447,20 @@ class NodeOperation {
|
||||
|
||||
/**
|
||||
* Initializes operation data needed after operations are linked and resolutions determined. For
|
||||
* rendering heap memory data use initExecution().
|
||||
* rendering heap memory data use init_execution().
|
||||
*/
|
||||
virtual void init_data();
|
||||
|
||||
virtual void initExecution();
|
||||
virtual void init_execution();
|
||||
|
||||
/**
|
||||
* \brief when a chunk is executed by a CPUDevice, this method is called
|
||||
* \ingroup execution
|
||||
* \param rect: the rectangle of the chunk (location and size)
|
||||
* \param chunkNumber: the chunkNumber to be calculated
|
||||
* \param memoryBuffers: all input MemoryBuffer's needed
|
||||
* \param chunk_number: the chunk_number to be calculated
|
||||
* \param memory_buffers: all input MemoryBuffer's needed
|
||||
*/
|
||||
virtual void executeRegion(rcti * /*rect*/, unsigned int /*chunkNumber*/)
|
||||
virtual void execute_region(rcti * /*rect*/, unsigned int /*chunk_number*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -477,15 +472,15 @@ class NodeOperation {
|
||||
* \param program: the OpenCL program containing all compositor kernels
|
||||
* \param queue: the OpenCL command queue of the device the chunk is executed on
|
||||
* \param rect: the rectangle of the chunk (location and size)
|
||||
* \param chunkNumber: the chunkNumber to be calculated
|
||||
* \param memoryBuffers: all input MemoryBuffer's needed
|
||||
* \param outputBuffer: the outputbuffer to write to
|
||||
* \param chunk_number: the chunk_number to be calculated
|
||||
* \param memory_buffers: all input MemoryBuffer's needed
|
||||
* \param output_buffer: the outputbuffer to write to
|
||||
*/
|
||||
virtual void executeOpenCLRegion(OpenCLDevice * /*device*/,
|
||||
rcti * /*rect*/,
|
||||
unsigned int /*chunkNumber*/,
|
||||
MemoryBuffer ** /*memoryBuffers*/,
|
||||
MemoryBuffer * /*outputBuffer*/)
|
||||
virtual void execute_opencl_region(OpenCLDevice * /*device*/,
|
||||
rcti * /*rect*/,
|
||||
unsigned int /*chunk_number*/,
|
||||
MemoryBuffer ** /*memory_buffers*/,
|
||||
MemoryBuffer * /*output_buffer*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -496,23 +491,23 @@ class NodeOperation {
|
||||
* \param context: the OpenCL context
|
||||
* \param program: the OpenCL program containing all compositor kernels
|
||||
* \param queue: the OpenCL command queue of the device the chunk is executed on
|
||||
* \param outputMemoryBuffer: the allocated memory buffer in main CPU memory
|
||||
* \param clOutputBuffer: the allocated memory buffer in OpenCLDevice memory
|
||||
* \param inputMemoryBuffers: all input MemoryBuffer's needed
|
||||
* \param clMemToCleanUp: all created cl_mem references must be added to this list.
|
||||
* \param output_memory_buffer: the allocated memory buffer in main CPU memory
|
||||
* \param cl_output_buffer: the allocated memory buffer in OpenCLDevice memory
|
||||
* \param input_memory_buffers: all input MemoryBuffer's needed
|
||||
* \param cl_mem_to_clean_up: all created cl_mem references must be added to this list.
|
||||
* Framework will clean this after execution
|
||||
* \param clKernelsToCleanUp: all created cl_kernel references must be added to this list.
|
||||
* \param cl_kernels_to_clean_up: all created cl_kernel references must be added to this list.
|
||||
* Framework will clean this after execution
|
||||
*/
|
||||
virtual void executeOpenCL(OpenCLDevice * /*device*/,
|
||||
MemoryBuffer * /*outputMemoryBuffer*/,
|
||||
cl_mem /*clOutputBuffer*/,
|
||||
MemoryBuffer ** /*inputMemoryBuffers*/,
|
||||
std::list<cl_mem> * /*clMemToCleanUp*/,
|
||||
std::list<cl_kernel> * /*clKernelsToCleanUp*/)
|
||||
virtual void execute_opencl(OpenCLDevice * /*device*/,
|
||||
MemoryBuffer * /*output_memory_buffer*/,
|
||||
cl_mem /*cl_output_buffer*/,
|
||||
MemoryBuffer ** /*input_memory_buffers*/,
|
||||
std::list<cl_mem> * /*cl_mem_to_clean_up*/,
|
||||
std::list<cl_kernel> * /*cl_kernels_to_clean_up*/)
|
||||
{
|
||||
}
|
||||
virtual void deinitExecution();
|
||||
virtual void deinit_execution();
|
||||
|
||||
void set_canvas(const rcti &canvas_area);
|
||||
const rcti &get_canvas() const;
|
||||
@@ -525,14 +520,14 @@ class NodeOperation {
|
||||
* \return [true:false]
|
||||
* \see BaseViewerOperation
|
||||
*/
|
||||
virtual bool isActiveViewerOutput() const
|
||||
virtual bool is_active_viewer_output() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool determineDependingAreaOfInterest(rcti *input,
|
||||
ReadBufferOperation *readOperation,
|
||||
rcti *output);
|
||||
virtual bool determine_depending_area_of_interest(rcti *input,
|
||||
ReadBufferOperation *read_operation,
|
||||
rcti *output);
|
||||
|
||||
/**
|
||||
* \brief set the index of the input socket that will determine the canvas of this
|
||||
@@ -554,58 +549,58 @@ class NodeOperation {
|
||||
* \note only applicable for output operations like ViewerOperation
|
||||
* \return eCompositorPriority
|
||||
*/
|
||||
virtual eCompositorPriority getRenderPriority() const
|
||||
virtual eCompositorPriority get_render_priority() const
|
||||
{
|
||||
return eCompositorPriority::Low;
|
||||
}
|
||||
|
||||
inline bool isBraked() const
|
||||
inline bool is_braked() const
|
||||
{
|
||||
return this->m_btree->test_break(this->m_btree->tbh);
|
||||
return btree_->test_break(btree_->tbh);
|
||||
}
|
||||
|
||||
inline void updateDraw()
|
||||
inline void update_draw()
|
||||
{
|
||||
if (this->m_btree->update_draw) {
|
||||
this->m_btree->update_draw(this->m_btree->udh);
|
||||
if (btree_->update_draw) {
|
||||
btree_->update_draw(btree_->udh);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int getWidth() const
|
||||
unsigned int get_width() const
|
||||
{
|
||||
return BLI_rcti_size_x(&get_canvas());
|
||||
}
|
||||
|
||||
unsigned int getHeight() const
|
||||
unsigned int get_height() const
|
||||
{
|
||||
return BLI_rcti_size_y(&get_canvas());
|
||||
}
|
||||
|
||||
inline void readSampled(float result[4], float x, float y, PixelSampler sampler)
|
||||
inline void read_sampled(float result[4], float x, float y, PixelSampler sampler)
|
||||
{
|
||||
executePixelSampled(result, x, y, sampler);
|
||||
execute_pixel_sampled(result, x, y, sampler);
|
||||
}
|
||||
|
||||
inline void readFiltered(float result[4], float x, float y, float dx[2], float dy[2])
|
||||
inline void read_filtered(float result[4], float x, float y, float dx[2], float dy[2])
|
||||
{
|
||||
executePixelFiltered(result, x, y, dx, dy);
|
||||
execute_pixel_filtered(result, x, y, dx, dy);
|
||||
}
|
||||
|
||||
inline void read(float result[4], int x, int y, void *chunkData)
|
||||
inline void read(float result[4], int x, int y, void *chunk_data)
|
||||
{
|
||||
executePixel(result, x, y, chunkData);
|
||||
execute_pixel(result, x, y, chunk_data);
|
||||
}
|
||||
|
||||
virtual void *initializeTileData(rcti * /*rect*/)
|
||||
virtual void *initialize_tile_data(rcti * /*rect*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void deinitializeTileData(rcti * /*rect*/, void * /*data*/)
|
||||
virtual void deinitialize_tile_data(rcti * /*rect*/, void * /*data*/)
|
||||
{
|
||||
}
|
||||
|
||||
virtual MemoryBuffer *getInputMemoryBuffer(MemoryBuffer ** /*memoryBuffers*/)
|
||||
virtual MemoryBuffer *get_input_memory_buffer(MemoryBuffer ** /*memory_buffers*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -614,7 +609,7 @@ class NodeOperation {
|
||||
* Return the meta data associated with this branch.
|
||||
*
|
||||
* The return parameter holds an instance or is an nullptr. */
|
||||
virtual std::unique_ptr<MetaData> getMetaData()
|
||||
virtual std::unique_ptr<MetaData> get_meta_data()
|
||||
{
|
||||
return std::unique_ptr<MetaData>();
|
||||
}
|
||||
@@ -672,28 +667,27 @@ class NodeOperation {
|
||||
combine_hashes(params_hash_, get_default_hash_3(param1, param2, param3));
|
||||
}
|
||||
|
||||
void addInputSocket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center);
|
||||
void addOutputSocket(DataType datatype);
|
||||
void add_input_socket(DataType datatype, ResizeMode resize_mode = ResizeMode::Center);
|
||||
void add_output_socket(DataType datatype);
|
||||
|
||||
/* TODO(manzanilla): to be removed with tiled implementation. */
|
||||
void setWidth(unsigned int width)
|
||||
void set_width(unsigned int width)
|
||||
{
|
||||
canvas_.xmax = canvas_.xmin + width;
|
||||
this->flags.is_canvas_set = true;
|
||||
}
|
||||
void setHeight(unsigned int height)
|
||||
void set_height(unsigned int height)
|
||||
{
|
||||
canvas_.ymax = canvas_.ymin + height;
|
||||
this->flags.is_canvas_set = true;
|
||||
}
|
||||
|
||||
SocketReader *getInputSocketReader(unsigned int inputSocketindex);
|
||||
NodeOperation *getInputOperation(unsigned int inputSocketindex);
|
||||
SocketReader *get_input_socket_reader(unsigned int index);
|
||||
|
||||
void deinitMutex();
|
||||
void initMutex();
|
||||
void lockMutex();
|
||||
void unlockMutex();
|
||||
void deinit_mutex();
|
||||
void init_mutex();
|
||||
void lock_mutex();
|
||||
void unlock_mutex();
|
||||
|
||||
/**
|
||||
* \brief set whether this operation is complex
|
||||
@@ -701,7 +695,7 @@ class NodeOperation {
|
||||
* Complex operations are typically doing many reads to calculate the output of a single pixel.
|
||||
* Mostly Filter types (Blurs, Convolution, Defocus etc) need this to be set to true.
|
||||
*/
|
||||
void setComplex(bool complex)
|
||||
void set_complex(bool complex)
|
||||
{
|
||||
this->flags.complex = complex;
|
||||
}
|
||||
@@ -712,12 +706,12 @@ class NodeOperation {
|
||||
* \param result: is a float[4] array to store the result
|
||||
* \param x: the x-coordinate of the pixel to calculate in image space
|
||||
* \param y: the y-coordinate of the pixel to calculate in image space
|
||||
* \param inputBuffers: chunks that can be read by their ReadBufferOperation.
|
||||
* \param input_buffers: chunks that can be read by their ReadBufferOperation.
|
||||
*/
|
||||
virtual void executePixelSampled(float /*output*/[4],
|
||||
float /*x*/,
|
||||
float /*y*/,
|
||||
PixelSampler /*sampler*/)
|
||||
virtual void execute_pixel_sampled(float /*output*/[4],
|
||||
float /*x*/,
|
||||
float /*y*/,
|
||||
PixelSampler /*sampler*/)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -727,12 +721,12 @@ class NodeOperation {
|
||||
* \param result: is a float[4] array to store the result
|
||||
* \param x: the x-coordinate of the pixel to calculate in image space
|
||||
* \param y: the y-coordinate of the pixel to calculate in image space
|
||||
* \param inputBuffers: chunks that can be read by their ReadBufferOperation.
|
||||
* \param chunkData: chunk specific data a during execution time.
|
||||
* \param input_buffers: chunks that can be read by their ReadBufferOperation.
|
||||
* \param chunk_data: chunk specific data a during execution time.
|
||||
*/
|
||||
virtual void executePixel(float output[4], int x, int y, void * /*chunkData*/)
|
||||
virtual void execute_pixel(float output[4], int x, int y, void * /*chunk_data*/)
|
||||
{
|
||||
executePixelSampled(output, x, y, PixelSampler::Nearest);
|
||||
execute_pixel_sampled(output, x, y, PixelSampler::Nearest);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -743,9 +737,9 @@ class NodeOperation {
|
||||
* \param y: the y-coordinate of the pixel to calculate in image space
|
||||
* \param dx:
|
||||
* \param dy:
|
||||
* \param inputBuffers: chunks that can be read by their ReadBufferOperation.
|
||||
* \param input_buffers: chunks that can be read by their ReadBufferOperation.
|
||||
*/
|
||||
virtual void executePixelFiltered(
|
||||
virtual void execute_pixel_filtered(
|
||||
float /*output*/[4], float /*x*/, float /*y*/, float /*dx*/[2], float /*dy*/[2])
|
||||
{
|
||||
}
|
||||
|
@@ -16,24 +16,19 @@
|
||||
* Copyright 2013, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "BLI_multi_value_map.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "COM_Converter.h"
|
||||
#include "COM_Debug.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_Node.h"
|
||||
#include "COM_NodeConverter.h"
|
||||
#include "COM_SocketProxyNode.h"
|
||||
|
||||
#include "COM_NodeOperation.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_PreviewOperation.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
#include "COM_SetColorOperation.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
#include "COM_SetVectorOperation.h"
|
||||
#include "COM_SocketProxyOperation.h"
|
||||
#include "COM_TranslateOperation.h"
|
||||
#include "COM_ViewerOperation.h"
|
||||
#include "COM_WriteBufferOperation.h"
|
||||
|
||||
@@ -45,39 +40,39 @@ namespace blender::compositor {
|
||||
NodeOperationBuilder::NodeOperationBuilder(const CompositorContext *context,
|
||||
bNodeTree *b_nodetree,
|
||||
ExecutionSystem *system)
|
||||
: m_context(context), exec_system_(system), m_current_node(nullptr), m_active_viewer(nullptr)
|
||||
: context_(context), exec_system_(system), current_node_(nullptr), active_viewer_(nullptr)
|
||||
{
|
||||
m_graph.from_bNodeTree(*context, b_nodetree);
|
||||
graph_.from_bNodeTree(*context, b_nodetree);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
void NodeOperationBuilder::convert_to_operations(ExecutionSystem *system)
|
||||
{
|
||||
/* interface handle for nodes */
|
||||
NodeConverter converter(this);
|
||||
|
||||
for (Node *node : m_graph.nodes()) {
|
||||
m_current_node = node;
|
||||
for (Node *node : graph_.nodes()) {
|
||||
current_node_ = node;
|
||||
|
||||
DebugInfo::node_to_operations(node);
|
||||
node->convertToOperations(converter, *m_context);
|
||||
node->convert_to_operations(converter, *context_);
|
||||
}
|
||||
|
||||
m_current_node = nullptr;
|
||||
current_node_ = nullptr;
|
||||
|
||||
/* The input map constructed by nodes maps operation inputs to node inputs.
|
||||
* Inverting yields a map of node inputs to all connected operation inputs,
|
||||
* so multiple operations can use the same node input.
|
||||
*/
|
||||
blender::MultiValueMap<NodeInput *, NodeOperationInput *> inverse_input_map;
|
||||
for (Map<NodeOperationInput *, NodeInput *>::MutableItem item : m_input_map.items()) {
|
||||
for (Map<NodeOperationInput *, NodeInput *>::MutableItem item : input_map_.items()) {
|
||||
inverse_input_map.add(item.value, item.key);
|
||||
}
|
||||
|
||||
for (const NodeGraph::Link &link : m_graph.links()) {
|
||||
for (const NodeGraph::Link &link : graph_.links()) {
|
||||
NodeOutput *from = link.from;
|
||||
NodeInput *to = link.to;
|
||||
|
||||
NodeOperationOutput *op_from = m_output_map.lookup_default(from, nullptr);
|
||||
NodeOperationOutput *op_from = output_map_.lookup_default(from, nullptr);
|
||||
|
||||
const blender::Span<NodeOperationInput *> op_to_list = inverse_input_map.lookup(to);
|
||||
if (!op_from || op_to_list.is_empty()) {
|
||||
@@ -91,7 +86,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
}
|
||||
|
||||
for (NodeOperationInput *op_to : op_to_list) {
|
||||
addLink(op_from, op_to);
|
||||
add_link(op_from, op_to);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +96,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
|
||||
add_datatype_conversions();
|
||||
|
||||
if (m_context->get_execution_model() == eExecutionModel::FullFrame) {
|
||||
if (context_->get_execution_model() == eExecutionModel::FullFrame) {
|
||||
save_graphviz("compositor_prior_folding");
|
||||
ConstantFolder folder(*this);
|
||||
folder.fold_operations();
|
||||
@@ -112,111 +107,111 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
save_graphviz("compositor_prior_merging");
|
||||
merge_equal_operations();
|
||||
|
||||
if (m_context->get_execution_model() == eExecutionModel::Tiled) {
|
||||
if (context_->get_execution_model() == eExecutionModel::Tiled) {
|
||||
/* surround complex ops with read/write buffer */
|
||||
add_complex_operation_buffers();
|
||||
}
|
||||
|
||||
/* links not available from here on */
|
||||
/* XXX make m_links a local variable to avoid confusion! */
|
||||
m_links.clear();
|
||||
/* XXX make links_ a local variable to avoid confusion! */
|
||||
links_.clear();
|
||||
|
||||
prune_operations();
|
||||
|
||||
/* ensure topological (link-based) order of nodes */
|
||||
/*sort_operations();*/ /* not needed yet */
|
||||
|
||||
if (m_context->get_execution_model() == eExecutionModel::Tiled) {
|
||||
if (context_->get_execution_model() == eExecutionModel::Tiled) {
|
||||
/* create execution groups */
|
||||
group_operations();
|
||||
}
|
||||
|
||||
/* transfer resulting operations to the system */
|
||||
system->set_operations(m_operations, m_groups);
|
||||
system->set_operations(operations_, groups_);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::addOperation(NodeOperation *operation)
|
||||
void NodeOperationBuilder::add_operation(NodeOperation *operation)
|
||||
{
|
||||
operation->set_id(m_operations.size());
|
||||
m_operations.append(operation);
|
||||
if (m_current_node) {
|
||||
operation->set_name(m_current_node->getbNode()->name);
|
||||
operation->set_id(operations_.size());
|
||||
operations_.append(operation);
|
||||
if (current_node_) {
|
||||
operation->set_name(current_node_->get_bnode()->name);
|
||||
}
|
||||
operation->set_execution_model(m_context->get_execution_model());
|
||||
operation->set_execution_model(context_->get_execution_model());
|
||||
operation->set_execution_system(exec_system_);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::replace_operation_with_constant(NodeOperation *operation,
|
||||
ConstantOperation *constant_operation)
|
||||
{
|
||||
BLI_assert(constant_operation->getNumberOfInputSockets() == 0);
|
||||
BLI_assert(constant_operation->get_number_of_input_sockets() == 0);
|
||||
unlink_inputs_and_relink_outputs(operation, constant_operation);
|
||||
addOperation(constant_operation);
|
||||
add_operation(constant_operation);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::unlink_inputs_and_relink_outputs(NodeOperation *unlinked_op,
|
||||
NodeOperation *linked_op)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < m_links.size()) {
|
||||
Link &link = m_links[i];
|
||||
if (&link.to()->getOperation() == unlinked_op) {
|
||||
link.to()->setLink(nullptr);
|
||||
m_links.remove(i);
|
||||
while (i < links_.size()) {
|
||||
Link &link = links_[i];
|
||||
if (&link.to()->get_operation() == unlinked_op) {
|
||||
link.to()->set_link(nullptr);
|
||||
links_.remove(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (&link.from()->getOperation() == unlinked_op) {
|
||||
link.to()->setLink(linked_op->getOutputSocket());
|
||||
m_links[i] = Link(linked_op->getOutputSocket(), link.to());
|
||||
if (&link.from()->get_operation() == unlinked_op) {
|
||||
link.to()->set_link(linked_op->get_output_socket());
|
||||
links_[i] = Link(linked_op->get_output_socket(), link.to());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::mapInputSocket(NodeInput *node_socket,
|
||||
NodeOperationInput *operation_socket)
|
||||
void NodeOperationBuilder::map_input_socket(NodeInput *node_socket,
|
||||
NodeOperationInput *operation_socket)
|
||||
{
|
||||
BLI_assert(m_current_node);
|
||||
BLI_assert(node_socket->getNode() == m_current_node);
|
||||
BLI_assert(current_node_);
|
||||
BLI_assert(node_socket->get_node() == current_node_);
|
||||
|
||||
/* NOTE: this maps operation sockets to node sockets.
|
||||
* for resolving links the map will be inverted first in convertToOperations,
|
||||
* for resolving links the map will be inverted first in convert_to_operations,
|
||||
* to get a list of links for each node input socket.
|
||||
*/
|
||||
m_input_map.add_new(operation_socket, node_socket);
|
||||
input_map_.add_new(operation_socket, node_socket);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::mapOutputSocket(NodeOutput *node_socket,
|
||||
NodeOperationOutput *operation_socket)
|
||||
void NodeOperationBuilder::map_output_socket(NodeOutput *node_socket,
|
||||
NodeOperationOutput *operation_socket)
|
||||
{
|
||||
BLI_assert(m_current_node);
|
||||
BLI_assert(node_socket->getNode() == m_current_node);
|
||||
BLI_assert(current_node_);
|
||||
BLI_assert(node_socket->get_node() == current_node_);
|
||||
|
||||
m_output_map.add_new(node_socket, operation_socket);
|
||||
output_map_.add_new(node_socket, operation_socket);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::addLink(NodeOperationOutput *from, NodeOperationInput *to)
|
||||
void NodeOperationBuilder::add_link(NodeOperationOutput *from, NodeOperationInput *to)
|
||||
{
|
||||
if (to->isConnected()) {
|
||||
if (to->is_connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_links.append(Link(from, to));
|
||||
links_.append(Link(from, to));
|
||||
|
||||
/* register with the input */
|
||||
to->setLink(from);
|
||||
to->set_link(from);
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
|
||||
void NodeOperationBuilder::remove_input_link(NodeOperationInput *to)
|
||||
{
|
||||
int index = 0;
|
||||
for (Link &link : m_links) {
|
||||
for (Link &link : links_) {
|
||||
if (link.to() == to) {
|
||||
/* unregister with the input */
|
||||
to->setLink(nullptr);
|
||||
to->set_link(nullptr);
|
||||
|
||||
m_links.remove(index);
|
||||
links_.remove(index);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
@@ -225,69 +220,69 @@ void NodeOperationBuilder::removeInputLink(NodeOperationInput *to)
|
||||
|
||||
PreviewOperation *NodeOperationBuilder::make_preview_operation() const
|
||||
{
|
||||
BLI_assert(m_current_node);
|
||||
BLI_assert(current_node_);
|
||||
|
||||
if (!(m_current_node->getbNode()->flag & NODE_PREVIEW)) {
|
||||
if (!(current_node_->get_bnode()->flag & NODE_PREVIEW)) {
|
||||
return nullptr;
|
||||
}
|
||||
/* previews only in the active group */
|
||||
if (!m_current_node->isInActiveGroup()) {
|
||||
if (!current_node_->is_in_active_group()) {
|
||||
return nullptr;
|
||||
}
|
||||
/* do not calculate previews of hidden nodes */
|
||||
if (m_current_node->getbNode()->flag & NODE_HIDDEN) {
|
||||
if (current_node_->get_bnode()->flag & NODE_HIDDEN) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bNodeInstanceHash *previews = m_context->getPreviewHash();
|
||||
bNodeInstanceHash *previews = context_->get_preview_hash();
|
||||
if (previews) {
|
||||
PreviewOperation *operation = new PreviewOperation(m_context->getViewSettings(),
|
||||
m_context->getDisplaySettings(),
|
||||
m_current_node->getbNode()->preview_xsize,
|
||||
m_current_node->getbNode()->preview_ysize);
|
||||
operation->setbNodeTree(m_context->getbNodeTree());
|
||||
operation->verifyPreview(previews, m_current_node->getInstanceKey());
|
||||
PreviewOperation *operation = new PreviewOperation(context_->get_view_settings(),
|
||||
context_->get_display_settings(),
|
||||
current_node_->get_bnode()->preview_xsize,
|
||||
current_node_->get_bnode()->preview_ysize);
|
||||
operation->set_bnodetree(context_->get_bnodetree());
|
||||
operation->verify_preview(previews, current_node_->get_instance_key());
|
||||
return operation;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::addPreview(NodeOperationOutput *output)
|
||||
void NodeOperationBuilder::add_preview(NodeOperationOutput *output)
|
||||
{
|
||||
PreviewOperation *operation = make_preview_operation();
|
||||
if (operation) {
|
||||
addOperation(operation);
|
||||
add_operation(operation);
|
||||
|
||||
addLink(output, operation->getInputSocket(0));
|
||||
add_link(output, operation->get_input_socket(0));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::addNodeInputPreview(NodeInput *input)
|
||||
void NodeOperationBuilder::add_node_input_preview(NodeInput *input)
|
||||
{
|
||||
PreviewOperation *operation = make_preview_operation();
|
||||
if (operation) {
|
||||
addOperation(operation);
|
||||
add_operation(operation);
|
||||
|
||||
mapInputSocket(input, operation->getInputSocket(0));
|
||||
map_input_socket(input, operation->get_input_socket(0));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
|
||||
void NodeOperationBuilder::register_viewer(ViewerOperation *viewer)
|
||||
{
|
||||
if (m_active_viewer) {
|
||||
if (m_current_node->isInActiveGroup()) {
|
||||
if (active_viewer_) {
|
||||
if (current_node_->is_in_active_group()) {
|
||||
/* deactivate previous viewer */
|
||||
m_active_viewer->setActive(false);
|
||||
active_viewer_->set_active(false);
|
||||
|
||||
m_active_viewer = viewer;
|
||||
viewer->setActive(true);
|
||||
active_viewer_ = viewer;
|
||||
viewer->set_active(true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (m_current_node->getbNodeTree() == m_context->getbNodeTree()) {
|
||||
m_active_viewer = viewer;
|
||||
viewer->setActive(true);
|
||||
if (current_node_->get_bnodetree() == context_->get_bnodetree()) {
|
||||
active_viewer_ = viewer;
|
||||
viewer->set_active(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,27 +294,27 @@ void NodeOperationBuilder::registerViewer(ViewerOperation *viewer)
|
||||
void NodeOperationBuilder::add_datatype_conversions()
|
||||
{
|
||||
Vector<Link> convert_links;
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
/* proxy operations can skip data type conversion */
|
||||
NodeOperation *from_op = &link.from()->getOperation();
|
||||
NodeOperation *to_op = &link.to()->getOperation();
|
||||
NodeOperation *from_op = &link.from()->get_operation();
|
||||
NodeOperation *to_op = &link.to()->get_operation();
|
||||
if (!(from_op->get_flags().use_datatype_conversion ||
|
||||
to_op->get_flags().use_datatype_conversion)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (link.from()->getDataType() != link.to()->getDataType()) {
|
||||
if (link.from()->get_data_type() != link.to()->get_data_type()) {
|
||||
convert_links.append(link);
|
||||
}
|
||||
}
|
||||
for (const Link &link : convert_links) {
|
||||
NodeOperation *converter = COM_convert_data_type(*link.from(), *link.to());
|
||||
if (converter) {
|
||||
addOperation(converter);
|
||||
add_operation(converter);
|
||||
|
||||
removeInputLink(link.to());
|
||||
addLink(link.from(), converter->getInputSocket(0));
|
||||
addLink(converter->getOutputSocket(0), link.to());
|
||||
remove_input_link(link.to());
|
||||
add_link(link.from(), converter->get_input_socket(0));
|
||||
add_link(converter->get_output_socket(0), link.to());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -327,69 +322,69 @@ void NodeOperationBuilder::add_datatype_conversions()
|
||||
void NodeOperationBuilder::add_operation_input_constants()
|
||||
{
|
||||
/* NOTE: unconnected inputs cached first to avoid modifying
|
||||
* m_operations while iterating over it
|
||||
* operations_ while iterating over it
|
||||
*/
|
||||
Vector<NodeOperationInput *> pending_inputs;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (int k = 0; k < op->getNumberOfInputSockets(); ++k) {
|
||||
NodeOperationInput *input = op->getInputSocket(k);
|
||||
if (!input->isConnected()) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
for (int k = 0; k < op->get_number_of_input_sockets(); ++k) {
|
||||
NodeOperationInput *input = op->get_input_socket(k);
|
||||
if (!input->is_connected()) {
|
||||
pending_inputs.append(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (NodeOperationInput *input : pending_inputs) {
|
||||
add_input_constant_value(input, m_input_map.lookup_default(input, nullptr));
|
||||
add_input_constant_value(input, input_map_.lookup_default(input, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
|
||||
const NodeInput *node_input)
|
||||
{
|
||||
switch (input->getDataType()) {
|
||||
switch (input->get_data_type()) {
|
||||
case DataType::Value: {
|
||||
float value;
|
||||
if (node_input && node_input->getbNodeSocket()) {
|
||||
value = node_input->getEditorValueFloat();
|
||||
if (node_input && node_input->get_bnode_socket()) {
|
||||
value = node_input->get_editor_value_float();
|
||||
}
|
||||
else {
|
||||
value = 0.0f;
|
||||
}
|
||||
|
||||
SetValueOperation *op = new SetValueOperation();
|
||||
op->setValue(value);
|
||||
addOperation(op);
|
||||
addLink(op->getOutputSocket(), input);
|
||||
op->set_value(value);
|
||||
add_operation(op);
|
||||
add_link(op->get_output_socket(), input);
|
||||
break;
|
||||
}
|
||||
case DataType::Color: {
|
||||
float value[4];
|
||||
if (node_input && node_input->getbNodeSocket()) {
|
||||
node_input->getEditorValueColor(value);
|
||||
if (node_input && node_input->get_bnode_socket()) {
|
||||
node_input->get_editor_value_color(value);
|
||||
}
|
||||
else {
|
||||
zero_v4(value);
|
||||
}
|
||||
|
||||
SetColorOperation *op = new SetColorOperation();
|
||||
op->setChannels(value);
|
||||
addOperation(op);
|
||||
addLink(op->getOutputSocket(), input);
|
||||
op->set_channels(value);
|
||||
add_operation(op);
|
||||
add_link(op->get_output_socket(), input);
|
||||
break;
|
||||
}
|
||||
case DataType::Vector: {
|
||||
float value[3];
|
||||
if (node_input && node_input->getbNodeSocket()) {
|
||||
node_input->getEditorValueVector(value);
|
||||
if (node_input && node_input->get_bnode_socket()) {
|
||||
node_input->get_editor_value_vector(value);
|
||||
}
|
||||
else {
|
||||
zero_v3(value);
|
||||
}
|
||||
|
||||
SetVectorOperation *op = new SetVectorOperation();
|
||||
op->setVector(value);
|
||||
addOperation(op);
|
||||
addLink(op->getOutputSocket(), input);
|
||||
op->set_vector(value);
|
||||
add_operation(op);
|
||||
add_link(op->get_output_socket(), input);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -398,10 +393,10 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
|
||||
void NodeOperationBuilder::resolve_proxies()
|
||||
{
|
||||
Vector<Link> proxy_links;
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
/* don't replace links from proxy to proxy, since we may need them for replacing others! */
|
||||
if (link.from()->getOperation().get_flags().is_proxy_operation &&
|
||||
!link.to()->getOperation().get_flags().is_proxy_operation) {
|
||||
if (link.from()->get_operation().get_flags().is_proxy_operation &&
|
||||
!link.to()->get_operation().get_flags().is_proxy_operation) {
|
||||
proxy_links.append(link);
|
||||
}
|
||||
}
|
||||
@@ -411,15 +406,15 @@ void NodeOperationBuilder::resolve_proxies()
|
||||
NodeOperationOutput *from = link.from();
|
||||
do {
|
||||
/* walk upstream bypassing the proxy operation */
|
||||
from = from->getOperation().getInputSocket(0)->getLink();
|
||||
} while (from && from->getOperation().get_flags().is_proxy_operation);
|
||||
from = from->get_operation().get_input_socket(0)->get_link();
|
||||
} while (from && from->get_operation().get_flags().is_proxy_operation);
|
||||
|
||||
removeInputLink(to);
|
||||
remove_input_link(to);
|
||||
/* we may not have a final proxy input link,
|
||||
* in that case it just gets dropped
|
||||
*/
|
||||
if (from) {
|
||||
addLink(from, to);
|
||||
add_link(from, to);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -428,16 +423,18 @@ void NodeOperationBuilder::determine_canvases()
|
||||
{
|
||||
/* Determine all canvas areas of the operations. */
|
||||
const rcti &preferred_area = COM_AREA_NONE;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
if (op->isOutputOperation(m_context->isRendering()) && !op->get_flags().is_preview_operation) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (op->is_output_operation(context_->is_rendering()) &&
|
||||
!op->get_flags().is_preview_operation) {
|
||||
rcti canvas = COM_AREA_NONE;
|
||||
op->determine_canvas(preferred_area, canvas);
|
||||
op->set_canvas(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
for (NodeOperation *op : m_operations) {
|
||||
if (op->isOutputOperation(m_context->isRendering()) && op->get_flags().is_preview_operation) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (op->is_output_operation(context_->is_rendering()) &&
|
||||
op->get_flags().is_preview_operation) {
|
||||
rcti canvas = COM_AREA_NONE;
|
||||
op->determine_canvas(preferred_area, canvas);
|
||||
op->set_canvas(canvas);
|
||||
@@ -447,13 +444,13 @@ void NodeOperationBuilder::determine_canvases()
|
||||
/* Convert operation canvases when needed. */
|
||||
{
|
||||
Vector<Link> convert_links;
|
||||
for (const Link &link : m_links) {
|
||||
if (link.to()->getResizeMode() != ResizeMode::None) {
|
||||
const rcti &from_canvas = link.from()->getOperation().get_canvas();
|
||||
const rcti &to_canvas = link.to()->getOperation().get_canvas();
|
||||
for (const Link &link : links_) {
|
||||
if (link.to()->get_resize_mode() != ResizeMode::None) {
|
||||
const rcti &from_canvas = link.from()->get_operation().get_canvas();
|
||||
const rcti &to_canvas = link.to()->get_operation().get_canvas();
|
||||
|
||||
bool needs_conversion;
|
||||
if (link.to()->getResizeMode() == ResizeMode::Align) {
|
||||
if (link.to()->get_resize_mode() == ResizeMode::Align) {
|
||||
needs_conversion = from_canvas.xmin != to_canvas.xmin ||
|
||||
from_canvas.ymin != to_canvas.ymin;
|
||||
}
|
||||
@@ -490,7 +487,7 @@ void NodeOperationBuilder::merge_equal_operations()
|
||||
bool check_for_next_merge = true;
|
||||
while (check_for_next_merge) {
|
||||
/* Re-generate hashes with any change. */
|
||||
Vector<NodeOperationHash> hashes = generate_hashes(m_operations);
|
||||
Vector<NodeOperationHash> hashes = generate_hashes(operations_);
|
||||
|
||||
/* Make hashes be consecutive when they are equal. */
|
||||
std::sort(hashes.begin(), hashes.end());
|
||||
@@ -512,7 +509,7 @@ void NodeOperationBuilder::merge_equal_operations()
|
||||
void NodeOperationBuilder::merge_equal_operations(NodeOperation *from, NodeOperation *into)
|
||||
{
|
||||
unlink_inputs_and_relink_outputs(from, into);
|
||||
m_operations.remove_first_occurrence_and_reorder(from);
|
||||
operations_.remove_first_occurrence_and_reorder(from);
|
||||
delete from;
|
||||
}
|
||||
|
||||
@@ -520,7 +517,7 @@ Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links(
|
||||
NodeOperationOutput *output) const
|
||||
{
|
||||
Vector<NodeOperationInput *> inputs;
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
if (link.from() == output) {
|
||||
inputs.append(link.to());
|
||||
}
|
||||
@@ -531,9 +528,9 @@ Vector<NodeOperationInput *> NodeOperationBuilder::cache_output_links(
|
||||
WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation(
|
||||
NodeOperationOutput *output) const
|
||||
{
|
||||
for (const Link &link : m_links) {
|
||||
for (const Link &link : links_) {
|
||||
if (link.from() == output) {
|
||||
NodeOperation &op = link.to()->getOperation();
|
||||
NodeOperation &op = link.to()->get_operation();
|
||||
if (op.get_flags().is_write_buffer_operation) {
|
||||
return (WriteBufferOperation *)(&op);
|
||||
}
|
||||
@@ -545,39 +542,39 @@ WriteBufferOperation *NodeOperationBuilder::find_attached_write_buffer_operation
|
||||
void NodeOperationBuilder::add_input_buffers(NodeOperation * /*operation*/,
|
||||
NodeOperationInput *input)
|
||||
{
|
||||
if (!input->isConnected()) {
|
||||
if (!input->is_connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NodeOperationOutput *output = input->getLink();
|
||||
if (output->getOperation().get_flags().is_read_buffer_operation) {
|
||||
NodeOperationOutput *output = input->get_link();
|
||||
if (output->get_operation().get_flags().is_read_buffer_operation) {
|
||||
/* input is already buffered, no need to add another */
|
||||
return;
|
||||
}
|
||||
|
||||
/* this link will be replaced below */
|
||||
removeInputLink(input);
|
||||
remove_input_link(input);
|
||||
|
||||
/* check of other end already has write operation, otherwise add a new one */
|
||||
WriteBufferOperation *writeoperation = find_attached_write_buffer_operation(output);
|
||||
if (!writeoperation) {
|
||||
writeoperation = new WriteBufferOperation(output->getDataType());
|
||||
writeoperation->setbNodeTree(m_context->getbNodeTree());
|
||||
addOperation(writeoperation);
|
||||
writeoperation = new WriteBufferOperation(output->get_data_type());
|
||||
writeoperation->set_bnodetree(context_->get_bnodetree());
|
||||
add_operation(writeoperation);
|
||||
|
||||
addLink(output, writeoperation->getInputSocket(0));
|
||||
add_link(output, writeoperation->get_input_socket(0));
|
||||
|
||||
writeoperation->readResolutionFromInputSocket();
|
||||
writeoperation->read_resolution_from_input_socket();
|
||||
}
|
||||
|
||||
/* add readbuffer op for the input */
|
||||
ReadBufferOperation *readoperation = new ReadBufferOperation(output->getDataType());
|
||||
readoperation->setMemoryProxy(writeoperation->getMemoryProxy());
|
||||
this->addOperation(readoperation);
|
||||
ReadBufferOperation *readoperation = new ReadBufferOperation(output->get_data_type());
|
||||
readoperation->set_memory_proxy(writeoperation->get_memory_proxy());
|
||||
this->add_operation(readoperation);
|
||||
|
||||
addLink(readoperation->getOutputSocket(), input);
|
||||
add_link(readoperation->get_output_socket(), input);
|
||||
|
||||
readoperation->readResolutionFromWriteBuffer();
|
||||
readoperation->read_resolution_from_write_buffer();
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
|
||||
@@ -589,54 +586,54 @@ void NodeOperationBuilder::add_output_buffers(NodeOperation *operation,
|
||||
return;
|
||||
}
|
||||
|
||||
WriteBufferOperation *writeOperation = nullptr;
|
||||
WriteBufferOperation *write_operation = nullptr;
|
||||
for (NodeOperationInput *target : targets) {
|
||||
/* try to find existing write buffer operation */
|
||||
if (target->getOperation().get_flags().is_write_buffer_operation) {
|
||||
BLI_assert(writeOperation == nullptr); /* there should only be one write op connected */
|
||||
writeOperation = (WriteBufferOperation *)(&target->getOperation());
|
||||
if (target->get_operation().get_flags().is_write_buffer_operation) {
|
||||
BLI_assert(write_operation == nullptr); /* there should only be one write op connected */
|
||||
write_operation = (WriteBufferOperation *)(&target->get_operation());
|
||||
}
|
||||
else {
|
||||
/* remove all links to other nodes */
|
||||
removeInputLink(target);
|
||||
remove_input_link(target);
|
||||
}
|
||||
}
|
||||
|
||||
/* if no write buffer operation exists yet, create a new one */
|
||||
if (!writeOperation) {
|
||||
writeOperation = new WriteBufferOperation(operation->getOutputSocket()->getDataType());
|
||||
writeOperation->setbNodeTree(m_context->getbNodeTree());
|
||||
addOperation(writeOperation);
|
||||
if (!write_operation) {
|
||||
write_operation = new WriteBufferOperation(operation->get_output_socket()->get_data_type());
|
||||
write_operation->set_bnodetree(context_->get_bnodetree());
|
||||
add_operation(write_operation);
|
||||
|
||||
addLink(output, writeOperation->getInputSocket(0));
|
||||
add_link(output, write_operation->get_input_socket(0));
|
||||
}
|
||||
|
||||
writeOperation->readResolutionFromInputSocket();
|
||||
write_operation->read_resolution_from_input_socket();
|
||||
|
||||
/* add readbuffer op for every former connected input */
|
||||
for (NodeOperationInput *target : targets) {
|
||||
if (&target->getOperation() == writeOperation) {
|
||||
if (&target->get_operation() == write_operation) {
|
||||
continue; /* skip existing write op links */
|
||||
}
|
||||
|
||||
ReadBufferOperation *readoperation = new ReadBufferOperation(
|
||||
operation->getOutputSocket()->getDataType());
|
||||
readoperation->setMemoryProxy(writeOperation->getMemoryProxy());
|
||||
addOperation(readoperation);
|
||||
operation->get_output_socket()->get_data_type());
|
||||
readoperation->set_memory_proxy(write_operation->get_memory_proxy());
|
||||
add_operation(readoperation);
|
||||
|
||||
addLink(readoperation->getOutputSocket(), target);
|
||||
add_link(readoperation->get_output_socket(), target);
|
||||
|
||||
readoperation->readResolutionFromWriteBuffer();
|
||||
readoperation->read_resolution_from_write_buffer();
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::add_complex_operation_buffers()
|
||||
{
|
||||
/* NOTE: complex ops and get cached here first, since adding operations
|
||||
* will invalidate iterators over the main m_operations
|
||||
* will invalidate iterators over the main operations_
|
||||
*/
|
||||
Vector<NodeOperation *> complex_ops;
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
if (operation->get_flags().complex) {
|
||||
complex_ops.append(operation);
|
||||
}
|
||||
@@ -645,12 +642,12 @@ void NodeOperationBuilder::add_complex_operation_buffers()
|
||||
for (NodeOperation *op : complex_ops) {
|
||||
DebugInfo::operation_read_write_buffer(op);
|
||||
|
||||
for (int index = 0; index < op->getNumberOfInputSockets(); index++) {
|
||||
add_input_buffers(op, op->getInputSocket(index));
|
||||
for (int index = 0; index < op->get_number_of_input_sockets(); index++) {
|
||||
add_input_buffers(op, op->get_input_socket(index));
|
||||
}
|
||||
|
||||
for (int index = 0; index < op->getNumberOfOutputSockets(); index++) {
|
||||
add_output_buffers(op, op->getOutputSocket(index));
|
||||
for (int index = 0; index < op->get_number_of_output_sockets(); index++) {
|
||||
add_output_buffers(op, op->get_output_socket(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -664,34 +661,34 @@ static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *
|
||||
}
|
||||
reachable.insert(op);
|
||||
|
||||
for (int i = 0; i < op->getNumberOfInputSockets(); i++) {
|
||||
NodeOperationInput *input = op->getInputSocket(i);
|
||||
if (input->isConnected()) {
|
||||
find_reachable_operations_recursive(reachable, &input->getLink()->getOperation());
|
||||
for (int i = 0; i < op->get_number_of_input_sockets(); i++) {
|
||||
NodeOperationInput *input = op->get_input_socket(i);
|
||||
if (input->is_connected()) {
|
||||
find_reachable_operations_recursive(reachable, &input->get_link()->get_operation());
|
||||
}
|
||||
}
|
||||
|
||||
/* associated write-buffer operations are executed as well */
|
||||
if (op->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *read_op = (ReadBufferOperation *)op;
|
||||
MemoryProxy *memproxy = read_op->getMemoryProxy();
|
||||
find_reachable_operations_recursive(reachable, memproxy->getWriteBufferOperation());
|
||||
MemoryProxy *memproxy = read_op->get_memory_proxy();
|
||||
find_reachable_operations_recursive(reachable, memproxy->get_write_buffer_operation());
|
||||
}
|
||||
}
|
||||
|
||||
void NodeOperationBuilder::prune_operations()
|
||||
{
|
||||
Tags reachable;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
/* output operations are primary executed operations */
|
||||
if (op->isOutputOperation(m_context->isRendering())) {
|
||||
if (op->is_output_operation(context_->is_rendering())) {
|
||||
find_reachable_operations_recursive(reachable, op);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete unreachable operations */
|
||||
Vector<NodeOperation *> reachable_ops;
|
||||
for (NodeOperation *op : m_operations) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (reachable.find(op) != reachable.end()) {
|
||||
reachable_ops.append(op);
|
||||
}
|
||||
@@ -700,7 +697,7 @@ void NodeOperationBuilder::prune_operations()
|
||||
}
|
||||
}
|
||||
/* finally replace the operations list with the pruned list */
|
||||
m_operations = reachable_ops;
|
||||
operations_ = reachable_ops;
|
||||
}
|
||||
|
||||
/* topological (depth-first) sorting of operations */
|
||||
@@ -713,10 +710,10 @@ static void sort_operations_recursive(Vector<NodeOperation *> &sorted,
|
||||
}
|
||||
visited.insert(op);
|
||||
|
||||
for (int i = 0; i < op->getNumberOfInputSockets(); i++) {
|
||||
NodeOperationInput *input = op->getInputSocket(i);
|
||||
if (input->isConnected()) {
|
||||
sort_operations_recursive(sorted, visited, &input->getLink()->getOperation());
|
||||
for (int i = 0; i < op->get_number_of_input_sockets(); i++) {
|
||||
NodeOperationInput *input = op->get_input_socket(i);
|
||||
if (input->is_connected()) {
|
||||
sort_operations_recursive(sorted, visited, &input->get_link()->get_operation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -726,14 +723,14 @@ static void sort_operations_recursive(Vector<NodeOperation *> &sorted,
|
||||
void NodeOperationBuilder::sort_operations()
|
||||
{
|
||||
Vector<NodeOperation *> sorted;
|
||||
sorted.reserve(m_operations.size());
|
||||
sorted.reserve(operations_.size());
|
||||
Tags visited;
|
||||
|
||||
for (NodeOperation *operation : m_operations) {
|
||||
for (NodeOperation *operation : operations_) {
|
||||
sort_operations_recursive(sorted, visited, operation);
|
||||
}
|
||||
|
||||
m_operations = sorted;
|
||||
operations_ = sorted;
|
||||
}
|
||||
|
||||
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group)
|
||||
@@ -743,23 +740,23 @@ static void add_group_operations_recursive(Tags &visited, NodeOperation *op, Exe
|
||||
}
|
||||
visited.insert(op);
|
||||
|
||||
if (!group->addOperation(op)) {
|
||||
if (!group->add_operation(op)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* add all eligible input ops to the group */
|
||||
for (int i = 0; i < op->getNumberOfInputSockets(); i++) {
|
||||
NodeOperationInput *input = op->getInputSocket(i);
|
||||
if (input->isConnected()) {
|
||||
add_group_operations_recursive(visited, &input->getLink()->getOperation(), group);
|
||||
for (int i = 0; i < op->get_number_of_input_sockets(); i++) {
|
||||
NodeOperationInput *input = op->get_input_socket(i);
|
||||
if (input->is_connected()) {
|
||||
add_group_operations_recursive(visited, &input->get_link()->get_operation(), group);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
|
||||
{
|
||||
ExecutionGroup *group = new ExecutionGroup(this->m_groups.size());
|
||||
m_groups.append(group);
|
||||
ExecutionGroup *group = new ExecutionGroup(groups_.size());
|
||||
groups_.append(group);
|
||||
|
||||
Tags visited;
|
||||
add_group_operations_recursive(visited, op, group);
|
||||
@@ -769,20 +766,20 @@ ExecutionGroup *NodeOperationBuilder::make_group(NodeOperation *op)
|
||||
|
||||
void NodeOperationBuilder::group_operations()
|
||||
{
|
||||
for (NodeOperation *op : m_operations) {
|
||||
if (op->isOutputOperation(m_context->isRendering())) {
|
||||
for (NodeOperation *op : operations_) {
|
||||
if (op->is_output_operation(context_->is_rendering())) {
|
||||
ExecutionGroup *group = make_group(op);
|
||||
group->setOutputExecutionGroup(true);
|
||||
group->set_output_execution_group(true);
|
||||
}
|
||||
|
||||
/* add new groups for associated memory proxies where needed */
|
||||
if (op->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *read_op = (ReadBufferOperation *)op;
|
||||
MemoryProxy *memproxy = read_op->getMemoryProxy();
|
||||
MemoryProxy *memproxy = read_op->get_memory_proxy();
|
||||
|
||||
if (memproxy->getExecutor() == nullptr) {
|
||||
ExecutionGroup *group = make_group(memproxy->getWriteBufferOperation());
|
||||
memproxy->setExecutor(group);
|
||||
if (memproxy->get_executor() == nullptr) {
|
||||
ExecutionGroup *group = make_group(memproxy->get_write_buffer_operation());
|
||||
memproxy->set_executor(group);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -791,7 +788,7 @@ void NodeOperationBuilder::group_operations()
|
||||
void NodeOperationBuilder::save_graphviz(StringRefNull name)
|
||||
{
|
||||
if (COM_EXPORT_GRAPHVIZ) {
|
||||
exec_system_->set_operations(m_operations, m_groups);
|
||||
exec_system_->set_operations(operations_, groups_);
|
||||
DebugInfo::graphviz(exec_system_, name);
|
||||
}
|
||||
}
|
||||
@@ -809,15 +806,15 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder)
|
||||
|
||||
os << "\n";
|
||||
for (const NodeOperationBuilder::Link &link : builder.get_links()) {
|
||||
os << " op" << link.from()->getOperation().get_id() << " -> op"
|
||||
<< link.to()->getOperation().get_id() << ";\n";
|
||||
os << " op" << link.from()->get_operation().get_id() << " -> op"
|
||||
<< link.to()->get_operation().get_id() << ";\n";
|
||||
}
|
||||
for (const NodeOperation *operation : builder.get_operations()) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
const ReadBufferOperation &read_operation = static_cast<const ReadBufferOperation &>(
|
||||
*operation);
|
||||
const WriteBufferOperation &write_operation =
|
||||
*read_operation.getMemoryProxy()->getWriteBufferOperation();
|
||||
*read_operation.get_memory_proxy()->get_write_buffer_operation();
|
||||
os << " op" << write_operation.get_id() << " -> op" << read_operation.get_id() << ";\n";
|
||||
}
|
||||
}
|
||||
@@ -829,7 +826,7 @@ std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder &builder)
|
||||
|
||||
std::ostream &operator<<(std::ostream &os, const NodeOperationBuilder::Link &link)
|
||||
{
|
||||
os << link.from()->getOperation().get_id() << " -> " << link.to()->getOperation().get_id();
|
||||
os << link.from()->get_operation().get_id() << " -> " << link.to()->get_operation().get_id();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
@@ -18,9 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include "COM_NodeGraph.h"
|
||||
|
||||
@@ -47,45 +46,45 @@ class NodeOperationBuilder {
|
||||
public:
|
||||
class Link {
|
||||
private:
|
||||
NodeOperationOutput *m_from;
|
||||
NodeOperationInput *m_to;
|
||||
NodeOperationOutput *from_;
|
||||
NodeOperationInput *to_;
|
||||
|
||||
public:
|
||||
Link(NodeOperationOutput *from, NodeOperationInput *to) : m_from(from), m_to(to)
|
||||
Link(NodeOperationOutput *from, NodeOperationInput *to) : from_(from), to_(to)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOperationOutput *from() const
|
||||
{
|
||||
return m_from;
|
||||
return from_;
|
||||
}
|
||||
NodeOperationInput *to() const
|
||||
{
|
||||
return m_to;
|
||||
return to_;
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
const CompositorContext *m_context;
|
||||
NodeGraph m_graph;
|
||||
const CompositorContext *context_;
|
||||
NodeGraph graph_;
|
||||
ExecutionSystem *exec_system_;
|
||||
|
||||
Vector<NodeOperation *> m_operations;
|
||||
Vector<Link> m_links;
|
||||
Vector<ExecutionGroup *> m_groups;
|
||||
Vector<NodeOperation *> operations_;
|
||||
Vector<Link> links_;
|
||||
Vector<ExecutionGroup *> groups_;
|
||||
|
||||
/** Maps operation inputs to node inputs */
|
||||
Map<NodeOperationInput *, NodeInput *> m_input_map;
|
||||
Map<NodeOperationInput *, NodeInput *> input_map_;
|
||||
/** Maps node outputs to operation outputs */
|
||||
Map<NodeOutput *, NodeOperationOutput *> m_output_map;
|
||||
Map<NodeOutput *, NodeOperationOutput *> output_map_;
|
||||
|
||||
Node *m_current_node;
|
||||
Node *current_node_;
|
||||
|
||||
/** Operation that will be writing to the viewer image
|
||||
* Only one operation can occupy this place at a time,
|
||||
* to avoid race conditions
|
||||
*/
|
||||
ViewerOperation *m_active_viewer;
|
||||
ViewerOperation *active_viewer_;
|
||||
|
||||
public:
|
||||
NodeOperationBuilder(const CompositorContext *context,
|
||||
@@ -94,44 +93,44 @@ class NodeOperationBuilder {
|
||||
|
||||
const CompositorContext &context() const
|
||||
{
|
||||
return *m_context;
|
||||
return *context_;
|
||||
}
|
||||
|
||||
void convertToOperations(ExecutionSystem *system);
|
||||
void convert_to_operations(ExecutionSystem *system);
|
||||
|
||||
void addOperation(NodeOperation *operation);
|
||||
void add_operation(NodeOperation *operation);
|
||||
void replace_operation_with_constant(NodeOperation *operation,
|
||||
ConstantOperation *constant_operation);
|
||||
|
||||
/** Map input socket of the current node to an operation socket */
|
||||
void mapInputSocket(NodeInput *node_socket, NodeOperationInput *operation_socket);
|
||||
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket);
|
||||
/** Map output socket of the current node to an operation socket */
|
||||
void mapOutputSocket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
|
||||
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket);
|
||||
|
||||
void addLink(NodeOperationOutput *from, NodeOperationInput *to);
|
||||
void removeInputLink(NodeOperationInput *to);
|
||||
void add_link(NodeOperationOutput *from, NodeOperationInput *to);
|
||||
void remove_input_link(NodeOperationInput *to);
|
||||
|
||||
/** Add a preview operation for a operation output */
|
||||
void addPreview(NodeOperationOutput *output);
|
||||
void add_preview(NodeOperationOutput *output);
|
||||
/** Add a preview operation for a node input */
|
||||
void addNodeInputPreview(NodeInput *input);
|
||||
void add_node_input_preview(NodeInput *input);
|
||||
|
||||
/** Define a viewer operation as the active output, if possible */
|
||||
void registerViewer(ViewerOperation *viewer);
|
||||
void register_viewer(ViewerOperation *viewer);
|
||||
/** The currently active viewer output operation */
|
||||
ViewerOperation *active_viewer() const
|
||||
{
|
||||
return m_active_viewer;
|
||||
return active_viewer_;
|
||||
}
|
||||
|
||||
const Vector<NodeOperation *> &get_operations() const
|
||||
{
|
||||
return m_operations;
|
||||
return operations_;
|
||||
}
|
||||
|
||||
const Vector<Link> &get_links() const
|
||||
{
|
||||
return m_links;
|
||||
return links_;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -17,7 +17,9 @@
|
||||
*/
|
||||
|
||||
#include "COM_OpenCLDevice.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
@@ -38,68 +40,69 @@ const cl_image_format IMAGE_FORMAT_VALUE = {
|
||||
OpenCLDevice::OpenCLDevice(cl_context context,
|
||||
cl_device_id device,
|
||||
cl_program program,
|
||||
cl_int vendorId)
|
||||
cl_int vendor_id)
|
||||
{
|
||||
this->m_device = device;
|
||||
this->m_context = context;
|
||||
this->m_program = program;
|
||||
this->m_queue = nullptr;
|
||||
this->m_vendorID = vendorId;
|
||||
device_ = device;
|
||||
context_ = context;
|
||||
program_ = program;
|
||||
queue_ = nullptr;
|
||||
vendor_id_ = vendor_id;
|
||||
|
||||
cl_int error;
|
||||
this->m_queue = clCreateCommandQueue(this->m_context, this->m_device, 0, &error);
|
||||
queue_ = clCreateCommandQueue(context_, device_, 0, &error);
|
||||
}
|
||||
|
||||
OpenCLDevice::OpenCLDevice(OpenCLDevice &&other) noexcept
|
||||
: m_context(other.m_context),
|
||||
m_device(other.m_device),
|
||||
m_program(other.m_program),
|
||||
m_queue(other.m_queue),
|
||||
m_vendorID(other.m_vendorID)
|
||||
: context_(other.context_),
|
||||
device_(other.device_),
|
||||
program_(other.program_),
|
||||
queue_(other.queue_),
|
||||
vendor_id_(other.vendor_id_)
|
||||
{
|
||||
other.m_queue = nullptr;
|
||||
other.queue_ = nullptr;
|
||||
}
|
||||
|
||||
OpenCLDevice::~OpenCLDevice()
|
||||
{
|
||||
if (this->m_queue) {
|
||||
clReleaseCommandQueue(this->m_queue);
|
||||
if (queue_) {
|
||||
clReleaseCommandQueue(queue_);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenCLDevice::execute(WorkPackage *work_package)
|
||||
{
|
||||
const unsigned int chunkNumber = work_package->chunk_number;
|
||||
ExecutionGroup *executionGroup = work_package->execution_group;
|
||||
const unsigned int chunk_number = work_package->chunk_number;
|
||||
ExecutionGroup *execution_group = work_package->execution_group;
|
||||
|
||||
MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
|
||||
MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(work_package->rect);
|
||||
MemoryBuffer **input_buffers = execution_group->get_input_buffers_opencl(chunk_number);
|
||||
MemoryBuffer *output_buffer = execution_group->allocate_output_buffer(work_package->rect);
|
||||
|
||||
executionGroup->getOutputOperation()->executeOpenCLRegion(
|
||||
this, &work_package->rect, chunkNumber, inputBuffers, outputBuffer);
|
||||
execution_group->get_output_operation()->execute_opencl_region(
|
||||
this, &work_package->rect, chunk_number, input_buffers, output_buffer);
|
||||
|
||||
delete outputBuffer;
|
||||
delete output_buffer;
|
||||
|
||||
executionGroup->finalizeChunkExecution(chunkNumber, inputBuffers);
|
||||
execution_group->finalize_chunk_execution(chunk_number, input_buffers);
|
||||
}
|
||||
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
int parameterIndex,
|
||||
int offsetIndex,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **inputMemoryBuffers,
|
||||
SocketReader *reader)
|
||||
cl_mem OpenCLDevice::COM_cl_attach_memory_buffer_to_kernel_parameter(
|
||||
cl_kernel kernel,
|
||||
int parameter_index,
|
||||
int offset_index,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **input_memory_buffers,
|
||||
SocketReader *reader)
|
||||
{
|
||||
return COM_clAttachMemoryBufferToKernelParameter(kernel,
|
||||
parameterIndex,
|
||||
offsetIndex,
|
||||
cleanup,
|
||||
inputMemoryBuffers,
|
||||
(ReadBufferOperation *)reader);
|
||||
return COM_cl_attach_memory_buffer_to_kernel_parameter(kernel,
|
||||
parameter_index,
|
||||
offset_index,
|
||||
cleanup,
|
||||
input_memory_buffers,
|
||||
(ReadBufferOperation *)reader);
|
||||
}
|
||||
|
||||
const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBuffer)
|
||||
const cl_image_format *OpenCLDevice::determine_image_format(MemoryBuffer *memory_buffer)
|
||||
{
|
||||
switch (memoryBuffer->get_num_channels()) {
|
||||
switch (memory_buffer->get_num_channels()) {
|
||||
case 1:
|
||||
return &IMAGE_FORMAT_VALUE;
|
||||
break;
|
||||
@@ -116,166 +119,164 @@ const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBu
|
||||
return &IMAGE_FORMAT_COLOR;
|
||||
}
|
||||
|
||||
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
int parameterIndex,
|
||||
int offsetIndex,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **inputMemoryBuffers,
|
||||
ReadBufferOperation *reader)
|
||||
cl_mem OpenCLDevice::COM_cl_attach_memory_buffer_to_kernel_parameter(
|
||||
cl_kernel kernel,
|
||||
int parameter_index,
|
||||
int offset_index,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **input_memory_buffers,
|
||||
ReadBufferOperation *reader)
|
||||
{
|
||||
cl_int error;
|
||||
|
||||
MemoryBuffer *result = reader->getInputMemoryBuffer(inputMemoryBuffers);
|
||||
MemoryBuffer *result = reader->get_input_memory_buffer(input_memory_buffers);
|
||||
|
||||
const cl_image_format *imageFormat = determineImageFormat(result);
|
||||
const cl_image_format *image_format = determine_image_format(result);
|
||||
|
||||
cl_mem clBuffer = clCreateImage2D(this->m_context,
|
||||
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
imageFormat,
|
||||
result->getWidth(),
|
||||
result->getHeight(),
|
||||
0,
|
||||
result->getBuffer(),
|
||||
&error);
|
||||
cl_mem cl_buffer = clCreateImage2D(context_,
|
||||
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
|
||||
image_format,
|
||||
result->get_width(),
|
||||
result->get_height(),
|
||||
0,
|
||||
result->get_buffer(),
|
||||
&error);
|
||||
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
if (error == CL_SUCCESS) {
|
||||
cleanup->push_back(clBuffer);
|
||||
cleanup->push_back(cl_buffer);
|
||||
}
|
||||
|
||||
error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clBuffer);
|
||||
error = clSetKernelArg(kernel, parameter_index, sizeof(cl_mem), &cl_buffer);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
|
||||
COM_clAttachMemoryBufferOffsetToKernelParameter(kernel, offsetIndex, result);
|
||||
return clBuffer;
|
||||
COM_cl_attach_memory_buffer_offset_to_kernel_parameter(kernel, offset_index, result);
|
||||
return cl_buffer;
|
||||
}
|
||||
|
||||
void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel,
|
||||
int offsetIndex,
|
||||
MemoryBuffer *memoryBuffer)
|
||||
void OpenCLDevice::COM_cl_attach_memory_buffer_offset_to_kernel_parameter(
|
||||
cl_kernel kernel, int offset_index, MemoryBuffer *memory_buffer)
|
||||
{
|
||||
if (offsetIndex != -1) {
|
||||
if (offset_index != -1) {
|
||||
cl_int error;
|
||||
const rcti &rect = memoryBuffer->get_rect();
|
||||
const rcti &rect = memory_buffer->get_rect();
|
||||
cl_int2 offset = {{rect.xmin, rect.ymin}};
|
||||
|
||||
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
|
||||
error = clSetKernelArg(kernel, offset_index, sizeof(cl_int2), &offset);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenCLDevice::COM_clAttachSizeToKernelParameter(cl_kernel kernel,
|
||||
int offsetIndex,
|
||||
NodeOperation *operation)
|
||||
void OpenCLDevice::COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel,
|
||||
int offset_index,
|
||||
NodeOperation *operation)
|
||||
{
|
||||
if (offsetIndex != -1) {
|
||||
if (offset_index != -1) {
|
||||
cl_int error;
|
||||
cl_int2 offset = {{(cl_int)operation->getWidth(), (cl_int)operation->getHeight()}};
|
||||
cl_int2 offset = {{(cl_int)operation->get_width(), (cl_int)operation->get_height()}};
|
||||
|
||||
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
|
||||
error = clSetKernelArg(kernel, offset_index, sizeof(cl_int2), &offset);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OpenCLDevice::COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
int parameterIndex,
|
||||
cl_mem clOutputMemoryBuffer)
|
||||
void OpenCLDevice::COM_cl_attach_output_memory_buffer_to_kernel_parameter(
|
||||
cl_kernel kernel, int parameter_index, cl_mem cl_output_memory_buffer)
|
||||
{
|
||||
cl_int error;
|
||||
error = clSetKernelArg(kernel, parameterIndex, sizeof(cl_mem), &clOutputMemoryBuffer);
|
||||
error = clSetKernelArg(kernel, parameter_index, sizeof(cl_mem), &cl_output_memory_buffer);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
}
|
||||
|
||||
void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer)
|
||||
void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_memory_buffer)
|
||||
{
|
||||
cl_int error;
|
||||
const size_t size[] = {
|
||||
(size_t)outputMemoryBuffer->getWidth(),
|
||||
(size_t)outputMemoryBuffer->getHeight(),
|
||||
(size_t)output_memory_buffer->get_width(),
|
||||
(size_t)output_memory_buffer->get_height(),
|
||||
};
|
||||
|
||||
error = clEnqueueNDRangeKernel(
|
||||
this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
error = clEnqueueNDRangeKernel(queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
}
|
||||
|
||||
void OpenCLDevice::COM_clEnqueueRange(cl_kernel kernel,
|
||||
MemoryBuffer *outputMemoryBuffer,
|
||||
int offsetIndex,
|
||||
NodeOperation *operation)
|
||||
void OpenCLDevice::COM_cl_enqueue_range(cl_kernel kernel,
|
||||
MemoryBuffer *output_memory_buffer,
|
||||
int offset_index,
|
||||
NodeOperation *operation)
|
||||
{
|
||||
cl_int error;
|
||||
const int width = outputMemoryBuffer->getWidth();
|
||||
const int height = outputMemoryBuffer->getHeight();
|
||||
const int width = output_memory_buffer->get_width();
|
||||
const int height = output_memory_buffer->get_height();
|
||||
int offsetx;
|
||||
int offsety;
|
||||
int localSize = 1024;
|
||||
int local_size = 1024;
|
||||
size_t size[2];
|
||||
cl_int2 offset;
|
||||
|
||||
if (this->m_vendorID == NVIDIA) {
|
||||
localSize = 32;
|
||||
if (vendor_id_ == NVIDIA) {
|
||||
local_size = 32;
|
||||
}
|
||||
|
||||
bool breaked = false;
|
||||
for (offsety = 0; offsety < height && (!breaked); offsety += localSize) {
|
||||
for (offsety = 0; offsety < height && (!breaked); offsety += local_size) {
|
||||
offset.s[1] = offsety;
|
||||
if (offsety + localSize < height) {
|
||||
size[1] = localSize;
|
||||
if (offsety + local_size < height) {
|
||||
size[1] = local_size;
|
||||
}
|
||||
else {
|
||||
size[1] = height - offsety;
|
||||
}
|
||||
|
||||
for (offsetx = 0; offsetx < width && (!breaked); offsetx += localSize) {
|
||||
if (offsetx + localSize < width) {
|
||||
size[0] = localSize;
|
||||
for (offsetx = 0; offsetx < width && (!breaked); offsetx += local_size) {
|
||||
if (offsetx + local_size < width) {
|
||||
size[0] = local_size;
|
||||
}
|
||||
else {
|
||||
size[0] = width - offsetx;
|
||||
}
|
||||
offset.s[0] = offsetx;
|
||||
|
||||
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
|
||||
error = clSetKernelArg(kernel, offset_index, sizeof(cl_int2), &offset);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
error = clEnqueueNDRangeKernel(
|
||||
this->m_queue, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
queue_, kernel, 2, nullptr, size, nullptr, 0, nullptr, nullptr);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
clFlush(this->m_queue);
|
||||
if (operation->isBraked()) {
|
||||
clFlush(queue_);
|
||||
if (operation->is_braked()) {
|
||||
breaked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cl_kernel OpenCLDevice::COM_clCreateKernel(const char *kernelname,
|
||||
std::list<cl_kernel> *clKernelsToCleanUp)
|
||||
cl_kernel OpenCLDevice::COM_cl_create_kernel(const char *kernelname,
|
||||
std::list<cl_kernel> *cl_kernels_to_clean_up)
|
||||
{
|
||||
cl_int error;
|
||||
cl_kernel kernel = clCreateKernel(this->m_program, kernelname, &error);
|
||||
cl_kernel kernel = clCreateKernel(program_, kernelname, &error);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
else {
|
||||
if (clKernelsToCleanUp) {
|
||||
clKernelsToCleanUp->push_back(kernel);
|
||||
if (cl_kernels_to_clean_up) {
|
||||
cl_kernels_to_clean_up->push_back(kernel);
|
||||
}
|
||||
}
|
||||
return kernel;
|
||||
|
@@ -20,13 +20,20 @@ class OpenCLDevice;
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "COM_Device.h"
|
||||
#include "COM_ReadBufferOperation.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
|
||||
#include "clew.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class NodeOperation;
|
||||
class MemoryBuffer;
|
||||
class ReadBufferOperation;
|
||||
|
||||
typedef NodeOperation SocketReader;
|
||||
|
||||
/**
|
||||
* \brief device representing an GPU OpenCL device.
|
||||
* an instance of this class represents a single cl_device
|
||||
@@ -36,27 +43,27 @@ class OpenCLDevice : public Device {
|
||||
/**
|
||||
* \brief opencl context
|
||||
*/
|
||||
cl_context m_context;
|
||||
cl_context context_;
|
||||
|
||||
/**
|
||||
* \brief opencl device
|
||||
*/
|
||||
cl_device_id m_device;
|
||||
cl_device_id device_;
|
||||
|
||||
/**
|
||||
* \brief opencl program
|
||||
*/
|
||||
cl_program m_program;
|
||||
cl_program program_;
|
||||
|
||||
/**
|
||||
* \brief opencl command queue
|
||||
*/
|
||||
cl_command_queue m_queue;
|
||||
cl_command_queue queue_;
|
||||
|
||||
/**
|
||||
* \brief opencl vendor ID
|
||||
*/
|
||||
cl_int m_vendorID;
|
||||
cl_int vendor_id_;
|
||||
|
||||
public:
|
||||
/**
|
||||
@@ -66,7 +73,7 @@ class OpenCLDevice : public Device {
|
||||
* \param program:
|
||||
* \param vendorID:
|
||||
*/
|
||||
OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendorId);
|
||||
OpenCLDevice(cl_context context, cl_device_id device, cl_program program, cl_int vendor_id);
|
||||
|
||||
OpenCLDevice(OpenCLDevice &&other) noexcept;
|
||||
|
||||
@@ -82,45 +89,46 @@ class OpenCLDevice : public Device {
|
||||
* \brief determine an image format
|
||||
* \param memorybuffer:
|
||||
*/
|
||||
static const cl_image_format *determineImageFormat(MemoryBuffer *memoryBuffer);
|
||||
static const cl_image_format *determine_image_format(MemoryBuffer *memory_buffer);
|
||||
|
||||
cl_context getContext()
|
||||
cl_context get_context()
|
||||
{
|
||||
return this->m_context;
|
||||
return context_;
|
||||
}
|
||||
|
||||
cl_command_queue getQueue()
|
||||
cl_command_queue get_queue()
|
||||
{
|
||||
return this->m_queue;
|
||||
return queue_;
|
||||
}
|
||||
|
||||
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
int parameterIndex,
|
||||
int offsetIndex,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **inputMemoryBuffers,
|
||||
SocketReader *reader);
|
||||
cl_mem COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
int parameterIndex,
|
||||
int offsetIndex,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **inputMemoryBuffers,
|
||||
ReadBufferOperation *reader);
|
||||
void COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel kernel,
|
||||
int offsetIndex,
|
||||
MemoryBuffer *memoryBuffers);
|
||||
void COM_clAttachOutputMemoryBufferToKernelParameter(cl_kernel kernel,
|
||||
int parameterIndex,
|
||||
cl_mem clOutputMemoryBuffer);
|
||||
void COM_clAttachSizeToKernelParameter(cl_kernel kernel,
|
||||
int offsetIndex,
|
||||
NodeOperation *operation);
|
||||
void COM_clEnqueueRange(cl_kernel kernel, MemoryBuffer *outputMemoryBuffer);
|
||||
void COM_clEnqueueRange(cl_kernel kernel,
|
||||
MemoryBuffer *outputMemoryBuffer,
|
||||
int offsetIndex,
|
||||
NodeOperation *operation);
|
||||
cl_kernel COM_clCreateKernel(const char *kernelname, std::list<cl_kernel> *clKernelsToCleanUp);
|
||||
cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel,
|
||||
int parameter_index,
|
||||
int offset_index,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **input_memory_buffers,
|
||||
SocketReader *reader);
|
||||
cl_mem COM_cl_attach_memory_buffer_to_kernel_parameter(cl_kernel kernel,
|
||||
int parameter_index,
|
||||
int offset_index,
|
||||
std::list<cl_mem> *cleanup,
|
||||
MemoryBuffer **input_memory_buffers,
|
||||
ReadBufferOperation *reader);
|
||||
void COM_cl_attach_memory_buffer_offset_to_kernel_parameter(cl_kernel kernel,
|
||||
int offset_index,
|
||||
MemoryBuffer *memory_buffers);
|
||||
void COM_cl_attach_output_memory_buffer_to_kernel_parameter(cl_kernel kernel,
|
||||
int parameter_index,
|
||||
cl_mem cl_output_memory_buffer);
|
||||
void COM_cl_attach_size_to_kernel_parameter(cl_kernel kernel,
|
||||
int offset_index,
|
||||
NodeOperation *operation);
|
||||
void COM_cl_enqueue_range(cl_kernel kernel, MemoryBuffer *output_memory_buffer);
|
||||
void COM_cl_enqueue_range(cl_kernel kernel,
|
||||
MemoryBuffer *output_memory_buffer,
|
||||
int offset_index,
|
||||
NodeOperation *operation);
|
||||
cl_kernel COM_cl_create_kernel(const char *kernelname,
|
||||
std::list<cl_kernel> *cl_kernels_to_clean_up);
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "COM_SharedOperationBuffers.h"
|
||||
#include "BLI_rect.h"
|
||||
#include "COM_NodeOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
@@ -19,16 +19,19 @@
|
||||
#pragma once
|
||||
|
||||
#include "BLI_map.hh"
|
||||
#include "BLI_span.hh"
|
||||
#include "BLI_vector.hh"
|
||||
#include "COM_MemoryBuffer.h"
|
||||
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
# include "MEM_guardedalloc.h"
|
||||
#endif
|
||||
#include <memory>
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
class MemoryBuffer;
|
||||
class NodeOperation;
|
||||
|
||||
/**
|
||||
* Stores and shares operations rendered buffers including render data. Buffers are
|
||||
* disposed once all dependent operations have finished reading them.
|
||||
|
@@ -22,42 +22,42 @@ namespace blender::compositor {
|
||||
|
||||
SingleThreadedOperation::SingleThreadedOperation()
|
||||
{
|
||||
this->m_cachedInstance = nullptr;
|
||||
cached_instance_ = nullptr;
|
||||
flags.complex = true;
|
||||
flags.single_threaded = true;
|
||||
}
|
||||
|
||||
void SingleThreadedOperation::initExecution()
|
||||
void SingleThreadedOperation::init_execution()
|
||||
{
|
||||
initMutex();
|
||||
init_mutex();
|
||||
}
|
||||
|
||||
void SingleThreadedOperation::executePixel(float output[4], int x, int y, void * /*data*/)
|
||||
void SingleThreadedOperation::execute_pixel(float output[4], int x, int y, void * /*data*/)
|
||||
{
|
||||
this->m_cachedInstance->readNoCheck(output, x, y);
|
||||
cached_instance_->read_no_check(output, x, y);
|
||||
}
|
||||
|
||||
void SingleThreadedOperation::deinitExecution()
|
||||
void SingleThreadedOperation::deinit_execution()
|
||||
{
|
||||
deinitMutex();
|
||||
if (this->m_cachedInstance) {
|
||||
delete this->m_cachedInstance;
|
||||
this->m_cachedInstance = nullptr;
|
||||
deinit_mutex();
|
||||
if (cached_instance_) {
|
||||
delete cached_instance_;
|
||||
cached_instance_ = nullptr;
|
||||
}
|
||||
}
|
||||
void *SingleThreadedOperation::initializeTileData(rcti *rect)
|
||||
void *SingleThreadedOperation::initialize_tile_data(rcti *rect)
|
||||
{
|
||||
if (this->m_cachedInstance) {
|
||||
return this->m_cachedInstance;
|
||||
if (cached_instance_) {
|
||||
return cached_instance_;
|
||||
}
|
||||
|
||||
lockMutex();
|
||||
if (this->m_cachedInstance == nullptr) {
|
||||
lock_mutex();
|
||||
if (cached_instance_ == nullptr) {
|
||||
//
|
||||
this->m_cachedInstance = createMemoryBuffer(rect);
|
||||
cached_instance_ = create_memory_buffer(rect);
|
||||
}
|
||||
unlockMutex();
|
||||
return this->m_cachedInstance;
|
||||
unlock_mutex();
|
||||
return cached_instance_;
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -24,12 +24,12 @@ namespace blender::compositor {
|
||||
|
||||
class SingleThreadedOperation : public NodeOperation {
|
||||
private:
|
||||
MemoryBuffer *m_cachedInstance;
|
||||
MemoryBuffer *cached_instance_;
|
||||
|
||||
protected:
|
||||
inline bool isCached()
|
||||
inline bool is_cached()
|
||||
{
|
||||
return this->m_cachedInstance != nullptr;
|
||||
return cached_instance_ != nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -38,21 +38,21 @@ class SingleThreadedOperation : public NodeOperation {
|
||||
/**
|
||||
* The inner loop of this operation.
|
||||
*/
|
||||
void executePixel(float output[4], int x, int y, void *data) override;
|
||||
void execute_pixel(float output[4], int x, int y, void *data) override;
|
||||
|
||||
/**
|
||||
* Initialize the execution
|
||||
*/
|
||||
void initExecution() override;
|
||||
void init_execution() override;
|
||||
|
||||
/**
|
||||
* Deinitialize the execution
|
||||
*/
|
||||
void deinitExecution() override;
|
||||
void deinit_execution() override;
|
||||
|
||||
void *initializeTileData(rcti *rect) override;
|
||||
void *initialize_tile_data(rcti *rect) override;
|
||||
|
||||
virtual MemoryBuffer *createMemoryBuffer(rcti *rect) = 0;
|
||||
virtual MemoryBuffer *create_memory_buffer(rcti *rect) = 0;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -35,24 +35,24 @@ TiledExecutionModel::TiledExecutionModel(CompositorContext &context,
|
||||
Span<ExecutionGroup *> groups)
|
||||
: ExecutionModel(context, operations), groups_(groups)
|
||||
{
|
||||
const bNodeTree *node_tree = context.getbNodeTree();
|
||||
const bNodeTree *node_tree = context.get_bnodetree();
|
||||
node_tree->stats_draw(node_tree->sdh, TIP_("Compositing | Determining resolution"));
|
||||
|
||||
unsigned int resolution[2];
|
||||
for (ExecutionGroup *group : groups_) {
|
||||
resolution[0] = 0;
|
||||
resolution[1] = 0;
|
||||
group->determineResolution(resolution);
|
||||
group->determine_resolution(resolution);
|
||||
|
||||
if (border_.use_render_border) {
|
||||
const rctf *render_border = border_.render_border;
|
||||
group->setRenderBorder(
|
||||
group->set_render_border(
|
||||
render_border->xmin, render_border->xmax, render_border->ymin, render_border->ymax);
|
||||
}
|
||||
|
||||
if (border_.use_viewer_border) {
|
||||
const rctf *viewer_border = border_.viewer_border;
|
||||
group->setViewerBorder(
|
||||
group->set_viewer_border(
|
||||
viewer_border->xmin, viewer_border->xmax, viewer_border->ymin, viewer_border->ymax);
|
||||
}
|
||||
}
|
||||
@@ -63,8 +63,8 @@ static void update_read_buffer_offset(Span<NodeOperation *> operations)
|
||||
unsigned int order = 0;
|
||||
for (NodeOperation *operation : operations) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *readOperation = (ReadBufferOperation *)operation;
|
||||
readOperation->setOffset(order);
|
||||
ReadBufferOperation *read_operation = (ReadBufferOperation *)operation;
|
||||
read_operation->set_offset(order);
|
||||
order++;
|
||||
}
|
||||
}
|
||||
@@ -75,8 +75,8 @@ static void init_write_operations_for_execution(Span<NodeOperation *> operations
|
||||
{
|
||||
for (NodeOperation *operation : operations) {
|
||||
if (operation->get_flags().is_write_buffer_operation) {
|
||||
operation->setbNodeTree(bTree);
|
||||
operation->initExecution();
|
||||
operation->set_bnodetree(bTree);
|
||||
operation->init_execution();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,8 +85,8 @@ static void link_write_buffers(Span<NodeOperation *> operations)
|
||||
{
|
||||
for (NodeOperation *operation : operations) {
|
||||
if (operation->get_flags().is_read_buffer_operation) {
|
||||
ReadBufferOperation *readOperation = static_cast<ReadBufferOperation *>(operation);
|
||||
readOperation->updateMemoryBuffer();
|
||||
ReadBufferOperation *read_operation = static_cast<ReadBufferOperation *>(operation);
|
||||
read_operation->update_memory_buffer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,8 @@ static void init_non_write_operations_for_execution(Span<NodeOperation *> operat
|
||||
{
|
||||
for (NodeOperation *operation : operations) {
|
||||
if (!operation->get_flags().is_write_buffer_operation) {
|
||||
operation->setbNodeTree(bTree);
|
||||
operation->initExecution();
|
||||
operation->set_bnodetree(bTree);
|
||||
operation->init_execution();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,27 +106,27 @@ static void init_execution_groups_for_execution(Span<ExecutionGroup *> groups,
|
||||
const int chunk_size)
|
||||
{
|
||||
for (ExecutionGroup *execution_group : groups) {
|
||||
execution_group->setChunksize(chunk_size);
|
||||
execution_group->initExecution();
|
||||
execution_group->set_chunksize(chunk_size);
|
||||
execution_group->init_execution();
|
||||
}
|
||||
}
|
||||
|
||||
void TiledExecutionModel::execute(ExecutionSystem &exec_system)
|
||||
{
|
||||
const bNodeTree *editingtree = this->context_.getbNodeTree();
|
||||
const bNodeTree *editingtree = this->context_.get_bnodetree();
|
||||
|
||||
editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | Initializing execution"));
|
||||
|
||||
update_read_buffer_offset(operations_);
|
||||
|
||||
init_write_operations_for_execution(operations_, context_.getbNodeTree());
|
||||
init_write_operations_for_execution(operations_, context_.get_bnodetree());
|
||||
link_write_buffers(operations_);
|
||||
init_non_write_operations_for_execution(operations_, context_.getbNodeTree());
|
||||
init_execution_groups_for_execution(groups_, context_.getChunksize());
|
||||
init_non_write_operations_for_execution(operations_, context_.get_bnodetree());
|
||||
init_execution_groups_for_execution(groups_, context_.get_chunksize());
|
||||
|
||||
WorkScheduler::start(context_);
|
||||
execute_groups(eCompositorPriority::High, exec_system);
|
||||
if (!context_.isFastCalculation()) {
|
||||
if (!context_.is_fast_calculation()) {
|
||||
execute_groups(eCompositorPriority::Medium, exec_system);
|
||||
execute_groups(eCompositorPriority::Low, exec_system);
|
||||
}
|
||||
@@ -136,11 +136,11 @@ void TiledExecutionModel::execute(ExecutionSystem &exec_system)
|
||||
editingtree->stats_draw(editingtree->sdh, TIP_("Compositing | De-initializing execution"));
|
||||
|
||||
for (NodeOperation *operation : operations_) {
|
||||
operation->deinitExecution();
|
||||
operation->deinit_execution();
|
||||
}
|
||||
|
||||
for (ExecutionGroup *execution_group : groups_) {
|
||||
execution_group->deinitExecution();
|
||||
execution_group->deinit_execution();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ void TiledExecutionModel::execute_groups(eCompositorPriority priority,
|
||||
{
|
||||
for (ExecutionGroup *execution_group : groups_) {
|
||||
if (execution_group->get_flags().is_output &&
|
||||
execution_group->getRenderPriority() == priority) {
|
||||
execution_group->get_render_priority() == priority) {
|
||||
execution_group->execute(&exec_system);
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_Enums.h"
|
||||
#include "COM_ExecutionModel.h"
|
||||
|
||||
#ifdef WITH_CXX_GUARDEDALLOC
|
||||
|
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "COM_WorkPackage.h"
|
||||
|
||||
#include "COM_Enums.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
@@ -24,7 +24,7 @@
|
||||
|
||||
#include "COM_Enums.h"
|
||||
|
||||
#include "BLI_rect.h"
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
@@ -43,7 +43,7 @@ struct WorkPackage {
|
||||
eWorkPackageState state = eWorkPackageState::NotScheduled;
|
||||
|
||||
/**
|
||||
* \brief executionGroup with the operations-setup to be evaluated
|
||||
* \brief execution_group with the operations-setup to be evaluated
|
||||
*/
|
||||
ExecutionGroup *execution_group;
|
||||
|
||||
|
@@ -16,15 +16,14 @@
|
||||
* Copyright 2011, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <list>
|
||||
#include "COM_WorkScheduler.h"
|
||||
|
||||
#include "COM_CPUDevice.h"
|
||||
#include "COM_CompositorContext.h"
|
||||
#include "COM_ExecutionGroup.h"
|
||||
#include "COM_OpenCLDevice.h"
|
||||
#include "COM_OpenCLKernels.cl.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
#include "COM_WriteBufferOperation.h"
|
||||
#include "COM_compositor.h"
|
||||
|
||||
#include "clew.h"
|
||||
|
||||
@@ -33,7 +32,6 @@
|
||||
#include "BLI_task.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_vector.hh"
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include "BKE_global.h"
|
||||
|
||||
@@ -106,10 +104,10 @@ static struct {
|
||||
/** \name OpenCL Scheduling
|
||||
* \{ */
|
||||
|
||||
static void CL_CALLBACK clContextError(const char *errinfo,
|
||||
const void * /*private_info*/,
|
||||
size_t /*cb*/,
|
||||
void * /*user_data*/)
|
||||
static void CL_CALLBACK cl_context_error(const char *errinfo,
|
||||
const void * /*private_info*/,
|
||||
size_t /*cb*/,
|
||||
void * /*user_data*/)
|
||||
{
|
||||
printf("OPENCL error: %s\n", errinfo);
|
||||
}
|
||||
@@ -128,7 +126,7 @@ static void *thread_execute_gpu(void *data)
|
||||
|
||||
static void opencl_start(const CompositorContext &context)
|
||||
{
|
||||
if (context.getHasActiveOpenCLDevices()) {
|
||||
if (context.get_has_active_opencl_devices()) {
|
||||
g_work_scheduler.opencl.queue = BLI_thread_queue_init();
|
||||
BLI_threadpool_init(&g_work_scheduler.opencl.threads,
|
||||
thread_execute_gpu,
|
||||
@@ -188,35 +186,35 @@ static void opencl_initialize(const bool use_opencl)
|
||||
}
|
||||
|
||||
if (clCreateContextFromType) {
|
||||
cl_uint numberOfPlatforms = 0;
|
||||
cl_uint number_of_platforms = 0;
|
||||
cl_int error;
|
||||
error = clGetPlatformIDs(0, nullptr, &numberOfPlatforms);
|
||||
error = clGetPlatformIDs(0, nullptr, &number_of_platforms);
|
||||
if (error == -1001) {
|
||||
} /* GPU not supported */
|
||||
else if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
if (G.f & G_DEBUG) {
|
||||
printf("%u number of platforms\n", numberOfPlatforms);
|
||||
printf("%u number of platforms\n", number_of_platforms);
|
||||
}
|
||||
cl_platform_id *platforms = (cl_platform_id *)MEM_mallocN(
|
||||
sizeof(cl_platform_id) * numberOfPlatforms, __func__);
|
||||
error = clGetPlatformIDs(numberOfPlatforms, platforms, nullptr);
|
||||
unsigned int indexPlatform;
|
||||
for (indexPlatform = 0; indexPlatform < numberOfPlatforms; indexPlatform++) {
|
||||
cl_platform_id platform = platforms[indexPlatform];
|
||||
cl_uint numberOfDevices = 0;
|
||||
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &numberOfDevices);
|
||||
if (numberOfDevices <= 0) {
|
||||
sizeof(cl_platform_id) * number_of_platforms, __func__);
|
||||
error = clGetPlatformIDs(number_of_platforms, platforms, nullptr);
|
||||
unsigned int index_platform;
|
||||
for (index_platform = 0; index_platform < number_of_platforms; index_platform++) {
|
||||
cl_platform_id platform = platforms[index_platform];
|
||||
cl_uint number_of_devices = 0;
|
||||
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, nullptr, &number_of_devices);
|
||||
if (number_of_devices <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
cl_device_id *cldevices = (cl_device_id *)MEM_mallocN(
|
||||
sizeof(cl_device_id) * numberOfDevices, __func__);
|
||||
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numberOfDevices, cldevices, nullptr);
|
||||
sizeof(cl_device_id) * number_of_devices, __func__);
|
||||
clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, number_of_devices, cldevices, nullptr);
|
||||
|
||||
g_work_scheduler.opencl.context = clCreateContext(
|
||||
nullptr, numberOfDevices, cldevices, clContextError, nullptr, &error);
|
||||
nullptr, number_of_devices, cldevices, cl_context_error, nullptr, &error);
|
||||
if (error != CL_SUCCESS) {
|
||||
printf("CLERROR[%d]: %s\n", error, clewErrorString(error));
|
||||
}
|
||||
@@ -224,7 +222,7 @@ static void opencl_initialize(const bool use_opencl)
|
||||
g_work_scheduler.opencl.program = clCreateProgramWithSource(
|
||||
g_work_scheduler.opencl.context, 1, cl_str, nullptr, &error);
|
||||
error = clBuildProgram(g_work_scheduler.opencl.program,
|
||||
numberOfDevices,
|
||||
number_of_devices,
|
||||
cldevices,
|
||||
nullptr,
|
||||
nullptr,
|
||||
@@ -257,9 +255,9 @@ static void opencl_initialize(const bool use_opencl)
|
||||
MEM_freeN(build_log);
|
||||
}
|
||||
else {
|
||||
unsigned int indexDevices;
|
||||
for (indexDevices = 0; indexDevices < numberOfDevices; indexDevices++) {
|
||||
cl_device_id device = cldevices[indexDevices];
|
||||
unsigned int index_devices;
|
||||
for (index_devices = 0; index_devices < number_of_devices; index_devices++) {
|
||||
cl_device_id device = cldevices[index_devices];
|
||||
cl_int vendorID = 0;
|
||||
cl_int error2 = clGetDeviceInfo(
|
||||
device, CL_DEVICE_VENDOR_ID, sizeof(cl_int), &vendorID, nullptr);
|
||||
|
@@ -18,14 +18,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "COM_ExecutionGroup.h"
|
||||
|
||||
#include "COM_Device.h"
|
||||
#include "COM_WorkPackage.h"
|
||||
#include "COM_defines.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
struct WorkPackage;
|
||||
|
||||
class CompositorContext;
|
||||
|
||||
/** \brief the workscheduler
|
||||
* \ingroup execution
|
||||
*/
|
||||
@@ -83,7 +81,7 @@ struct WorkScheduler {
|
||||
* \brief Are there OpenCL capable GPU devices initialized?
|
||||
* the result of this method is stored in the CompositorContext
|
||||
* A node can generate a different operation tree when OpenCLDevices exists.
|
||||
* \see CompositorContext.getHasActiveOpenCLDevices
|
||||
* \see CompositorContext.get_has_active_opencl_devices
|
||||
*/
|
||||
static bool has_gpu_devices();
|
||||
|
||||
|
@@ -24,10 +24,8 @@
|
||||
#include "BKE_scene.h"
|
||||
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_MovieDistortionOperation.h"
|
||||
#include "COM_WorkScheduler.h"
|
||||
#include "COM_compositor.h"
|
||||
#include "clew.h"
|
||||
|
||||
static struct {
|
||||
bool is_initialized = false;
|
||||
@@ -66,9 +64,9 @@ void COM_execute(RenderData *render_data,
|
||||
Scene *scene,
|
||||
bNodeTree *node_tree,
|
||||
int rendering,
|
||||
const ColorManagedViewSettings *viewSettings,
|
||||
const ColorManagedDisplaySettings *displaySettings,
|
||||
const char *viewName)
|
||||
const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings,
|
||||
const char *view_name)
|
||||
{
|
||||
/* Initialize mutex, TODO: this mutex init is actually not thread safe and
|
||||
* should be done somewhere as part of blender startup, all the other
|
||||
@@ -97,8 +95,14 @@ void COM_execute(RenderData *render_data,
|
||||
/* Execute. */
|
||||
const bool twopass = (node_tree->flag & NTREE_TWO_PASS) && !rendering;
|
||||
if (twopass) {
|
||||
blender::compositor::ExecutionSystem fast_pass(
|
||||
render_data, scene, node_tree, rendering, true, viewSettings, displaySettings, viewName);
|
||||
blender::compositor::ExecutionSystem fast_pass(render_data,
|
||||
scene,
|
||||
node_tree,
|
||||
rendering,
|
||||
true,
|
||||
view_settings,
|
||||
display_settings,
|
||||
view_name);
|
||||
fast_pass.execute();
|
||||
|
||||
if (node_tree->test_break(node_tree->tbh)) {
|
||||
@@ -108,7 +112,7 @@ void COM_execute(RenderData *render_data,
|
||||
}
|
||||
|
||||
blender::compositor::ExecutionSystem system(
|
||||
render_data, scene, node_tree, rendering, false, viewSettings, displaySettings, viewName);
|
||||
render_data, scene, node_tree, rendering, false, view_settings, display_settings, view_name);
|
||||
system.execute();
|
||||
|
||||
BLI_mutex_unlock(&g_compositor.mutex);
|
||||
|
@@ -21,50 +21,46 @@
|
||||
#include "COM_AlphaOverKeyOperation.h"
|
||||
#include "COM_AlphaOverMixedOperation.h"
|
||||
#include "COM_AlphaOverPremultiplyOperation.h"
|
||||
#include "COM_MixOperation.h"
|
||||
|
||||
#include "COM_SetValueOperation.h"
|
||||
#include "DNA_material_types.h" /* the ramp types */
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
void AlphaOverNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void AlphaOverNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
NodeInput *color1Socket = this->getInputSocket(1);
|
||||
NodeInput *color2Socket = this->getInputSocket(2);
|
||||
bNode *editorNode = this->getbNode();
|
||||
NodeInput *color1Socket = this->get_input_socket(1);
|
||||
NodeInput *color2Socket = this->get_input_socket(2);
|
||||
bNode *editor_node = this->get_bnode();
|
||||
|
||||
MixBaseOperation *convertProg;
|
||||
NodeTwoFloats *ntf = (NodeTwoFloats *)editorNode->storage;
|
||||
MixBaseOperation *convert_prog;
|
||||
NodeTwoFloats *ntf = (NodeTwoFloats *)editor_node->storage;
|
||||
if (ntf->x != 0.0f) {
|
||||
AlphaOverMixedOperation *mixOperation = new AlphaOverMixedOperation();
|
||||
mixOperation->setX(ntf->x);
|
||||
convertProg = mixOperation;
|
||||
AlphaOverMixedOperation *mix_operation = new AlphaOverMixedOperation();
|
||||
mix_operation->setX(ntf->x);
|
||||
convert_prog = mix_operation;
|
||||
}
|
||||
else if (editorNode->custom1) {
|
||||
convertProg = new AlphaOverKeyOperation();
|
||||
else if (editor_node->custom1) {
|
||||
convert_prog = new AlphaOverKeyOperation();
|
||||
}
|
||||
else {
|
||||
convertProg = new AlphaOverPremultiplyOperation();
|
||||
convert_prog = new AlphaOverPremultiplyOperation();
|
||||
}
|
||||
|
||||
convertProg->setUseValueAlphaMultiply(false);
|
||||
if (color1Socket->isLinked()) {
|
||||
convertProg->set_canvas_input_index(1);
|
||||
convert_prog->set_use_value_alpha_multiply(false);
|
||||
if (color1Socket->is_linked()) {
|
||||
convert_prog->set_canvas_input_index(1);
|
||||
}
|
||||
else if (color2Socket->isLinked()) {
|
||||
convertProg->set_canvas_input_index(2);
|
||||
else if (color2Socket->is_linked()) {
|
||||
convert_prog->set_canvas_input_index(2);
|
||||
}
|
||||
else {
|
||||
convertProg->set_canvas_input_index(0);
|
||||
convert_prog->set_canvas_input_index(0);
|
||||
}
|
||||
|
||||
converter.addOperation(convertProg);
|
||||
converter.mapInputSocket(getInputSocket(0), convertProg->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), convertProg->getInputSocket(1));
|
||||
converter.mapInputSocket(getInputSocket(2), convertProg->getInputSocket(2));
|
||||
converter.mapOutputSocket(getOutputSocket(0), convertProg->getOutputSocket(0));
|
||||
converter.add_operation(convert_prog);
|
||||
converter.map_input_socket(get_input_socket(0), convert_prog->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), convert_prog->get_input_socket(1));
|
||||
converter.map_input_socket(get_input_socket(2), convert_prog->get_input_socket(2));
|
||||
converter.map_output_socket(get_output_socket(0), convert_prog->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,11 +28,11 @@ namespace blender::compositor {
|
||||
*/
|
||||
class AlphaOverNode : public Node {
|
||||
public:
|
||||
AlphaOverNode(bNode *editorNode) : Node(editorNode)
|
||||
AlphaOverNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
}
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -20,41 +20,40 @@
|
||||
|
||||
#include "COM_AntiAliasingNode.h"
|
||||
#include "COM_SMAAOperation.h"
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
void AntiAliasingNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void AntiAliasingNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *node = this->getbNode();
|
||||
bNode *node = this->get_bnode();
|
||||
NodeAntiAliasingData *data = (NodeAntiAliasingData *)node->storage;
|
||||
|
||||
/* Edge Detection (First Pass) */
|
||||
SMAAEdgeDetectionOperation *operation1 = nullptr;
|
||||
|
||||
operation1 = new SMAAEdgeDetectionOperation();
|
||||
operation1->setThreshold(data->threshold);
|
||||
operation1->setLocalContrastAdaptationFactor(data->contrast_limit);
|
||||
converter.addOperation(operation1);
|
||||
operation1->set_threshold(data->threshold);
|
||||
operation1->set_local_contrast_adaptation_factor(data->contrast_limit);
|
||||
converter.add_operation(operation1);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation1->getInputSocket(0));
|
||||
converter.map_input_socket(get_input_socket(0), operation1->get_input_socket(0));
|
||||
|
||||
/* Blending Weight Calculation Pixel Shader (Second Pass) */
|
||||
SMAABlendingWeightCalculationOperation *operation2 =
|
||||
new SMAABlendingWeightCalculationOperation();
|
||||
operation2->setCornerRounding(data->corner_rounding);
|
||||
converter.addOperation(operation2);
|
||||
operation2->set_corner_rounding(data->corner_rounding);
|
||||
converter.add_operation(operation2);
|
||||
|
||||
converter.addLink(operation1->getOutputSocket(), operation2->getInputSocket(0));
|
||||
converter.add_link(operation1->get_output_socket(), operation2->get_input_socket(0));
|
||||
|
||||
/* Neighborhood Blending Pixel Shader (Third Pass) */
|
||||
SMAANeighborhoodBlendingOperation *operation3 = new SMAANeighborhoodBlendingOperation();
|
||||
converter.addOperation(operation3);
|
||||
converter.add_operation(operation3);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation3->getInputSocket(0));
|
||||
converter.addLink(operation2->getOutputSocket(), operation3->getInputSocket(1));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation3->getOutputSocket());
|
||||
converter.map_input_socket(get_input_socket(0), operation3->get_input_socket(0));
|
||||
converter.add_link(operation2->get_output_socket(), operation3->get_input_socket(1));
|
||||
converter.map_output_socket(get_output_socket(0), operation3->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -30,11 +30,11 @@ namespace blender::compositor {
|
||||
*/
|
||||
class AntiAliasingNode : public Node {
|
||||
public:
|
||||
AntiAliasingNode(bNode *editorNode) : Node(editorNode)
|
||||
AntiAliasingNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
}
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,28 +18,26 @@
|
||||
|
||||
#include "COM_BilateralBlurNode.h"
|
||||
#include "COM_BilateralBlurOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode)
|
||||
BilateralBlurNode::BilateralBlurNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void BilateralBlurNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
void BilateralBlurNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage;
|
||||
NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->get_bnode()->storage;
|
||||
BilateralBlurOperation *operation = new BilateralBlurOperation();
|
||||
operation->setQuality(context.getQuality());
|
||||
operation->setData(data);
|
||||
operation->set_quality(context.get_quality());
|
||||
operation->set_data(data);
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class BilateralBlurNode : public Node {
|
||||
public:
|
||||
BilateralBlurNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
BilateralBlurNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
#include "COM_BlurNode.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_FastGaussianBlurOperation.h"
|
||||
#include "COM_GammaCorrectOperation.h"
|
||||
#include "COM_GaussianAlphaXBlurOperation.h"
|
||||
@@ -27,107 +26,106 @@
|
||||
#include "COM_GaussianYBlurOperation.h"
|
||||
#include "COM_MathBaseOperation.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
#include "DNA_node_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
|
||||
BlurNode::BlurNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void BlurNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
void BlurNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
bNode *editorNode = this->getbNode();
|
||||
NodeBlurData *data = (NodeBlurData *)editorNode->storage;
|
||||
NodeInput *inputSizeSocket = this->getInputSocket(1);
|
||||
bool connectedSizeSocket = inputSizeSocket->isLinked();
|
||||
bNode *editor_node = this->get_bnode();
|
||||
NodeBlurData *data = (NodeBlurData *)editor_node->storage;
|
||||
NodeInput *input_size_socket = this->get_input_socket(1);
|
||||
bool connected_size_socket = input_size_socket->is_linked();
|
||||
|
||||
const float size = this->getInputSocket(1)->getEditorValueFloat();
|
||||
const bool extend_bounds = (editorNode->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
|
||||
const float size = this->get_input_socket(1)->get_editor_value_float();
|
||||
const bool extend_bounds = (editor_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
|
||||
|
||||
eCompositorQuality quality = context.getQuality();
|
||||
eCompositorQuality quality = context.get_quality();
|
||||
NodeOperation *input_operation = nullptr, *output_operation = nullptr;
|
||||
|
||||
if (data->filtertype == R_FILTER_FAST_GAUSS) {
|
||||
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
|
||||
operationfgb->setData(data);
|
||||
operationfgb->setExtendBounds(extend_bounds);
|
||||
converter.addOperation(operationfgb);
|
||||
operationfgb->set_data(data);
|
||||
operationfgb->set_extend_bounds(extend_bounds);
|
||||
converter.add_operation(operationfgb);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(1), operationfgb->getInputSocket(1));
|
||||
converter.map_input_socket(get_input_socket(1), operationfgb->get_input_socket(1));
|
||||
|
||||
input_operation = operationfgb;
|
||||
output_operation = operationfgb;
|
||||
}
|
||||
else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
|
||||
else if (editor_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
|
||||
MathAddOperation *clamp = new MathAddOperation();
|
||||
SetValueOperation *zero = new SetValueOperation();
|
||||
zero->setValue(0.0f);
|
||||
clamp->setUseClamp(true);
|
||||
zero->set_value(0.0f);
|
||||
clamp->set_use_clamp(true);
|
||||
|
||||
converter.addOperation(clamp);
|
||||
converter.addOperation(zero);
|
||||
converter.mapInputSocket(getInputSocket(1), clamp->getInputSocket(0));
|
||||
converter.addLink(zero->getOutputSocket(), clamp->getInputSocket(1));
|
||||
converter.add_operation(clamp);
|
||||
converter.add_operation(zero);
|
||||
converter.map_input_socket(get_input_socket(1), clamp->get_input_socket(0));
|
||||
converter.add_link(zero->get_output_socket(), clamp->get_input_socket(1));
|
||||
|
||||
GaussianAlphaXBlurOperation *operationx = new GaussianAlphaXBlurOperation();
|
||||
operationx->setData(data);
|
||||
operationx->setQuality(quality);
|
||||
operationx->setSize(1.0f);
|
||||
operationx->setFalloff(PROP_SMOOTH);
|
||||
operationx->setSubtract(false);
|
||||
operationx->setExtendBounds(extend_bounds);
|
||||
operationx->set_data(data);
|
||||
operationx->set_quality(quality);
|
||||
operationx->set_size(1.0f);
|
||||
operationx->set_falloff(PROP_SMOOTH);
|
||||
operationx->set_subtract(false);
|
||||
operationx->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operationx);
|
||||
converter.addLink(clamp->getOutputSocket(), operationx->getInputSocket(0));
|
||||
converter.add_operation(operationx);
|
||||
converter.add_link(clamp->get_output_socket(), operationx->get_input_socket(0));
|
||||
|
||||
GaussianAlphaYBlurOperation *operationy = new GaussianAlphaYBlurOperation();
|
||||
operationy->setData(data);
|
||||
operationy->setQuality(quality);
|
||||
operationy->setSize(1.0f);
|
||||
operationy->setFalloff(PROP_SMOOTH);
|
||||
operationy->setSubtract(false);
|
||||
operationy->setExtendBounds(extend_bounds);
|
||||
operationy->set_data(data);
|
||||
operationy->set_quality(quality);
|
||||
operationy->set_size(1.0f);
|
||||
operationy->set_falloff(PROP_SMOOTH);
|
||||
operationy->set_subtract(false);
|
||||
operationy->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operationy);
|
||||
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
|
||||
converter.add_operation(operationy);
|
||||
converter.add_link(operationx->get_output_socket(), operationy->get_input_socket(0));
|
||||
|
||||
GaussianBlurReferenceOperation *operation = new GaussianBlurReferenceOperation();
|
||||
operation->setData(data);
|
||||
operation->setQuality(quality);
|
||||
operation->setExtendBounds(extend_bounds);
|
||||
operation->set_data(data);
|
||||
operation->set_quality(quality);
|
||||
operation->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.addLink(operationy->getOutputSocket(), operation->getInputSocket(1));
|
||||
converter.add_operation(operation);
|
||||
converter.add_link(operationy->get_output_socket(), operation->get_input_socket(1));
|
||||
|
||||
output_operation = operation;
|
||||
input_operation = operation;
|
||||
}
|
||||
else if (!data->bokeh) {
|
||||
GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
|
||||
operationx->setData(data);
|
||||
operationx->setQuality(quality);
|
||||
operationx->checkOpenCL();
|
||||
operationx->setExtendBounds(extend_bounds);
|
||||
operationx->set_data(data);
|
||||
operationx->set_quality(quality);
|
||||
operationx->check_opencl();
|
||||
operationx->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operationx);
|
||||
converter.mapInputSocket(getInputSocket(1), operationx->getInputSocket(1));
|
||||
converter.add_operation(operationx);
|
||||
converter.map_input_socket(get_input_socket(1), operationx->get_input_socket(1));
|
||||
|
||||
GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
|
||||
operationy->setData(data);
|
||||
operationy->setQuality(quality);
|
||||
operationy->checkOpenCL();
|
||||
operationy->setExtendBounds(extend_bounds);
|
||||
operationy->set_data(data);
|
||||
operationy->set_quality(quality);
|
||||
operationy->check_opencl();
|
||||
operationy->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operationy);
|
||||
converter.mapInputSocket(getInputSocket(1), operationy->getInputSocket(1));
|
||||
converter.addLink(operationx->getOutputSocket(), operationy->getInputSocket(0));
|
||||
converter.add_operation(operationy);
|
||||
converter.map_input_socket(get_input_socket(1), operationy->get_input_socket(1));
|
||||
converter.add_link(operationx->get_output_socket(), operationy->get_input_socket(0));
|
||||
|
||||
if (!connectedSizeSocket) {
|
||||
operationx->setSize(size);
|
||||
operationy->setSize(size);
|
||||
if (!connected_size_socket) {
|
||||
operationx->set_size(size);
|
||||
operationy->set_size(size);
|
||||
}
|
||||
|
||||
input_operation = operationx;
|
||||
@@ -135,15 +133,15 @@ void BlurNode::convertToOperations(NodeConverter &converter,
|
||||
}
|
||||
else {
|
||||
GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
|
||||
operation->setData(data);
|
||||
operation->setQuality(quality);
|
||||
operation->setExtendBounds(extend_bounds);
|
||||
operation->set_data(data);
|
||||
operation->set_quality(quality);
|
||||
operation->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
|
||||
if (!connectedSizeSocket) {
|
||||
operation->setSize(size);
|
||||
if (!connected_size_socket) {
|
||||
operation->set_size(size);
|
||||
}
|
||||
|
||||
input_operation = operation;
|
||||
@@ -153,21 +151,21 @@ void BlurNode::convertToOperations(NodeConverter &converter,
|
||||
if (data->gamma) {
|
||||
GammaCorrectOperation *correct = new GammaCorrectOperation();
|
||||
GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
|
||||
converter.addOperation(correct);
|
||||
converter.addOperation(inverse);
|
||||
converter.add_operation(correct);
|
||||
converter.add_operation(inverse);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), correct->getInputSocket(0));
|
||||
converter.addLink(correct->getOutputSocket(), input_operation->getInputSocket(0));
|
||||
converter.addLink(output_operation->getOutputSocket(), inverse->getInputSocket(0));
|
||||
converter.mapOutputSocket(getOutputSocket(), inverse->getOutputSocket());
|
||||
converter.map_input_socket(get_input_socket(0), correct->get_input_socket(0));
|
||||
converter.add_link(correct->get_output_socket(), input_operation->get_input_socket(0));
|
||||
converter.add_link(output_operation->get_output_socket(), inverse->get_input_socket(0));
|
||||
converter.map_output_socket(get_output_socket(), inverse->get_output_socket());
|
||||
|
||||
converter.addPreview(inverse->getOutputSocket());
|
||||
converter.add_preview(inverse->get_output_socket());
|
||||
}
|
||||
else {
|
||||
converter.mapInputSocket(getInputSocket(0), input_operation->getInputSocket(0));
|
||||
converter.mapOutputSocket(getOutputSocket(), output_operation->getOutputSocket());
|
||||
converter.map_input_socket(get_input_socket(0), input_operation->get_input_socket(0));
|
||||
converter.map_output_socket(get_output_socket(), output_operation->get_output_socket());
|
||||
|
||||
converter.addPreview(output_operation->getOutputSocket());
|
||||
converter.add_preview(output_operation->get_output_socket());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class BlurNode : public Node {
|
||||
public:
|
||||
BlurNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
BlurNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,61 +18,56 @@
|
||||
|
||||
#include "COM_BokehBlurNode.h"
|
||||
#include "COM_BokehBlurOperation.h"
|
||||
#include "COM_ConvertDepthToRadiusOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_VariableSizeBokehBlurOperation.h"
|
||||
#include "DNA_camera_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
|
||||
BokehBlurNode::BokehBlurNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void BokehBlurNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
void BokehBlurNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
bNode *b_node = this->getbNode();
|
||||
bNode *b_node = this->get_bnode();
|
||||
|
||||
NodeInput *inputSizeSocket = this->getInputSocket(2);
|
||||
NodeInput *input_size_socket = this->get_input_socket(2);
|
||||
|
||||
bool connectedSizeSocket = inputSizeSocket->isLinked();
|
||||
bool connected_size_socket = input_size_socket->is_linked();
|
||||
const bool extend_bounds = (b_node->custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS) != 0;
|
||||
|
||||
if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connectedSizeSocket) {
|
||||
if ((b_node->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) && connected_size_socket) {
|
||||
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
|
||||
operation->setQuality(context.getQuality());
|
||||
operation->setThreshold(0.0f);
|
||||
operation->setMaxBlur(b_node->custom4);
|
||||
operation->setDoScaleSize(true);
|
||||
operation->set_quality(context.get_quality());
|
||||
operation->set_threshold(0.0f);
|
||||
operation->set_max_blur(b_node->custom4);
|
||||
operation->set_do_scale_size(true);
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
|
||||
}
|
||||
else {
|
||||
BokehBlurOperation *operation = new BokehBlurOperation();
|
||||
operation->setQuality(context.getQuality());
|
||||
operation->setExtendBounds(extend_bounds);
|
||||
operation->set_quality(context.get_quality());
|
||||
operation->set_extend_bounds(extend_bounds);
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.add_operation(operation);
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
|
||||
/* NOTE: on the bokeh blur operation the sockets are switched.
|
||||
* for this reason the next two lines are correct. Fix for T43771. */
|
||||
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(3));
|
||||
converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(2));
|
||||
converter.map_input_socket(get_input_socket(2), operation->get_input_socket(3));
|
||||
converter.map_input_socket(get_input_socket(3), operation->get_input_socket(2));
|
||||
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
|
||||
|
||||
if (!connectedSizeSocket) {
|
||||
operation->setSize(this->getInputSocket(2)->getEditorValueFloat());
|
||||
if (!connected_size_socket) {
|
||||
operation->set_size(this->get_input_socket(2)->get_editor_value_float());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class BokehBlurNode : public Node {
|
||||
public:
|
||||
BokehBlurNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
BokehBlurNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,25 +18,24 @@
|
||||
|
||||
#include "COM_BokehImageNode.h"
|
||||
#include "COM_BokehImageOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
BokehImageNode::BokehImageNode(bNode *editorNode) : Node(editorNode)
|
||||
BokehImageNode::BokehImageNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void BokehImageNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void BokehImageNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
BokehImageOperation *operation = new BokehImageOperation();
|
||||
operation->setData((NodeBokehImage *)this->getbNode()->storage);
|
||||
operation->set_data((NodeBokehImage *)this->get_bnode()->storage);
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
|
||||
converter.add_operation(operation);
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
|
||||
|
||||
converter.addPreview(operation->getOutputSocket(0));
|
||||
converter.add_preview(operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class BokehImageNode : public Node {
|
||||
public:
|
||||
BokehImageNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
BokehImageNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,59 +18,59 @@
|
||||
|
||||
#include "COM_BoxMaskNode.h"
|
||||
#include "COM_BoxMaskOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
#include "COM_ScaleOperation.h"
|
||||
#include "COM_SetValueOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
BoxMaskNode::BoxMaskNode(bNode *editorNode) : Node(editorNode)
|
||||
BoxMaskNode::BoxMaskNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void BoxMaskNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
void BoxMaskNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
NodeInput *inputSocket = this->getInputSocket(0);
|
||||
NodeOutput *outputSocket = this->getOutputSocket(0);
|
||||
NodeInput *input_socket = this->get_input_socket(0);
|
||||
NodeOutput *output_socket = this->get_output_socket(0);
|
||||
|
||||
BoxMaskOperation *operation;
|
||||
operation = new BoxMaskOperation();
|
||||
operation->setData((NodeBoxMask *)this->getbNode()->storage);
|
||||
operation->setMaskType(this->getbNode()->custom1);
|
||||
converter.addOperation(operation);
|
||||
operation->set_data((NodeBoxMask *)this->get_bnode()->storage);
|
||||
operation->set_mask_type(this->get_bnode()->custom1);
|
||||
converter.add_operation(operation);
|
||||
|
||||
if (inputSocket->isLinked()) {
|
||||
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
|
||||
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
|
||||
if (input_socket->is_linked()) {
|
||||
converter.map_input_socket(input_socket, operation->get_input_socket(0));
|
||||
converter.map_output_socket(output_socket, operation->get_output_socket());
|
||||
}
|
||||
else {
|
||||
/* Value operation to produce original transparent image */
|
||||
SetValueOperation *valueOperation = new SetValueOperation();
|
||||
valueOperation->setValue(0.0f);
|
||||
converter.addOperation(valueOperation);
|
||||
SetValueOperation *value_operation = new SetValueOperation();
|
||||
value_operation->set_value(0.0f);
|
||||
converter.add_operation(value_operation);
|
||||
|
||||
/* Scale that image up to render resolution */
|
||||
const RenderData *rd = context.getRenderData();
|
||||
const float render_size_factor = context.getRenderPercentageAsFactor();
|
||||
ScaleFixedSizeOperation *scaleOperation = new ScaleFixedSizeOperation();
|
||||
const RenderData *rd = context.get_render_data();
|
||||
const float render_size_factor = context.get_render_percentage_as_factor();
|
||||
ScaleFixedSizeOperation *scale_operation = new ScaleFixedSizeOperation();
|
||||
|
||||
scaleOperation->setIsAspect(false);
|
||||
scaleOperation->setIsCrop(false);
|
||||
scaleOperation->setOffset(0.0f, 0.0f);
|
||||
scaleOperation->setNewWidth(rd->xsch * render_size_factor);
|
||||
scaleOperation->setNewHeight(rd->ysch * render_size_factor);
|
||||
scaleOperation->getInputSocket(0)->setResizeMode(ResizeMode::Align);
|
||||
converter.addOperation(scaleOperation);
|
||||
scale_operation->set_is_aspect(false);
|
||||
scale_operation->set_is_crop(false);
|
||||
scale_operation->set_offset(0.0f, 0.0f);
|
||||
scale_operation->set_new_width(rd->xsch * render_size_factor);
|
||||
scale_operation->set_new_height(rd->ysch * render_size_factor);
|
||||
scale_operation->get_input_socket(0)->set_resize_mode(ResizeMode::Align);
|
||||
converter.add_operation(scale_operation);
|
||||
|
||||
converter.addLink(valueOperation->getOutputSocket(0), scaleOperation->getInputSocket(0));
|
||||
converter.addLink(scaleOperation->getOutputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
|
||||
converter.add_link(value_operation->get_output_socket(0),
|
||||
scale_operation->get_input_socket(0));
|
||||
converter.add_link(scale_operation->get_output_socket(0), operation->get_input_socket(0));
|
||||
converter.map_output_socket(output_socket, operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class BoxMaskNode : public Node {
|
||||
public:
|
||||
BoxMaskNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
BoxMaskNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,27 +18,26 @@
|
||||
|
||||
#include "COM_BrightnessNode.h"
|
||||
#include "COM_BrightnessOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
BrightnessNode::BrightnessNode(bNode *editorNode) : Node(editorNode)
|
||||
BrightnessNode::BrightnessNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void BrightnessNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void BrightnessNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *bnode = this->getbNode();
|
||||
bNode *bnode = this->get_bnode();
|
||||
BrightnessOperation *operation = new BrightnessOperation();
|
||||
operation->setUsePremultiply((bnode->custom1 & 1) != 0);
|
||||
converter.addOperation(operation);
|
||||
operation->set_use_premultiply((bnode->custom1 & 1) != 0);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class BrightnessNode : public Node {
|
||||
public:
|
||||
BrightnessNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
BrightnessNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,26 +17,25 @@
|
||||
*/
|
||||
|
||||
#include "COM_ChannelMatteNode.h"
|
||||
#include "BKE_node.h"
|
||||
#include "COM_ChannelMatteOperation.h"
|
||||
#include "COM_ConvertOperation.h"
|
||||
#include "COM_SetAlphaMultiplyOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode)
|
||||
ChannelMatteNode::ChannelMatteNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ChannelMatteNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ChannelMatteNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *node = this->getbNode();
|
||||
bNode *node = this->get_bnode();
|
||||
|
||||
NodeInput *inputSocketImage = this->getInputSocket(0);
|
||||
NodeOutput *outputSocketImage = this->getOutputSocket(0);
|
||||
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
|
||||
NodeInput *input_socket_image = this->get_input_socket(0);
|
||||
NodeOutput *output_socket_image = this->get_output_socket(0);
|
||||
NodeOutput *output_socket_matte = this->get_output_socket(1);
|
||||
|
||||
NodeOperation *convert = nullptr, *inv_convert = nullptr;
|
||||
/* colorspace */
|
||||
@@ -53,9 +52,9 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
|
||||
break;
|
||||
case CMP_NODE_CHANNEL_MATTE_CS_YCC: /* YCC */
|
||||
convert = new ConvertRGBToYCCOperation();
|
||||
((ConvertRGBToYCCOperation *)convert)->setMode(BLI_YCC_ITU_BT709);
|
||||
((ConvertRGBToYCCOperation *)convert)->set_mode(BLI_YCC_ITU_BT709);
|
||||
inv_convert = new ConvertYCCToRGBOperation();
|
||||
((ConvertYCCToRGBOperation *)inv_convert)->setMode(BLI_YCC_ITU_BT709);
|
||||
((ConvertYCCToRGBOperation *)inv_convert)->set_mode(BLI_YCC_ITU_BT709);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -63,36 +62,36 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter,
|
||||
|
||||
ChannelMatteOperation *operation = new ChannelMatteOperation();
|
||||
/* pass the ui properties to the operation */
|
||||
operation->setSettings((NodeChroma *)node->storage, node->custom2);
|
||||
converter.addOperation(operation);
|
||||
operation->set_settings((NodeChroma *)node->storage, node->custom2);
|
||||
converter.add_operation(operation);
|
||||
|
||||
SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
|
||||
converter.addOperation(operationAlpha);
|
||||
SetAlphaMultiplyOperation *operation_alpha = new SetAlphaMultiplyOperation();
|
||||
converter.add_operation(operation_alpha);
|
||||
|
||||
if (convert != nullptr) {
|
||||
converter.addOperation(convert);
|
||||
converter.add_operation(convert);
|
||||
|
||||
converter.mapInputSocket(inputSocketImage, convert->getInputSocket(0));
|
||||
converter.addLink(convert->getOutputSocket(), operation->getInputSocket(0));
|
||||
converter.addLink(convert->getOutputSocket(), operationAlpha->getInputSocket(0));
|
||||
converter.map_input_socket(input_socket_image, convert->get_input_socket(0));
|
||||
converter.add_link(convert->get_output_socket(), operation->get_input_socket(0));
|
||||
converter.add_link(convert->get_output_socket(), operation_alpha->get_input_socket(0));
|
||||
}
|
||||
else {
|
||||
converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
|
||||
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
|
||||
converter.map_input_socket(input_socket_image, operation->get_input_socket(0));
|
||||
converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
|
||||
}
|
||||
|
||||
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
|
||||
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
|
||||
converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
|
||||
converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
|
||||
|
||||
if (inv_convert != nullptr) {
|
||||
converter.addOperation(inv_convert);
|
||||
converter.addLink(operationAlpha->getOutputSocket(0), inv_convert->getInputSocket(0));
|
||||
converter.mapOutputSocket(outputSocketImage, inv_convert->getOutputSocket());
|
||||
converter.addPreview(inv_convert->getOutputSocket());
|
||||
converter.add_operation(inv_convert);
|
||||
converter.add_link(operation_alpha->get_output_socket(0), inv_convert->get_input_socket(0));
|
||||
converter.map_output_socket(output_socket_image, inv_convert->get_output_socket());
|
||||
converter.add_preview(inv_convert->get_output_socket());
|
||||
}
|
||||
else {
|
||||
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
|
||||
converter.addPreview(operationAlpha->getOutputSocket());
|
||||
converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
|
||||
converter.add_preview(operation_alpha->get_output_socket());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ChannelMatteNode : public Node {
|
||||
public:
|
||||
ChannelMatteNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ChannelMatteNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,53 +17,52 @@
|
||||
*/
|
||||
|
||||
#include "COM_ChromaMatteNode.h"
|
||||
#include "BKE_node.h"
|
||||
#include "COM_ChromaMatteOperation.h"
|
||||
#include "COM_ConvertOperation.h"
|
||||
#include "COM_SetAlphaMultiplyOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode)
|
||||
ChromaMatteNode::ChromaMatteNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ChromaMatteNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ChromaMatteNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *editorsnode = getbNode();
|
||||
bNode *editorsnode = get_bnode();
|
||||
|
||||
NodeInput *inputSocketImage = this->getInputSocket(0);
|
||||
NodeInput *inputSocketKey = this->getInputSocket(1);
|
||||
NodeOutput *outputSocketImage = this->getOutputSocket(0);
|
||||
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
|
||||
NodeInput *input_socket_image = this->get_input_socket(0);
|
||||
NodeInput *input_socket_key = this->get_input_socket(1);
|
||||
NodeOutput *output_socket_image = this->get_output_socket(0);
|
||||
NodeOutput *output_socket_matte = this->get_output_socket(1);
|
||||
|
||||
ConvertRGBToYCCOperation *operationRGBToYCC_Image = new ConvertRGBToYCCOperation();
|
||||
ConvertRGBToYCCOperation *operationRGBToYCC_Key = new ConvertRGBToYCCOperation();
|
||||
operationRGBToYCC_Image->setMode(BLI_YCC_ITU_BT709);
|
||||
operationRGBToYCC_Key->setMode(BLI_YCC_ITU_BT709);
|
||||
converter.addOperation(operationRGBToYCC_Image);
|
||||
converter.addOperation(operationRGBToYCC_Key);
|
||||
operationRGBToYCC_Image->set_mode(BLI_YCC_ITU_BT709);
|
||||
operationRGBToYCC_Key->set_mode(BLI_YCC_ITU_BT709);
|
||||
converter.add_operation(operationRGBToYCC_Image);
|
||||
converter.add_operation(operationRGBToYCC_Key);
|
||||
|
||||
ChromaMatteOperation *operation = new ChromaMatteOperation();
|
||||
operation->setSettings((NodeChroma *)editorsnode->storage);
|
||||
converter.addOperation(operation);
|
||||
operation->set_settings((NodeChroma *)editorsnode->storage);
|
||||
converter.add_operation(operation);
|
||||
|
||||
SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
|
||||
converter.addOperation(operationAlpha);
|
||||
SetAlphaMultiplyOperation *operation_alpha = new SetAlphaMultiplyOperation();
|
||||
converter.add_operation(operation_alpha);
|
||||
|
||||
converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0));
|
||||
converter.mapInputSocket(inputSocketKey, operationRGBToYCC_Key->getInputSocket(0));
|
||||
converter.addLink(operationRGBToYCC_Image->getOutputSocket(), operation->getInputSocket(0));
|
||||
converter.addLink(operationRGBToYCC_Key->getOutputSocket(), operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket());
|
||||
converter.map_input_socket(input_socket_image, operationRGBToYCC_Image->get_input_socket(0));
|
||||
converter.map_input_socket(input_socket_key, operationRGBToYCC_Key->get_input_socket(0));
|
||||
converter.add_link(operationRGBToYCC_Image->get_output_socket(), operation->get_input_socket(0));
|
||||
converter.add_link(operationRGBToYCC_Key->get_output_socket(), operation->get_input_socket(1));
|
||||
converter.map_output_socket(output_socket_matte, operation->get_output_socket());
|
||||
|
||||
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
|
||||
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
|
||||
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
|
||||
converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
|
||||
converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
|
||||
converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
|
||||
|
||||
converter.addPreview(operationAlpha->getOutputSocket());
|
||||
converter.add_preview(operation_alpha->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ChromaMatteNode : public Node {
|
||||
public:
|
||||
ChromaMatteNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ChromaMatteNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,28 +17,25 @@
|
||||
*/
|
||||
|
||||
#include "COM_ColorBalanceNode.h"
|
||||
#include "BKE_node.h"
|
||||
#include "COM_ColorBalanceASCCDLOperation.h"
|
||||
#include "COM_ColorBalanceLGGOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_MixOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorBalanceNode::ColorBalanceNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorBalanceNode::ColorBalanceNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorBalanceNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorBalanceNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *node = this->getbNode();
|
||||
bNode *node = this->get_bnode();
|
||||
NodeColorBalance *n = (NodeColorBalance *)node->storage;
|
||||
|
||||
NodeInput *inputSocket = this->getInputSocket(0);
|
||||
NodeInput *inputImageSocket = this->getInputSocket(1);
|
||||
NodeOutput *outputSocket = this->getOutputSocket(0);
|
||||
NodeInput *input_socket = this->get_input_socket(0);
|
||||
NodeInput *input_image_socket = this->get_input_socket(1);
|
||||
NodeOutput *output_socket = this->get_output_socket(0);
|
||||
|
||||
NodeOperation *operation;
|
||||
if (node->custom1 == 0) {
|
||||
@@ -50,9 +47,9 @@ void ColorBalanceNode::convertToOperations(NodeConverter &converter,
|
||||
gamma_inv[c] = (n->gamma[c] != 0.0f) ? 1.0f / n->gamma[c] : 1000000.0f;
|
||||
}
|
||||
|
||||
operationLGG->setGain(n->gain);
|
||||
operationLGG->setLift(lift_lgg);
|
||||
operationLGG->setGammaInv(gamma_inv);
|
||||
operationLGG->set_gain(n->gain);
|
||||
operationLGG->set_lift(lift_lgg);
|
||||
operationLGG->set_gamma_inv(gamma_inv);
|
||||
operation = operationLGG;
|
||||
}
|
||||
else {
|
||||
@@ -62,16 +59,16 @@ void ColorBalanceNode::convertToOperations(NodeConverter &converter,
|
||||
copy_v3_fl(offset, n->offset_basis);
|
||||
add_v3_v3(offset, n->offset);
|
||||
|
||||
operationCDL->setOffset(offset);
|
||||
operationCDL->setPower(n->power);
|
||||
operationCDL->setSlope(n->slope);
|
||||
operationCDL->set_offset(offset);
|
||||
operationCDL->set_power(n->power);
|
||||
operationCDL->set_slope(n->slope);
|
||||
operation = operationCDL;
|
||||
}
|
||||
converter.addOperation(operation);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
|
||||
converter.mapInputSocket(inputImageSocket, operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
|
||||
converter.map_input_socket(input_socket, operation->get_input_socket(0));
|
||||
converter.map_input_socket(input_image_socket, operation->get_input_socket(1));
|
||||
converter.map_output_socket(output_socket, operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorBalanceNode : public Node {
|
||||
public:
|
||||
ColorBalanceNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorBalanceNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,30 +18,29 @@
|
||||
|
||||
#include "COM_ColorCorrectionNode.h"
|
||||
#include "COM_ColorCorrectionOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorCorrectionNode::ColorCorrectionNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorCorrectionNode::ColorCorrectionNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorCorrectionNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorCorrectionNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *editorNode = getbNode();
|
||||
bNode *editor_node = get_bnode();
|
||||
|
||||
ColorCorrectionOperation *operation = new ColorCorrectionOperation();
|
||||
operation->setData((NodeColorCorrection *)editorNode->storage);
|
||||
operation->setRedChannelEnabled((editorNode->custom1 & 1) != 0);
|
||||
operation->setGreenChannelEnabled((editorNode->custom1 & 2) != 0);
|
||||
operation->setBlueChannelEnabled((editorNode->custom1 & 4) != 0);
|
||||
converter.addOperation(operation);
|
||||
operation->set_data((NodeColorCorrection *)editor_node->storage);
|
||||
operation->set_red_channel_enabled((editor_node->custom1 & 1) != 0);
|
||||
operation->set_green_channel_enabled((editor_node->custom1 & 2) != 0);
|
||||
operation->set_blue_channel_enabled((editor_node->custom1 & 4) != 0);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorCorrectionNode : public Node {
|
||||
public:
|
||||
ColorCorrectionNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorCorrectionNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,43 +18,42 @@
|
||||
|
||||
#include "COM_ColorCurveNode.h"
|
||||
#include "COM_ColorCurveOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorCurveNode::ColorCurveNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorCurveNode::ColorCurveNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorCurveNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorCurveNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
if (this->getInputSocket(2)->isLinked() || this->getInputSocket(3)->isLinked()) {
|
||||
if (this->get_input_socket(2)->is_linked() || this->get_input_socket(3)->is_linked()) {
|
||||
ColorCurveOperation *operation = new ColorCurveOperation();
|
||||
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
|
||||
converter.addOperation(operation);
|
||||
operation->set_curve_mapping((CurveMapping *)this->get_bnode()->storage);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapInputSocket(getInputSocket(2), operation->getInputSocket(2));
|
||||
converter.mapInputSocket(getInputSocket(3), operation->getInputSocket(3));
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_input_socket(get_input_socket(2), operation->get_input_socket(2));
|
||||
converter.map_input_socket(get_input_socket(3), operation->get_input_socket(3));
|
||||
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
|
||||
}
|
||||
else {
|
||||
ConstantLevelColorCurveOperation *operation = new ConstantLevelColorCurveOperation();
|
||||
float col[4];
|
||||
this->getInputSocket(2)->getEditorValueColor(col);
|
||||
operation->setBlackLevel(col);
|
||||
this->getInputSocket(3)->getEditorValueColor(col);
|
||||
operation->setWhiteLevel(col);
|
||||
operation->setCurveMapping((CurveMapping *)this->getbNode()->storage);
|
||||
converter.addOperation(operation);
|
||||
this->get_input_socket(2)->get_editor_value_color(col);
|
||||
operation->set_black_level(col);
|
||||
this->get_input_socket(3)->get_editor_value_color(col);
|
||||
operation->set_white_level(col);
|
||||
operation->set_curve_mapping((CurveMapping *)this->get_bnode()->storage);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorCurveNode : public Node {
|
||||
public:
|
||||
ColorCurveNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorCurveNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,24 +18,23 @@
|
||||
|
||||
#include "COM_ColorExposureNode.h"
|
||||
#include "COM_ColorExposureOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ExposureNode::ExposureNode(bNode *editorNode) : Node(editorNode)
|
||||
ExposureNode::ExposureNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ExposureNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ExposureNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
ExposureOperation *operation = new ExposureOperation();
|
||||
converter.addOperation(operation);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_input_socket(get_input_socket(1), operation->get_input_socket(1));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ExposureNode : public Node {
|
||||
public:
|
||||
ExposureNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ExposureNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,51 +17,50 @@
|
||||
*/
|
||||
|
||||
#include "COM_ColorMatteNode.h"
|
||||
#include "BKE_node.h"
|
||||
#include "COM_ColorMatteOperation.h"
|
||||
#include "COM_ConvertOperation.h"
|
||||
#include "COM_SetAlphaMultiplyOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorMatteNode::ColorMatteNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorMatteNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorMatteNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *editorsnode = getbNode();
|
||||
bNode *editorsnode = get_bnode();
|
||||
|
||||
NodeInput *inputSocketImage = this->getInputSocket(0);
|
||||
NodeInput *inputSocketKey = this->getInputSocket(1);
|
||||
NodeOutput *outputSocketImage = this->getOutputSocket(0);
|
||||
NodeOutput *outputSocketMatte = this->getOutputSocket(1);
|
||||
NodeInput *input_socket_image = this->get_input_socket(0);
|
||||
NodeInput *input_socket_key = this->get_input_socket(1);
|
||||
NodeOutput *output_socket_image = this->get_output_socket(0);
|
||||
NodeOutput *output_socket_matte = this->get_output_socket(1);
|
||||
|
||||
ConvertRGBToHSVOperation *operationRGBToHSV_Image = new ConvertRGBToHSVOperation();
|
||||
ConvertRGBToHSVOperation *operationRGBToHSV_Key = new ConvertRGBToHSVOperation();
|
||||
converter.addOperation(operationRGBToHSV_Image);
|
||||
converter.addOperation(operationRGBToHSV_Key);
|
||||
converter.add_operation(operationRGBToHSV_Image);
|
||||
converter.add_operation(operationRGBToHSV_Key);
|
||||
|
||||
ColorMatteOperation *operation = new ColorMatteOperation();
|
||||
operation->setSettings((NodeChroma *)editorsnode->storage);
|
||||
converter.addOperation(operation);
|
||||
operation->set_settings((NodeChroma *)editorsnode->storage);
|
||||
converter.add_operation(operation);
|
||||
|
||||
SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation();
|
||||
converter.addOperation(operationAlpha);
|
||||
SetAlphaMultiplyOperation *operation_alpha = new SetAlphaMultiplyOperation();
|
||||
converter.add_operation(operation_alpha);
|
||||
|
||||
converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0));
|
||||
converter.mapInputSocket(inputSocketKey, operationRGBToHSV_Key->getInputSocket(0));
|
||||
converter.addLink(operationRGBToHSV_Image->getOutputSocket(), operation->getInputSocket(0));
|
||||
converter.addLink(operationRGBToHSV_Key->getOutputSocket(), operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(outputSocketMatte, operation->getOutputSocket(0));
|
||||
converter.map_input_socket(input_socket_image, operationRGBToHSV_Image->get_input_socket(0));
|
||||
converter.map_input_socket(input_socket_key, operationRGBToHSV_Key->get_input_socket(0));
|
||||
converter.add_link(operationRGBToHSV_Image->get_output_socket(), operation->get_input_socket(0));
|
||||
converter.add_link(operationRGBToHSV_Key->get_output_socket(), operation->get_input_socket(1));
|
||||
converter.map_output_socket(output_socket_matte, operation->get_output_socket(0));
|
||||
|
||||
converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0));
|
||||
converter.addLink(operation->getOutputSocket(), operationAlpha->getInputSocket(1));
|
||||
converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket());
|
||||
converter.map_input_socket(input_socket_image, operation_alpha->get_input_socket(0));
|
||||
converter.add_link(operation->get_output_socket(), operation_alpha->get_input_socket(1));
|
||||
converter.map_output_socket(output_socket_image, operation_alpha->get_output_socket());
|
||||
|
||||
converter.addPreview(operationAlpha->getOutputSocket());
|
||||
converter.add_preview(operation_alpha->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorMatteNode : public Node {
|
||||
public:
|
||||
ColorMatteNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorMatteNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,27 +17,26 @@
|
||||
*/
|
||||
|
||||
#include "COM_ColorNode.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "COM_SetColorOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorNode::ColorNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorNode::ColorNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
SetColorOperation *operation = new SetColorOperation();
|
||||
NodeOutput *output = this->getOutputSocket(0);
|
||||
NodeOutput *output = this->get_output_socket(0);
|
||||
float col[4];
|
||||
output->getEditorValueColor(col);
|
||||
operation->setChannels(col);
|
||||
converter.addOperation(operation);
|
||||
output->get_editor_value_color(col);
|
||||
operation->set_channels(col);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapOutputSocket(output, operation->getOutputSocket());
|
||||
converter.map_output_socket(output, operation->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorNode : public Node {
|
||||
public:
|
||||
ColorNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,40 +17,37 @@
|
||||
*/
|
||||
|
||||
#include "COM_ColorRampNode.h"
|
||||
#include "BKE_node.h"
|
||||
#include "COM_ColorRampOperation.h"
|
||||
#include "COM_ConvertOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
#include "DNA_texture_types.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorRampNode::ColorRampNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorRampNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorRampNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
NodeInput *inputSocket = this->getInputSocket(0);
|
||||
NodeOutput *outputSocket = this->getOutputSocket(0);
|
||||
NodeOutput *outputSocketAlpha = this->getOutputSocket(1);
|
||||
bNode *editorNode = this->getbNode();
|
||||
NodeInput *input_socket = this->get_input_socket(0);
|
||||
NodeOutput *output_socket = this->get_output_socket(0);
|
||||
NodeOutput *output_socket_alpha = this->get_output_socket(1);
|
||||
bNode *editor_node = this->get_bnode();
|
||||
|
||||
ColorRampOperation *operation = new ColorRampOperation();
|
||||
operation->setColorBand((ColorBand *)editorNode->storage);
|
||||
converter.addOperation(operation);
|
||||
operation->set_color_band((ColorBand *)editor_node->storage);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(inputSocket, operation->getInputSocket(0));
|
||||
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
|
||||
converter.map_input_socket(input_socket, operation->get_input_socket(0));
|
||||
converter.map_output_socket(output_socket, operation->get_output_socket(0));
|
||||
|
||||
SeparateChannelOperation *operation2 = new SeparateChannelOperation();
|
||||
operation2->setChannel(3);
|
||||
converter.addOperation(operation2);
|
||||
operation2->set_channel(3);
|
||||
converter.add_operation(operation2);
|
||||
|
||||
converter.addLink(operation->getOutputSocket(), operation2->getInputSocket(0));
|
||||
converter.mapOutputSocket(outputSocketAlpha, operation2->getOutputSocket());
|
||||
converter.add_link(operation->get_output_socket(), operation2->get_input_socket(0));
|
||||
converter.map_output_socket(output_socket_alpha, operation2->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorRampNode : public Node {
|
||||
public:
|
||||
ColorRampNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorRampNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -17,35 +17,34 @@
|
||||
*/
|
||||
|
||||
#include "COM_ColorSpillNode.h"
|
||||
#include "BKE_node.h"
|
||||
#include "COM_ColorSpillOperation.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorSpillNode::ColorSpillNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorSpillNode::ColorSpillNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorSpillNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorSpillNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
bNode *editorsnode = getbNode();
|
||||
bNode *editorsnode = get_bnode();
|
||||
|
||||
NodeInput *inputSocketImage = this->getInputSocket(0);
|
||||
NodeInput *inputSocketFac = this->getInputSocket(1);
|
||||
NodeOutput *outputSocketImage = this->getOutputSocket(0);
|
||||
NodeInput *input_socket_image = this->get_input_socket(0);
|
||||
NodeInput *input_socket_fac = this->get_input_socket(1);
|
||||
NodeOutput *output_socket_image = this->get_output_socket(0);
|
||||
|
||||
ColorSpillOperation *operation;
|
||||
operation = new ColorSpillOperation();
|
||||
operation->setSettings((NodeColorspill *)editorsnode->storage);
|
||||
operation->setSpillChannel(editorsnode->custom1 - 1); /* Channel for spilling */
|
||||
operation->setSpillMethod(editorsnode->custom2); /* Channel method */
|
||||
converter.addOperation(operation);
|
||||
operation->set_settings((NodeColorspill *)editorsnode->storage);
|
||||
operation->set_spill_channel(editorsnode->custom1 - 1); /* Channel for spilling */
|
||||
operation->set_spill_method(editorsnode->custom2); /* Channel method */
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(inputSocketImage, operation->getInputSocket(0));
|
||||
converter.mapInputSocket(inputSocketFac, operation->getInputSocket(1));
|
||||
converter.mapOutputSocket(outputSocketImage, operation->getOutputSocket());
|
||||
converter.map_input_socket(input_socket_image, operation->get_input_socket(0));
|
||||
converter.map_input_socket(input_socket_fac, operation->get_input_socket(1));
|
||||
converter.map_output_socket(output_socket_image, operation->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,9 +28,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorSpillNode : public Node {
|
||||
public:
|
||||
ColorSpillNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorSpillNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -19,26 +19,25 @@
|
||||
#include "COM_ColorToBWNode.h"
|
||||
|
||||
#include "COM_ConvertOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode)
|
||||
ColorToBWNode::ColorToBWNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void ColorToBWNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ColorToBWNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
NodeInput *colorSocket = this->getInputSocket(0);
|
||||
NodeOutput *valueSocket = this->getOutputSocket(0);
|
||||
NodeInput *color_socket = this->get_input_socket(0);
|
||||
NodeOutput *value_socket = this->get_output_socket(0);
|
||||
|
||||
ConvertColorToBWOperation *convertProg = new ConvertColorToBWOperation();
|
||||
converter.addOperation(convertProg);
|
||||
ConvertColorToBWOperation *convert_prog = new ConvertColorToBWOperation();
|
||||
converter.add_operation(convert_prog);
|
||||
|
||||
converter.mapInputSocket(colorSocket, convertProg->getInputSocket(0));
|
||||
converter.mapOutputSocket(valueSocket, convertProg->getOutputSocket(0));
|
||||
converter.map_input_socket(color_socket, convert_prog->get_input_socket(0));
|
||||
converter.map_output_socket(value_socket, convert_prog->get_output_socket(0));
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -29,9 +29,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ColorToBWNode : public Node {
|
||||
public:
|
||||
ColorToBWNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
ColorToBWNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -22,70 +22,70 @@
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
CombineColorNode::CombineColorNode(bNode *editorNode) : Node(editorNode)
|
||||
CombineColorNode::CombineColorNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
}
|
||||
|
||||
void CombineColorNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
void CombineColorNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
NodeInput *inputRSocket = this->getInputSocket(0);
|
||||
NodeInput *inputGSocket = this->getInputSocket(1);
|
||||
NodeInput *inputBSocket = this->getInputSocket(2);
|
||||
NodeInput *inputASocket = this->getInputSocket(3);
|
||||
NodeOutput *outputSocket = this->getOutputSocket(0);
|
||||
NodeInput *input_rsocket = this->get_input_socket(0);
|
||||
NodeInput *input_gsocket = this->get_input_socket(1);
|
||||
NodeInput *input_bsocket = this->get_input_socket(2);
|
||||
NodeInput *input_asocket = this->get_input_socket(3);
|
||||
NodeOutput *output_socket = this->get_output_socket(0);
|
||||
|
||||
CombineChannelsOperation *operation = new CombineChannelsOperation();
|
||||
if (inputRSocket->isLinked()) {
|
||||
if (input_rsocket->is_linked()) {
|
||||
operation->set_canvas_input_index(0);
|
||||
}
|
||||
else if (inputGSocket->isLinked()) {
|
||||
else if (input_gsocket->is_linked()) {
|
||||
operation->set_canvas_input_index(1);
|
||||
}
|
||||
else if (inputBSocket->isLinked()) {
|
||||
else if (input_bsocket->is_linked()) {
|
||||
operation->set_canvas_input_index(2);
|
||||
}
|
||||
else {
|
||||
operation->set_canvas_input_index(3);
|
||||
}
|
||||
converter.addOperation(operation);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(inputRSocket, operation->getInputSocket(0));
|
||||
converter.mapInputSocket(inputGSocket, operation->getInputSocket(1));
|
||||
converter.mapInputSocket(inputBSocket, operation->getInputSocket(2));
|
||||
converter.mapInputSocket(inputASocket, operation->getInputSocket(3));
|
||||
converter.map_input_socket(input_rsocket, operation->get_input_socket(0));
|
||||
converter.map_input_socket(input_gsocket, operation->get_input_socket(1));
|
||||
converter.map_input_socket(input_bsocket, operation->get_input_socket(2));
|
||||
converter.map_input_socket(input_asocket, operation->get_input_socket(3));
|
||||
|
||||
NodeOperation *color_conv = getColorConverter(context);
|
||||
NodeOperation *color_conv = get_color_converter(context);
|
||||
if (color_conv) {
|
||||
converter.addOperation(color_conv);
|
||||
converter.add_operation(color_conv);
|
||||
|
||||
converter.addLink(operation->getOutputSocket(), color_conv->getInputSocket(0));
|
||||
converter.mapOutputSocket(outputSocket, color_conv->getOutputSocket());
|
||||
converter.add_link(operation->get_output_socket(), color_conv->get_input_socket(0));
|
||||
converter.map_output_socket(output_socket, color_conv->get_output_socket());
|
||||
}
|
||||
else {
|
||||
converter.mapOutputSocket(outputSocket, operation->getOutputSocket());
|
||||
converter.map_output_socket(output_socket, operation->get_output_socket());
|
||||
}
|
||||
}
|
||||
|
||||
NodeOperation *CombineRGBANode::getColorConverter(const CompositorContext & /*context*/) const
|
||||
NodeOperation *CombineRGBANode::get_color_converter(const CompositorContext & /*context*/) const
|
||||
{
|
||||
return nullptr; /* no conversion needed */
|
||||
}
|
||||
|
||||
NodeOperation *CombineHSVANode::getColorConverter(const CompositorContext & /*context*/) const
|
||||
NodeOperation *CombineHSVANode::get_color_converter(const CompositorContext & /*context*/) const
|
||||
{
|
||||
return new ConvertHSVToRGBOperation();
|
||||
}
|
||||
|
||||
NodeOperation *CombineYCCANode::getColorConverter(const CompositorContext & /*context*/) const
|
||||
NodeOperation *CombineYCCANode::get_color_converter(const CompositorContext & /*context*/) const
|
||||
{
|
||||
ConvertYCCToRGBOperation *operation = new ConvertYCCToRGBOperation();
|
||||
bNode *editorNode = this->getbNode();
|
||||
operation->setMode(editorNode->custom1);
|
||||
bNode *editor_node = this->get_bnode();
|
||||
operation->set_mode(editor_node->custom1);
|
||||
return operation;
|
||||
}
|
||||
|
||||
NodeOperation *CombineYUVANode::getColorConverter(const CompositorContext & /*context*/) const
|
||||
NodeOperation *CombineYUVANode::get_color_converter(const CompositorContext & /*context*/) const
|
||||
{
|
||||
return new ConvertYUVToRGBOperation();
|
||||
}
|
||||
|
@@ -24,48 +24,48 @@ namespace blender::compositor {
|
||||
|
||||
class CombineColorNode : public Node {
|
||||
public:
|
||||
CombineColorNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
CombineColorNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
|
||||
protected:
|
||||
virtual NodeOperation *getColorConverter(const CompositorContext &context) const = 0;
|
||||
virtual NodeOperation *get_color_converter(const CompositorContext &context) const = 0;
|
||||
};
|
||||
|
||||
class CombineRGBANode : public CombineColorNode {
|
||||
public:
|
||||
CombineRGBANode(bNode *editorNode) : CombineColorNode(editorNode)
|
||||
CombineRGBANode(bNode *editor_node) : CombineColorNode(editor_node)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOperation *getColorConverter(const CompositorContext &context) const override;
|
||||
NodeOperation *get_color_converter(const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
class CombineHSVANode : public CombineColorNode {
|
||||
public:
|
||||
CombineHSVANode(bNode *editorNode) : CombineColorNode(editorNode)
|
||||
CombineHSVANode(bNode *editor_node) : CombineColorNode(editor_node)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOperation *getColorConverter(const CompositorContext &context) const override;
|
||||
NodeOperation *get_color_converter(const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
class CombineYCCANode : public CombineColorNode {
|
||||
public:
|
||||
CombineYCCANode(bNode *editorNode) : CombineColorNode(editorNode)
|
||||
CombineYCCANode(bNode *editor_node) : CombineColorNode(editor_node)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOperation *getColorConverter(const CompositorContext &context) const override;
|
||||
NodeOperation *get_color_converter(const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
class CombineYUVANode : public CombineColorNode {
|
||||
public:
|
||||
CombineYUVANode(bNode *editorNode) : CombineColorNode(editorNode)
|
||||
CombineYUVANode(bNode *editor_node) : CombineColorNode(editor_node)
|
||||
{
|
||||
}
|
||||
|
||||
NodeOperation *getColorConverter(const CompositorContext &context) const override;
|
||||
NodeOperation *get_color_converter(const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,48 +18,47 @@
|
||||
|
||||
#include "COM_CompositorNode.h"
|
||||
#include "COM_CompositorOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
CompositorNode::CompositorNode(bNode *editorNode) : Node(editorNode)
|
||||
CompositorNode::CompositorNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
/* pass */
|
||||
}
|
||||
|
||||
void CompositorNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
void CompositorNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const
|
||||
{
|
||||
bNode *editorNode = this->getbNode();
|
||||
bool is_active = (editorNode->flag & NODE_DO_OUTPUT_RECALC) || context.isRendering();
|
||||
bool ignore_alpha = (editorNode->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
|
||||
bNode *editor_node = this->get_bnode();
|
||||
bool is_active = (editor_node->flag & NODE_DO_OUTPUT_RECALC) || context.is_rendering();
|
||||
bool ignore_alpha = (editor_node->custom2 & CMP_NODE_OUTPUT_IGNORE_ALPHA) != 0;
|
||||
|
||||
NodeInput *imageSocket = this->getInputSocket(0);
|
||||
NodeInput *alphaSocket = this->getInputSocket(1);
|
||||
NodeInput *depthSocket = this->getInputSocket(2);
|
||||
NodeInput *image_socket = this->get_input_socket(0);
|
||||
NodeInput *alpha_socket = this->get_input_socket(1);
|
||||
NodeInput *depth_socket = this->get_input_socket(2);
|
||||
|
||||
CompositorOperation *compositorOperation = new CompositorOperation();
|
||||
compositorOperation->setScene(context.getScene());
|
||||
compositorOperation->setSceneName(context.getScene()->id.name);
|
||||
compositorOperation->setRenderData(context.getRenderData());
|
||||
compositorOperation->setViewName(context.getViewName());
|
||||
compositorOperation->setbNodeTree(context.getbNodeTree());
|
||||
CompositorOperation *compositor_operation = new CompositorOperation();
|
||||
compositor_operation->set_scene(context.get_scene());
|
||||
compositor_operation->set_scene_name(context.get_scene()->id.name);
|
||||
compositor_operation->set_render_data(context.get_render_data());
|
||||
compositor_operation->set_view_name(context.get_view_name());
|
||||
compositor_operation->set_bnodetree(context.get_bnodetree());
|
||||
/* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */
|
||||
compositorOperation->setUseAlphaInput(ignore_alpha || alphaSocket->isLinked());
|
||||
compositorOperation->setActive(is_active);
|
||||
compositor_operation->set_use_alpha_input(ignore_alpha || alpha_socket->is_linked());
|
||||
compositor_operation->set_active(is_active);
|
||||
|
||||
converter.addOperation(compositorOperation);
|
||||
converter.mapInputSocket(imageSocket, compositorOperation->getInputSocket(0));
|
||||
converter.add_operation(compositor_operation);
|
||||
converter.map_input_socket(image_socket, compositor_operation->get_input_socket(0));
|
||||
/* only use alpha link if "use alpha" is enabled */
|
||||
if (ignore_alpha) {
|
||||
converter.addInputValue(compositorOperation->getInputSocket(1), 1.0f);
|
||||
converter.add_input_value(compositor_operation->get_input_socket(1), 1.0f);
|
||||
}
|
||||
else {
|
||||
converter.mapInputSocket(alphaSocket, compositorOperation->getInputSocket(1));
|
||||
converter.map_input_socket(alpha_socket, compositor_operation->get_input_socket(1));
|
||||
}
|
||||
converter.mapInputSocket(depthSocket, compositorOperation->getInputSocket(2));
|
||||
converter.map_input_socket(depth_socket, compositor_operation->get_input_socket(2));
|
||||
|
||||
converter.addNodeInputPreview(imageSocket);
|
||||
converter.add_node_input_preview(image_socket);
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -29,9 +29,9 @@ namespace blender::compositor {
|
||||
*/
|
||||
class CompositorNode : public Node {
|
||||
public:
|
||||
CompositorNode(bNode *editorNode);
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
CompositorNode(bNode *editor_node);
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -18,15 +18,14 @@
|
||||
|
||||
#include "COM_ConvertAlphaNode.h"
|
||||
#include "COM_ConvertOperation.h"
|
||||
#include "COM_ExecutionSystem.h"
|
||||
|
||||
namespace blender::compositor {
|
||||
|
||||
void ConvertAlphaNode::convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
void ConvertAlphaNode::convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext & /*context*/) const
|
||||
{
|
||||
NodeOperation *operation = nullptr;
|
||||
bNode *node = this->getbNode();
|
||||
bNode *node = this->get_bnode();
|
||||
|
||||
/* value hardcoded in rna_nodetree.c */
|
||||
if (node->custom1 == 1) {
|
||||
@@ -36,10 +35,10 @@ void ConvertAlphaNode::convertToOperations(NodeConverter &converter,
|
||||
operation = new ConvertStraightToPremulOperation();
|
||||
}
|
||||
|
||||
converter.addOperation(operation);
|
||||
converter.add_operation(operation);
|
||||
|
||||
converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
|
||||
converter.map_input_socket(get_input_socket(0), operation->get_input_socket(0));
|
||||
converter.map_output_socket(get_output_socket(0), operation->get_output_socket());
|
||||
}
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
@@ -28,11 +28,11 @@ namespace blender::compositor {
|
||||
*/
|
||||
class ConvertAlphaNode : public Node {
|
||||
public:
|
||||
ConvertAlphaNode(bNode *editorNode) : Node(editorNode)
|
||||
ConvertAlphaNode(bNode *editor_node) : Node(editor_node)
|
||||
{
|
||||
}
|
||||
void convertToOperations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
void convert_to_operations(NodeConverter &converter,
|
||||
const CompositorContext &context) const override;
|
||||
};
|
||||
|
||||
} // namespace blender::compositor
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user