Add diagnostics and robust direction reading for OCIO LUT node

- Introduce ReadDirectionInput() helper that accepts both integer and
  string ('Forward'/'Inverse') representations of the direction combo.
- Log every processor creation with the raw direction value and the OCIO
  transform direction being used, along with whether it is main or worker.
- This helps determine why Forward/Inverse switching reportedly has no
  effect in the viewer/worker.

Tests still pass.
This commit is contained in:
2026-07-13 10:19:30 +08:00
parent f131abc5f7
commit e52570c89f
+34 -6
View File
@@ -50,6 +50,29 @@ bool IsMainProcess()
return qobject_cast<QApplication *>(QCoreApplication::instance()) != nullptr; return qobject_cast<QApplication *>(QCoreApplication::instance()) != nullptr;
} }
int ReadDirectionInput(const Node *node)
{
QVariant v = node->GetStandardValue(OCIOLutNode::kDirectionInput);
bool ok = false;
int direction = v.toInt(&ok);
if (ok) {
return direction;
}
// Some old serializers stored the combo value as a string.
const QString s = v.toString().toLower();
if (s == QStringLiteral("forward") || s == QStringLiteral("0")) {
return 0;
}
if (s == QStringLiteral("inverse") || s == QStringLiteral("1")) {
return 1;
}
qWarning() << "OCIOLutNode: unexpected direction value" << v;
return 0;
}
} // namespace } // namespace
OCIOLutNode::OCIOLutNode() OCIOLutNode::OCIOLutNode()
@@ -162,7 +185,7 @@ void OCIOLutNode::EnsureProcessor() const
if (!processor_dirty_ && last_processor_ && if (!processor_dirty_ && last_processor_ &&
GetStandardValue(kFileInput).toString() == last_path_ && GetStandardValue(kFileInput).toString() == last_path_ &&
GetStandardValue(kDirectionInput).toInt() == last_direction_) { ReadDirectionInput(this) == last_direction_) {
return; return;
} }
@@ -181,7 +204,7 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
} }
const QString path = GetStandardValue(kFileInput).toString(); const QString path = GetStandardValue(kFileInput).toString();
const int direction = GetStandardValue(kDirectionInput).toInt(); const int direction = ReadDirectionInput(this);
if (path.isEmpty()) { if (path.isEmpty()) {
const_cast<OCIOLutNode *>(this)->set_processor(nullptr); const_cast<OCIOLutNode *>(this)->set_processor(nullptr);
@@ -222,14 +245,19 @@ bool OCIOLutNode::CreateProcessorFromInputs() const
ColorProcessorPtr processor; ColorProcessorPtr processor;
try { try {
const bool forward =
static_cast<ColorProcessor::Direction>(direction) ==
ColorProcessor::kNormal;
qDebug() << "OCIOLutNode: creating processor for" << path
<< "direction=" << direction
<< "ocio_dir=" << (forward ? "FORWARD" : "INVERSE")
<< "process=" << (IsMainProcess() ? "main" : "worker");
OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create(); OCIO::FileTransformRcPtr transform = OCIO::FileTransform::Create();
transform->setSrc(path.toUtf8().constData()); transform->setSrc(path.toUtf8().constData());
transform->setInterpolation(OCIO::INTERP_LINEAR); transform->setInterpolation(OCIO::INTERP_LINEAR);
transform->setDirection( transform->setDirection(
static_cast<ColorProcessor::Direction>(direction) == forward ? OCIO::TRANSFORM_DIR_FORWARD : OCIO::TRANSFORM_DIR_INVERSE);
ColorProcessor::kNormal
? OCIO::TRANSFORM_DIR_FORWARD
: OCIO::TRANSFORM_DIR_INVERSE);
processor = ColorProcessor::Create(manager()->GetConfig()->getProcessor(transform)); processor = ColorProcessor::Create(manager()->GetConfig()->getProcessor(transform));
} catch (const std::exception &e) { } catch (const std::exception &e) {