Eyeon Talk:Script/Reference/Applications/Fuse/OpenCL Fuse Reference Manual

From VFXPedia

< Eyeon Talk:Script | Reference/Applications/Fuse
Revision as of 14:46, 8 April 2012 by Tilt (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Banging my head against the wall on the kernel part... I have some print statements in the fuse that let me see if everything is ok before and after the kernel, but I can't see what is or isn't working in the actual kernel. Is there a proper way to debug the OpenCL kernel? I assume printf is out, right? --Chad 19:10, 26 October 2010 (EDT)

OK, so I've narrowed down my issue... It seems to be OK by the OpenCL docs, but it's not working in my fuse. And by way of example, I'm a bit confused... There's no float3 in any of the samples. So maybe I'm doing something dumb? No rush, I have a workaround for the specific fuse I'm doing, but I would really like to know how to use float3's anyway. --Chad

   int2 ipos = (int2)(get_global_id(1), get_global_id(0));
   float4 incolor = FuReadImage(src, ipos, srcsize);
   float4 outcolor;
   float4 tempcolor;   // this will work, as will float2, but change it to float3, and it will not?
   tempcolor.s0 = incolor.s0;
   outcolor.s0 = tempcolor.s0;
   FuWriteImagef(dst, ipos, srcsize, outrgba);


Do you have verbose console messages turned on in Fusion's OpenCL prefs? That usually helps to narrow down syntax issues. Also, float3 is part of the OpenCL 1.1 spec, which isn't yet supported by nVidia drivers.--Stuart 00:29, 27 October 2010 (EDT)
Thank you so much! Both tips appreciated. Ideally, we wouldn't have to worry about doing all this profiling, but it looks like we're going to have to in the short term (or just develop to a more barebones spec). Somewhat related... Any chance we can get a simple example for OpenCL manager use in the SDK? We're assuming it is similar to Fuses, and the Fuses are a good start, but if we wanted to add OpenCL to our C++ plugins, like what you did with Defocus, what would it take? --Chad 14:12, 27 October 2010 (EDT)
You just need OCLManager.h, which I believe is in the most recent SDK. Syntax is very similar to fuses. I put together a C++ plugin example, but haven't yet made it public as I'm currently engaged in breaking it all anyway. You'll likely be needing to recompile (and maybe tweak) any C++ OpenCL plugins you make when I'm done, so be aware of that. --Daniel
The Fuses have been easy to learn with, it's just a question of "do we make our C++ code exposed to Lua" or "do we stick the OpenCL in the C++ plugin". We've never done the former, either, so maybe we should try that anyway. --Chad

If we wanted to test to see if OpenCL was available, and fall back to pure Lua if it isn't, what should we test for? --Chad 14:37, 27 October 2010 (EDT)

If OCLManager() returns nil, then OpenCL isn't available.--Stuart 18:31, 27 October 2010 (EDT)
Ok. That wasn't working for me yesterday, but I'll try a simpler test today. I guess as a second check, we can check to see if the RunKernel finished, like the "success = prog:RunKernel(kernel)" in the example, and if it did not, do the Lua operations. --Chad


Is it possible to keep an image in memory if you are connecting two OpenCL tools? If I'm not putting it in a viewer, or passing it to a non-OpenCL tool, it seems like you could save the upload/download step. Even if you did the download, if you kept a copy in OpenCL memory you would save the second tool from having to upload it. --Chad 10:30, 29 October 2010 (EDT)

How does the OpenGL interop work? Is it only for making our own OpenGL tools, or does it work with Fusion's 3D system? Or am I missing what the "gl" option is for? --Chad 10:30, 29 October 2010 (EDT)

Right now, if you use the "gl" option when creating the OCL image (readable or writable), it will create a shared OpenGL texture and cache this with the image, automatically saving future uploads from that image when displaying, for re-renders of that tool and for downstream tools. Consider it experimental for the moment, however. --Daniel

Would it make sense to have FuReadImageT write an array of floats if the image is mono/alpha? Right now we're pretty much just doubling up our kernels for RGBA and A and setting the image arguments differently for each. --Chad 13:32, 19 November 2010 (EST)


The wiki refers to the Release() method, but every example fuse is calling ReleaseCLObject(). What's the correct name? --Tilt 10:46, 8 April 2012 (EDT)


Sampling images with DoD

Since this page doesn't have a tips section, I'm adding this here: FuSampleImagef and FuSampleImageCf expect normalized coordinates. If the image has a data window (DoD) that's different from the full image size, the 0..1 range refers to the DoD's size, not the image size! In other words, 0.0/0.0 will sample the bottom left pixel of the current DoD and 0.5/0.5 will sample from the center of the DoD - not the center of the image.


Two questions:

  • Are there functions that return the canvas color instead of black when the coordinates are out of bounds?
  • Apparently I have to add 0.5 pixels to the coordinates to sample a pixel without filtering. In LUA, the Image:SamplePixel() function, however, doesn't need this. Is this an error on my part?