From a9aebbce6ed729b5ce4dde0c9137174aba6e3599 Mon Sep 17 00:00:00 2001 From: David Geldreich Date: Mon, 14 Aug 2023 22:00:21 +0200 Subject: [PATCH] add some Resolve features add OFX::Host::Param::StrChoiceInstance add ImageEffect properties : - kOfxImageEffectPropCudaStreamSupported - kOfxImageEffectPropMetalRenderSupported add Render properties : - kOfxImageEffectPropMetalEnabled - kOfxImageEffectPropCudaStream - kOfxImageEffectPropMetalCommandQueue correct a use after free error in kOfxActionUnload --- HostSupport/include/ofxhParam.h | 32 +++++++++ HostSupport/src/ofxhImageEffect.cpp | 13 ++++ HostSupport/src/ofxhImageEffectAPI.cpp | 3 +- HostSupport/src/ofxhParam.cpp | 89 ++++++++++++++++++++++++-- include/ofxImageEffect.h | 23 +++++++ 5 files changed, 153 insertions(+), 7 deletions(-) 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