Compositor: Fix convert resolutions linking different socket datatypes

Link sockets are always connected to inserted translate or scale
operation `Color` sockets even when they have different data type.
This causes crashes on full frame mode when operations read inputs 
with non expected datatypes.

Because data type conversions need to be executed before, convert
resolutions must ensure same datatypes are linked.
This commit is contained in:
Manuel Castilla 2021-07-13 15:46:32 +02:00
parent 3b6ee8cee7
commit 209aff0a35
5 changed files with 20 additions and 8 deletions

View File

@ -460,6 +460,9 @@ void COM_convert_resolution(NodeOperationBuilder &builder,
NodeOperationOutput *fromSocket,
NodeOperationInput *toSocket)
{
/* 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());
ResizeMode mode = toSocket->getResizeMode();
NodeOperation *toOperation = &toSocket->getOperation();
@ -515,7 +518,7 @@ void COM_convert_resolution(NodeOperationBuilder &builder,
NodeOperation *first = nullptr;
ScaleOperation *scaleOperation = nullptr;
if (doScale) {
scaleOperation = new ScaleOperation();
scaleOperation = new ScaleOperation(fromSocket->getDataType());
scaleOperation->getInputSocket(1)->setResizeMode(ResizeMode::None);
scaleOperation->getInputSocket(2)->setResizeMode(ResizeMode::None);
first = scaleOperation;
@ -535,7 +538,7 @@ void COM_convert_resolution(NodeOperationBuilder &builder,
builder.addOperation(scaleOperation);
}
TranslateOperation *translateOperation = new TranslateOperation();
TranslateOperation *translateOperation = new TranslateOperation(toSocket->getDataType());
translateOperation->getInputSocket(1)->setResizeMode(ResizeMode::None);
translateOperation->getInputSocket(2)->setResizeMode(ResizeMode::None);
if (!first) {

View File

@ -37,12 +37,16 @@ BaseScaleOperation::BaseScaleOperation()
m_variable_size = false;
}
ScaleOperation::ScaleOperation() : BaseScaleOperation()
ScaleOperation::ScaleOperation() : ScaleOperation(DataType::Color)
{
this->addInputSocket(DataType::Color);
}
ScaleOperation::ScaleOperation(DataType data_type) : BaseScaleOperation()
{
this->addInputSocket(data_type);
this->addInputSocket(DataType::Value);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Color);
this->addOutputSocket(data_type);
this->setResolutionInputSocketIndex(0);
this->m_inputOperation = nullptr;
this->m_inputXOperation = nullptr;

View File

@ -55,6 +55,7 @@ class ScaleOperation : public BaseScaleOperation {
public:
ScaleOperation();
ScaleOperation(DataType data_type);
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;

View File

@ -20,12 +20,15 @@
namespace blender::compositor {
TranslateOperation::TranslateOperation()
TranslateOperation::TranslateOperation() : TranslateOperation(DataType::Color)
{
this->addInputSocket(DataType::Color);
}
TranslateOperation::TranslateOperation(DataType data_type)
{
this->addInputSocket(data_type);
this->addInputSocket(DataType::Value);
this->addInputSocket(DataType::Value);
this->addOutputSocket(DataType::Color);
this->addOutputSocket(data_type);
this->setResolutionInputSocketIndex(0);
this->m_inputOperation = nullptr;
this->m_inputXOperation = nullptr;

View File

@ -35,6 +35,7 @@ class TranslateOperation : public NodeOperation {
public:
TranslateOperation();
TranslateOperation(DataType data_type);
bool determineDependingAreaOfInterest(rcti *input,
ReadBufferOperation *readOperation,
rcti *output) override;