Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OpenGL support handling for plugins with dynamic GL support. #869

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Engine/EffectInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -1322,11 +1322,6 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON
return ePluginOpenGLRenderSupportNone;
}

virtual void onEnableOpenGLKnobValueChanged(bool /*activated*/)
{

}

/**
* @brief If this effect is a writer then the file path corresponding to the output images path will be fed
* with the content of pattern.
Expand Down
34 changes: 7 additions & 27 deletions Engine/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5017,18 +5017,7 @@ Node::onEffectKnobValueChanged(KnobI* what,
ssinfo << "</font>";
_imp->nodeInfos.lock()->setValue( ssinfo.str() );
} else if ( what == _imp->openglRenderingEnabledKnob.lock().get() ) {
bool enabled = true;
int thisKnobIndex = _imp->openglRenderingEnabledKnob.lock()->getValue();
if (thisKnobIndex == 1 || (thisKnobIndex == 2 && getApp()->isBackground())) {
enabled = false;
}
if (enabled) {
// Check value on project now
if (!getApp()->getProject()->isOpenGLRenderActivated()) {
enabled = false;
}
}
_imp->effect->onEnableOpenGLKnobValueChanged(enabled);
// Do nothing. Knob value will be checked in getCurrentOpenGLRenderSupport() calls.
} else if (what == _imp->processAllLayersKnob.lock().get() ) {

std::map<int, ChannelSelector>::iterator foundOutput = _imp->channelsSelectors.find(-1);
Expand Down Expand Up @@ -5098,23 +5087,14 @@ Node::onEffectKnobValueChanged(KnobI* what,
void
Node::onOpenGLEnabledKnobChangedOnProject(bool activated)
{
bool enabled = activated;
KnobChoicePtr k = _imp->openglRenderingEnabledKnob.lock();
if (enabled) {
if (k) {
k->setAllDimensionsEnabled(true);
int thisKnobIndex = k->getValue();
if (thisKnobIndex == 1 || (thisKnobIndex == 2 && getApp()->isBackground())) {
enabled = false;
}
}
} else {
if (k) {
k->setAllDimensionsEnabled(true);
}
if (k) {
// Make the enable state for the node knob match the
// state of the project level GPU rendering state.
// This makes it so you can't change node level GPU
// rendering state if the project has GPU rendering disabled.
k->setAllDimensionsEnabled(activated);
}
_imp->effect->onEnableOpenGLKnobValueChanged(enabled);

}

bool
Expand Down
2 changes: 1 addition & 1 deletion Engine/NodeMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Node::load(const CreateNodeArgs& args)
Set modifiable props
*/
refreshDynamicProperties();
onOpenGLEnabledKnobChangedOnProject(getApp()->getProject()->isOpenGLRenderActivated());
onOpenGLEnabledKnobChangedOnProject(getApp()->getProject()->isGPURenderingEnabledInProject());

if ( isTrackerNodePlugin() ) {
_imp->isMultiInstance = true;
Expand Down
14 changes: 0 additions & 14 deletions Engine/OfxEffectInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2756,20 +2756,6 @@ OfxEffectInstance::supportsOpenGLRender() const
}
}

void
OfxEffectInstance::onEnableOpenGLKnobValueChanged(bool activated)
{
const Plugin* p = getNode()->getPlugin();
if (p->getPluginOpenGLRenderSupport() == ePluginOpenGLRenderSupportYes) {
// The property may only change if the plug-in has the property set to yes on the descriptor
if (activated) {
effectInstance()->getProps().setStringProperty(kOfxImageEffectPropOpenGLRenderSupported, "true");
} else {
effectInstance()->getProps().setStringProperty(kOfxImageEffectPropOpenGLRenderSupported, "false");
}
}
}

bool
OfxEffectInstance::supportsMultiResolution() const
{
Expand Down
1 change: 0 additions & 1 deletion Engine/OfxEffectInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON
Transform::Matrix3x3* transform) OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isHostMaskingEnabled() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual bool isHostMixingEnabled() const OVERRIDE FINAL WARN_UNUSED_RETURN;
virtual void onEnableOpenGLKnobValueChanged(bool activated) OVERRIDE FINAL;

/********OVERRIDDEN FROM EFFECT INSTANCE: END*************/
OfxClipInstance* getClipCorrespondingToInput(int inputNo) const;
Expand Down
25 changes: 4 additions & 21 deletions Engine/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,7 @@ Project::initializeKnobs()
_imp->gpuSupport->setAnimationEnabled(false);
_imp->gpuSupport->setHintToolTip( tr("Select when to activate GPU rendering for plug-ins. Note that if the OpenGL Rendering parameter in the Preferences/GPU Rendering is set to disabled then GPU rendering will not be activated regardless of that value.") );
_imp->gpuSupport->setEvaluateOnChange(false);
if (!appPTR->getCurrentSettings()->isOpenGLRenderingEnabled()) {
_imp->gpuSupport->setAllDimensionsEnabled(false);
}
_imp->gpuSupport->setAllDimensionsEnabled(appPTR->getCurrentSettings()->isOpenGLRenderingEnabled());
page->addKnob(_imp->gpuSupport);

KnobPagePtr viewsPage = AppManager::createKnob<KnobPage>( this, tr("Views") );
Expand Down Expand Up @@ -1210,16 +1208,6 @@ Project::getProjectFormatAtIndex(int index,
return _imp->findFormat(index, f);
}

bool
Project::isOpenGLRenderActivated() const
{
if (!appPTR->getCurrentSettings()->isOpenGLRenderingEnabled()) {
return false;
}
int index = _imp->gpuSupport->getValue();
return index == 0 || (index == 2 && !getApp()->isBackground());
}

int
Project::currentFrame() const
{
Expand Down Expand Up @@ -1740,14 +1728,9 @@ Project::onKnobValueChanged(KnobI* knob,
void
Project::refreshOpenGLRenderingFlagOnNodes()
{
bool activated = appPTR->getCurrentSettings()->isOpenGLRenderingEnabled();
if (!activated) {
_imp->gpuSupport->setAllDimensionsEnabled(false);
} else {
_imp->gpuSupport->setAllDimensionsEnabled(true);
int index = _imp->gpuSupport->getValue();
activated = index == 0 || (index == 2 && !getApp()->isBackground());
}
_imp->gpuSupport->setAllDimensionsEnabled(appPTR->getCurrentSettings()->isOpenGLRenderingEnabled());

const bool activated = isGPURenderingEnabledInProject();
NodesList allNodes;
getNodes_recursive(allNodes, false);
for (NodesList::iterator it = allNodes.begin(); it!=allNodes.end(); ++it) {
Expand Down
2 changes: 0 additions & 2 deletions Engine/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON
**/
bool quitAnyProcessingForAllNodes(AfterQuitProcessingI* receiver, const GenericWatcherCallerArgsPtr& args);

bool isOpenGLRenderActivated() const;

void refreshOpenGLRenderingFlagOnNodes();

private:
Expand Down