Blink API
|
Blink integrates into NUKE's PlanarIops to allow you to do Blink-based image processing inside an NDK plug-in, and get the benefits of Blink's SIMD and GPU acceleration.
You can also run Blink kernels inside the BlinkScript node, but the advantage of writing your own Blink-based plug-ins is that images can be left on the GPU between kernel iterations. This can lead to a considerable saving in transfer time to-and-from the GPU, especially if you are running many Blink kernels on the same images.
In addition, the API gives you access to ImageRollingKernels and ImageReductionKernels, neither of which can be used inside the BlinkScript node.
In order to do any image processing with Blink, your data needs to be in a Blink Image. In Nuke, there are two ways to achieve this.
DD::Image::ImagePlanes can be wrapped up in Blink::Images, using the ImagePlaneAsBlinkImage function in the Blink.h header file in include/DDImage.
You should check the return value from this function to make sure the call has been successful before attempting to use the Blink Image. An unsuccessful call will not make any changes to the ImagePlane passed in.
When this function returns true, "blinkImage" will be assigned to a Blink::Image which shares its underlying memory buffer with "imagePlane". This memory buffer will not be changed by Image independently of imagePlane, so can continue to be used even if the original image plane is deleted or goes out of scope.
Nuke's ImagePlanes are always on the CPU at present, so a Blink Image set up with the ImagePlaneAsBlinkImage will also be on the CPU. Use the distributeTo() or makeLike() functions on the Blink Image to transfer it to the GPU.
You can also use the copyToBuffer() and copyFromBuffer() functions to copy data from a buffer on the CPU to and from a Blink Image. As well as a pointer to the data buffer, these functions take a BlinkBufferDesc that describes how data is laid out inside the buffer:
Building the example plug-in is exactly like building any other NDK plug-in, but there is one extra library you need to link against. This is libRIPFramework.*, where the ".*" represents the dynamic library extension for your operating system.
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |