diff --git a/HostSupport/examples/hostDemoEffectInstance.cpp b/HostSupport/examples/hostDemoEffectInstance.cpp index db8652f04..d253fd6b3 100755 --- a/HostSupport/examples/hostDemoEffectInstance.cpp +++ b/HostSupport/examples/hostDemoEffectInstance.cpp @@ -164,7 +164,9 @@ namespace MyHost { // make a parameter instance OFX::Host::Param::Instance* MyEffectInstance::newParam(const std::string& name, OFX::Host::Param::Descriptor& descriptor) { - if(descriptor.getType()==kOfxParamTypeInteger) + if(descriptor.getType()==kOfxParamTypeString) + return new MyStringInstance(this,name,descriptor); + else if(descriptor.getType()==kOfxParamTypeInteger) return new MyIntegerInstance(this,name,descriptor); else if(descriptor.getType()==kOfxParamTypeDouble) return new MyDoubleInstance(this,name,descriptor); @@ -172,6 +174,10 @@ namespace MyHost { return new MyBooleanInstance(this,name,descriptor); else if(descriptor.getType()==kOfxParamTypeChoice) return new MyChoiceInstance(this,name,descriptor); +#ifdef OFX_EXTENSIONS_RESOLVE + else if(descriptor.getType()==kOfxParamTypeStrChoice) + return new MyStrChoiceInstance(this,name,descriptor); +#endif else if(descriptor.getType()==kOfxParamTypeRGBA) return new MyRGBAInstance(this,name,descriptor); else if(descriptor.getType()==kOfxParamTypeRGB) diff --git a/HostSupport/examples/hostDemoParamInstance.cpp b/HostSupport/examples/hostDemoParamInstance.cpp index 3906e420b..9da444754 100755 --- a/HostSupport/examples/hostDemoParamInstance.cpp +++ b/HostSupport/examples/hostDemoParamInstance.cpp @@ -55,6 +55,37 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace MyHost { + // + // MyStringInstance + // + + MyStringInstance::MyStringInstance(MyEffectInstance* effect, + const std::string& name, + OFX::Host::Param::Descriptor& descriptor) + : OFX::Host::Param::StringInstance(descriptor), _effect(effect), _descriptor(descriptor) + { + } + + OfxStatus MyStringInstance::get(std::string&) + { + return kOfxStatOK; + } + + OfxStatus MyStringInstance::get(OfxTime time, std::string&) + { + return kOfxStatOK; + } + + OfxStatus MyStringInstance::set(const char*) + { + return kOfxStatOK; + } + + OfxStatus MyStringInstance::set(OfxTime time, const char*) + { + return kOfxStatOK; + } + // // MyIntegerInstance // @@ -64,25 +95,31 @@ namespace MyHost { OFX::Host::Param::Descriptor& descriptor) : OFX::Host::Param::IntegerInstance(descriptor), _effect(effect), _descriptor(descriptor) { + _i = getProperties().getIntProperty(kOfxParamPropDefault); } - OfxStatus MyIntegerInstance::get(int&) + OfxStatus MyIntegerInstance::get(int& i) { - return kOfxStatErrMissingHostFeature; + i = _i; + return kOfxStatOK; } - OfxStatus MyIntegerInstance::get(OfxTime time, int&) + OfxStatus MyIntegerInstance::get(OfxTime time, int& i) { - return kOfxStatErrMissingHostFeature; + i = _i; + return kOfxStatOK; } - OfxStatus MyIntegerInstance::set(int) + OfxStatus MyIntegerInstance::set(int i) { - return kOfxStatErrMissingHostFeature; + _i = i; + return kOfxStatOK; } - OfxStatus MyIntegerInstance::set(OfxTime time, int) { - return kOfxStatErrMissingHostFeature; + OfxStatus MyIntegerInstance::set(OfxTime time, int i) + { + _i = i; + return kOfxStatOK; } // @@ -94,40 +131,41 @@ namespace MyHost { OFX::Host::Param::Descriptor& descriptor) : OFX::Host::Param::DoubleInstance(descriptor), _effect(effect), _descriptor(descriptor) { + _d = getProperties().getDoubleProperty(kOfxParamPropDefault); } OfxStatus MyDoubleInstance::get(double& d) { - // values for the Basic OFX plugin to work - d = 2.0; + d = _d; return kOfxStatOK; } OfxStatus MyDoubleInstance::get(OfxTime time, double& d) { - // values for the Basic OFX plugin to work - d = 2.0; + d = _d; return kOfxStatOK; } - OfxStatus MyDoubleInstance::set(double) + OfxStatus MyDoubleInstance::set(double d) { - return kOfxStatErrMissingHostFeature; + _d = d; + return kOfxStatOK; } - OfxStatus MyDoubleInstance::set(OfxTime time, double) + OfxStatus MyDoubleInstance::set(OfxTime time, double d) { - return kOfxStatErrMissingHostFeature; + _d = d; + return kOfxStatOK; } OfxStatus MyDoubleInstance::derive(OfxTime time, double&) { - return kOfxStatErrMissingHostFeature; + return kOfxStatOK; } OfxStatus MyDoubleInstance::integrate(OfxTime time1, OfxTime time2, double&) { - return kOfxStatErrMissingHostFeature; + return kOfxStatOK; } // @@ -139,31 +177,73 @@ namespace MyHost { OFX::Host::Param::Descriptor& descriptor) : OFX::Host::Param::BooleanInstance(descriptor), _effect(effect), _descriptor(descriptor) { + _b = getProperties().getIntProperty(kOfxParamPropDefault); } OfxStatus MyBooleanInstance::get(bool& b) { - b = true; + b = _b; return kOfxStatOK; } OfxStatus MyBooleanInstance::get(OfxTime time, bool& b) { - b = true; + b = _b; return kOfxStatOK; } - OfxStatus MyBooleanInstance::set(bool) + OfxStatus MyBooleanInstance::set(bool b) { - return kOfxStatErrMissingHostFeature; + _b = b; + return kOfxStatOK; } - OfxStatus MyBooleanInstance::set(OfxTime time, bool) { - return kOfxStatErrMissingHostFeature; + OfxStatus MyBooleanInstance::set(OfxTime time, bool b) + { + _b = b; + return kOfxStatOK; + } + +#ifdef OFX_EXTENSIONS_RESOLVE + // + // MyStrChoiceInstance + // + + MyStrChoiceInstance::MyStrChoiceInstance(MyEffectInstance* effect, + const std::string& name, + OFX::Host::Param::Descriptor& descriptor) + : OFX::Host::Param::StrChoiceInstance(descriptor), _effect(effect), _descriptor(descriptor) + { + _choice = getProperties().getStringProperty(kOfxParamPropDefault); + } + + OfxStatus MyStrChoiceInstance::get(std::string& choice) + { + choice = _choice; + return kOfxStatOK; + } + + OfxStatus MyStrChoiceInstance::get(OfxTime time, std::string& choice) + { + choice = _choice; + return kOfxStatOK; + } + + OfxStatus MyStrChoiceInstance::set(const char* choice) + { + _choice = std::string(choice); + return kOfxStatOK; + } + + OfxStatus MyStrChoiceInstance::set(OfxTime time, const char* choice) + { + _choice = std::string(choice); + return kOfxStatOK; } +#endif // - // MyChoiceInteger + // MyChoiceInstance // MyChoiceInstance::MyChoiceInstance(MyEffectInstance* effect, diff --git a/HostSupport/examples/hostDemoParamInstance.h b/HostSupport/examples/hostDemoParamInstance.h index 8ff778ae7..b6935e16b 100755 --- a/HostSupport/examples/hostDemoParamInstance.h +++ b/HostSupport/examples/hostDemoParamInstance.h @@ -39,7 +39,20 @@ namespace MyHost { MyPushbuttonInstance(MyEffectInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); }; + class MyStringInstance : public OFX::Host::Param::StringInstance { + protected: + MyEffectInstance* _effect; + OFX::Host::Param::Descriptor& _descriptor; + public: + MyStringInstance(MyEffectInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); + OfxStatus get(std::string&); + OfxStatus get(OfxTime time, std::string&); + OfxStatus set(const char*); + OfxStatus set(OfxTime time, const char*); + }; + class MyIntegerInstance : public OFX::Host::Param::IntegerInstance { + int _i; protected: MyEffectInstance* _effect; OFX::Host::Param::Descriptor& _descriptor; @@ -52,6 +65,7 @@ namespace MyHost { }; class MyDoubleInstance : public OFX::Host::Param::DoubleInstance { + double _d; protected: MyEffectInstance* _effect; OFX::Host::Param::Descriptor& _descriptor; @@ -66,6 +80,7 @@ namespace MyHost { }; class MyBooleanInstance : public OFX::Host::Param::BooleanInstance { + bool _b; protected: MyEffectInstance* _effect; OFX::Host::Param::Descriptor& _descriptor; @@ -89,6 +104,21 @@ namespace MyHost { OfxStatus set(OfxTime time, int); }; +#ifdef OFX_EXTENSIONS_RESOLVE + class MyStrChoiceInstance : public OFX::Host::Param::StrChoiceInstance { + std::string _choice; + protected: + MyEffectInstance* _effect; + OFX::Host::Param::Descriptor& _descriptor; + public: + MyStrChoiceInstance(MyEffectInstance* effect, const std::string& name, OFX::Host::Param::Descriptor& descriptor); + OfxStatus get(std::string&); + OfxStatus get(OfxTime time, std::string&); + OfxStatus set(const char*); + OfxStatus set(OfxTime time, const char*); + }; +#endif + class MyRGBAInstance : public OFX::Host::Param::RGBAInstance { protected: MyEffectInstance* _effect; diff --git a/HostSupport/include/ofxhParam.h b/HostSupport/include/ofxhParam.h index 5e86b47d8..af784ce85 100755 --- a/HostSupport/include/ofxhParam.h +++ b/HostSupport/include/ofxhParam.h @@ -377,6 +377,38 @@ namespace OFX { virtual void notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC; }; +#ifdef OFX_EXTENSIONS_RESOLVE + class StrChoiceInstance : public Instance, public KeyframeParam { + std::string _returnValue; ///< location to hold temporary return value. Should delegate this to implementation!!! + public: + StrChoiceInstance(Descriptor& descriptor, Param::SetInstance* instance = 0); + + // callback which should set option as appropriate + virtual void setOption(int num); + + // Deriving implementatation needs to overide these + virtual OfxStatus get(std::string &) = 0; + virtual OfxStatus get(OfxTime time, std::string &) = 0; + virtual OfxStatus set(const char*) = 0; + virtual OfxStatus set(OfxTime time, const char*) = 0; + + /// implementation of var args function + virtual OfxStatus getV(va_list arg); + + /// implementation of var args function + virtual OfxStatus getV(OfxTime time, va_list arg); + + /// implementation of var args function + virtual OfxStatus setV(va_list arg); + + /// implementation of var args function + virtual OfxStatus setV(OfxTime time, va_list arg); + + /// overridden from Instance + virtual void notify(const std::string &name, bool single, int num) OFX_EXCEPTION_SPEC; + }; +#endif + class DoubleInstance : public Instance, public KeyframeParam { public: DoubleInstance(Descriptor& descriptor, Param::SetInstance* instance = 0) : Instance(descriptor,instance) {} diff --git a/HostSupport/src/ofxhImageEffect.cpp b/HostSupport/src/ofxhImageEffect.cpp index 84f023775..e156e4c88 100644 --- a/HostSupport/src/ofxhImageEffect.cpp +++ b/HostSupport/src/ofxhImageEffect.cpp @@ -111,6 +111,8 @@ namespace OFX { #ifdef OFX_EXTENSIONS_RESOLVE { kOfxImageEffectPropOpenCLRenderSupported, Property::eString, 1, false, "false"}, { kOfxImageEffectPropCudaRenderSupported, Property::eString, 1, false, "false" }, + { kOfxImageEffectPropCudaStreamSupported, Property::eString, 1, false, "false" }, + { kOfxImageEffectPropMetalRenderSupported, Property::eString, 1, false, "false" }, #endif #ifdef OFX_EXTENSIONS_NUKE { kFnOfxImageEffectPropMultiPlanar, Property::eInt, 1, false, "0" }, @@ -1301,7 +1303,10 @@ namespace OFX { # ifdef OFX_EXTENSIONS_RESOLVE { kOfxImageEffectPropOpenCLEnabled, Property::eInt, 1, true, "0" }, { kOfxImageEffectPropCudaEnabled, Property::eInt, 1, true, "0" }, + { kOfxImageEffectPropMetalEnabled, Property::eInt, 1, true, "0" }, { kOfxImageEffectPropOpenCLCommandQueue, Property::ePointer, 1, false, "0" }, + { kOfxImageEffectPropCudaStream, Property::ePointer, 1, false, "0" }, + { kOfxImageEffectPropMetalCommandQueue, Property::ePointer, 1, false, "0" }, # endif # ifdef OFX_EXTENSIONS_NUKE { kFnOfxImageEffectPropView, Property::eInt, 1, true, "0" }, @@ -1401,7 +1406,10 @@ namespace OFX { # ifdef OFX_EXTENSIONS_RESOLVE { kOfxImageEffectPropOpenCLEnabled, Property::eInt, 1, true, "0" }, { kOfxImageEffectPropCudaEnabled, Property::eInt, 1, true, "0" }, + { kOfxImageEffectPropMetalEnabled, Property::eInt, 1, true, "0" }, { kOfxImageEffectPropOpenCLCommandQueue, Property::ePointer, 1, false, "0" }, + { kOfxImageEffectPropCudaStream, Property::ePointer, 1, false, "0" }, + { kOfxImageEffectPropMetalCommandQueue, Property::ePointer, 1, false, "0" }, # endif # ifdef OFX_EXTENSIONS_VEGAS { kOfxImageEffectPropRenderView, Property::eInt, 1, true, "0" }, @@ -1518,7 +1526,10 @@ namespace OFX { # ifdef OFX_EXTENSIONS_RESOLVE { kOfxImageEffectPropOpenCLEnabled, Property::eInt, 1, true, "0" }, { kOfxImageEffectPropCudaEnabled, Property::eInt, 1, true, "0" }, + { kOfxImageEffectPropMetalEnabled, Property::eInt, 1, true, "0" }, { kOfxImageEffectPropOpenCLCommandQueue, Property::ePointer, 1, false, "0" }, + { kOfxImageEffectPropCudaStream, Property::ePointer, 1, false, "0" }, + { kOfxImageEffectPropMetalCommandQueue, Property::ePointer, 1, false, "0" }, # endif # ifdef OFX_EXTENSIONS_NUKE { kFnOfxImageEffectPropView, Property::eInt, 1, true, "0" }, @@ -4199,6 +4210,8 @@ namespace OFX { # ifdef OFX_EXTENSIONS_RESOLVE { kOfxImageEffectPropOpenCLRenderSupported, Property::eString, 1, false, "false"}, { kOfxImageEffectPropCudaRenderSupported, Property::eString, 1, false, "false" }, + { kOfxImageEffectPropCudaStreamSupported, Property::eString, 1, false, "false" }, + { kOfxImageEffectPropMetalRenderSupported, Property::eString, 1, false, "false" }, # endif # ifdef OFX_EXTENSIONS_NUKE { kFnOfxImageEffectPropMultiPlanar, Property::eInt, 1, false, "0" }, diff --git a/HostSupport/src/ofxhImageEffectAPI.cpp b/HostSupport/src/ofxhImageEffectAPI.cpp index 1f031f0c8..2c755475e 100644 --- a/HostSupport/src/ofxhImageEffectAPI.cpp +++ b/HostSupport/src/ofxhImageEffectAPI.cpp @@ -282,10 +282,11 @@ namespace OFX { # ifdef OFX_DEBUG_ACTIONS OfxPlugin *op = _pluginHandle->getOfxPlugin(); std::cout << "OFX: "<pluginIdentifier<<"("<<(void*)op<<")->"<pluginIdentifier); // save it before it becomes invalid # endif stat = (*_pluginHandle)->mainEntry(kOfxActionUnload, 0, 0, 0); # ifdef OFX_DEBUG_ACTIONS - std::cout << "OFX: "<pluginIdentifier<<"("<<(void*)op<<")->"<"<"<"<getParamSetInstance()) { paramInstance->getParamSetInstance()->paramChangedByPlugin(paramInstance); } @@ -2405,7 +2482,7 @@ namespace OFX { va_end(ap); - if (stat == kOfxStatOK) { + if (stat == kOfxStatOK && paramInstance->getParamSetInstance()) { paramInstance->getParamSetInstance()->paramChangedByPlugin(paramInstance); } diff --git a/include/ofxImageEffect.h b/include/ofxImageEffect.h index 59bbd0a88..22cac73bf 100644 --- a/include/ofxImageEffect.h +++ b/include/ofxImageEffect.h @@ -1474,6 +1474,29 @@ using the buffer pointers. */ #define kOfxImageEffectPropCudaEnabled "OfxImageEffectPropCudaEnabled" +/** @brief Indicates whether a host or plugin can support Cuda stream + + - Type - string X 1 + - Property Set - plugin descriptor (read/write), host descriptor (read only) + - Default - "false" + - Valid Values - This must be one of + - "false" - in which case the host or plugin does not support Cuda stream + - "true" - which means a host or plugin can support Cuda stream provided + +*/ +#define kOfxImageEffectPropCudaStreamSupported "OfxImageEffectPropCudaStreamSupported" + +/** @brief The stream of Cuda render + + - Type - pointer X 1 + - Property Set - plugin descriptor (read only), host descriptor (read/write) + +This property contains a pointer to the stream of Cuda render (cudaStream_t). +In order to use it, reinterpret_cast(pointer) is needed. + +*/ +#define kOfxImageEffectPropCudaStream "OfxImageEffectPropCudaStream" + /** @brief Indicates whether a host or plugin can support Metal render - Type - string X 1