Code Monkey home page Code Monkey logo

Comments (8)

garyo avatar garyo commented on July 28, 2024

This allows the host more visibility into plugin memory usage. It is not mandatory. For instance the host may pre-allocate and manage large image buffers, and give those to the plugins faster than system malloc. But in practice, many hosts just wrap malloc/free with these calls.

from openfx.

emil-e avatar emil-e commented on July 28, 2024

@garyo That makes sense. I don't see it as a big hassle to use imageMemoryAlloc for image buffers since it's easy to have control over that, but for randoms strings, vectors, third party libraries and so on, it's hard or impossible to pipe all those allocations back to the host.

I also see that the support library manages the suites as global variables rather than storing the suites per plugin:

OfxMemorySuiteV1 *gMemorySuite = 0;

Is this really safe? Is is guaranteed that same suite would be returned for each individual plugin in the same library? Each plugin gets their own OfxHost through setHost and thus have their own fetchSuite pointer. The host could send different suites to different plugins so is this really safe?

from openfx.

garyo avatar garyo commented on July 28, 2024

Both of these questions would be excellent clarifications to the spec, which is defined by the doc comments in the source.
No host would require all allocations like strings and vectors to go through the OpenFX API. You may get better performance, for instance the host may return pinned physical memory, and may avoid certain low-memory situations where the host has pre-allocated most of the physical RAM.

As for the suites, we could add a clarification to the spec that the host must return the same suite pointers to all plugins in the same shared lib. I'm pretty sure all existing hosts do that (it's not hard for the host to switch different behavior within a suite on a per-plugin basis if needed) and plugins I've seen store them as single globals, but as you point out nothing in the spec currently precludes them from doing that.

Feel free to add some clarifying text to the appropriate places in the spec if you like!

from openfx.

barretpj avatar barretpj commented on July 28, 2024

from openfx.

garyo avatar garyo commented on July 28, 2024

That's a fair point, Phil. Even if we think everyone does it that way today there is a risk.
Perhaps we could add this as "Recommended: hosts should return the same suite pointers to all plugins in the same shared lib" rather than a strict requirement. That should help future hosts behave nicely, and also serves to alert plugins that they may want to handle the case where a host behaves differently. What do you think of that?

from openfx.

barretpj avatar barretpj commented on July 28, 2024

from openfx.

emil-e avatar emil-e commented on July 28, 2024

From someone just starting out with OpenFX, I never made any assumptions about suite pointers being the same across plugins nor that they would all receive the same host pointer. The fact that each plugin declares its own setHost function pointer is an indication that it could be different, otherwise it would be a top-level global exported function next to OfxGetPlugin. Looking only at these things, it was very surprising to be to see the implementation of the support library using global vars for this - it felt instinctively incorrect.

However, if one wants to redirect normal allocations in one's language of choice to go through the OFX memory suite, it would be very annoying to do without the memory allocation being actually global.

from openfx.

garyo avatar garyo commented on July 28, 2024

Gary will add this note: "Recommended: hosts should return the same suite pointers to all plugins in the same shared lib or bundle"

from openfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.