Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/operations/COM_DenoiseOperation.cc
| Show All 22 Lines | |||||
| # include "BLI_threads.h" | # include "BLI_threads.h" | ||||
| # include <OpenImageDenoise/oidn.hpp> | # include <OpenImageDenoise/oidn.hpp> | ||||
| static pthread_mutex_t oidn_lock = BLI_MUTEX_INITIALIZER; | static pthread_mutex_t oidn_lock = BLI_MUTEX_INITIALIZER; | ||||
| #endif | #endif | ||||
| #include <iostream> | #include <iostream> | ||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| DenoiseOperation::DenoiseOperation() | DenoiseOperation::DenoiseOperation() : SingleThreadedOperation(DataType::Color) | ||||
| { | { | ||||
| this->addInputSocket(DataType::Color); | this->addInputSocket(DataType::Color); | ||||
| this->addInputSocket(DataType::Vector); | this->addInputSocket(DataType::Vector); | ||||
| this->addInputSocket(DataType::Color); | this->addInputSocket(DataType::Color); | ||||
| this->addOutputSocket(DataType::Color); | this->addOutputSocket(DataType::Color); | ||||
| this->m_settings = nullptr; | this->m_settings = nullptr; | ||||
| } | } | ||||
| void DenoiseOperation::initExecution() | void DenoiseOperation::initExecution() | ||||
| { | { | ||||
| SingleThreadedOperation::initExecution(); | SingleThreadedOperation::initExecution(); | ||||
| this->m_inputProgramColor = getInputSocketReader(0); | this->m_inputProgramColor = getInputSocketReader(0); | ||||
| this->m_inputProgramNormal = getInputSocketReader(1); | this->m_inputProgramNormal = getInputSocketReader(1); | ||||
| this->m_inputProgramAlbedo = getInputSocketReader(2); | this->m_inputProgramAlbedo = getInputSocketReader(2); | ||||
| } | } | ||||
| void DenoiseOperation::deinitExecution() | void DenoiseOperation::deinitExecution() | ||||
| { | { | ||||
| this->m_inputProgramColor = nullptr; | this->m_inputProgramColor = nullptr; | ||||
| this->m_inputProgramNormal = nullptr; | this->m_inputProgramNormal = nullptr; | ||||
| this->m_inputProgramAlbedo = nullptr; | this->m_inputProgramAlbedo = nullptr; | ||||
| SingleThreadedOperation::deinitExecution(); | SingleThreadedOperation::deinitExecution(); | ||||
| } | } | ||||
| MemoryBuffer *DenoiseOperation::createMemoryBuffer(rcti *rect2) | void DenoiseOperation::update_memory_buffer(MemoryBuffer *output_buffer, | ||||
| { | rcti *output_rect, | ||||
| MemoryBuffer *tileColor = (MemoryBuffer *)this->m_inputProgramColor->initializeTileData(rect2); | blender::Span<MemoryBuffer *> inputs) | ||||
| MemoryBuffer *tileNormal = (MemoryBuffer *)this->m_inputProgramNormal->initializeTileData(rect2); | { | ||||
| MemoryBuffer *tileAlbedo = (MemoryBuffer *)this->m_inputProgramAlbedo->initializeTileData(rect2); | MemoryBuffer *tileColor = inputs[0]; | ||||
| rcti rect; | MemoryBuffer *tileNormal = inputs[1]; | ||||
| rect.xmin = 0; | MemoryBuffer *tileAlbedo = inputs[2]; | ||||
| rect.ymin = 0; | this->generateDenoise( | ||||
| rect.xmax = getWidth(); | output_buffer->getBuffer(), tileColor, tileNormal, tileAlbedo, this->m_settings); | ||||
| rect.ymax = getHeight(); | |||||
| MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect); | |||||
| float *data = result->getBuffer(); | |||||
| this->generateDenoise(data, tileColor, tileNormal, tileAlbedo, this->m_settings); | |||||
| return result; | |||||
| } | } | ||||
| bool DenoiseOperation::determineDependingAreaOfInterest(rcti * /*input*/, | bool DenoiseOperation::determineDependingAreaOfInterest(rcti * /*input*/, | ||||
| ReadBufferOperation *readOperation, | ReadBufferOperation *readOperation, | ||||
| rcti *output) | rcti *output) | ||||
| { | { | ||||
| if (isCached()) { | |||||
| return false; | |||||
| } | |||||
| rcti newInput; | rcti newInput; | ||||
| newInput.xmax = this->getWidth(); | newInput.xmax = this->getWidth(); | ||||
| newInput.xmin = 0; | newInput.xmin = 0; | ||||
| newInput.ymax = this->getHeight(); | newInput.ymax = this->getHeight(); | ||||
| newInput.ymin = 0; | newInput.ymin = 0; | ||||
| return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); | return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||