CIKernel from Metal filter renders only black? Help

Having pored over the WWDC Video and slides, I am trying to get a CIFilter using a metal program to work. I have everything working with a Core Image Kernel Language version, but even a simple pass-through CIColorKernel only passes black ;-(

I have verified that the metal code is compiled and the libraries are linked, and in fact, [CIColorKernel kernelWithFunctionName:fromMetalLibraryData:error] returns what appears to be a perfectly good kernel, and the filter output image succeeds and even shows the filter in the image description ( CI processing stack). But it is black.


Here's the metal code for the filter:


#include <metal_stdlib>
using namespace metal;
#include <CoreImage/CoreImage.h>
extern "C" { namespace coreimage {
  
float4 ColorBands( sample_t src);  // xcode complains without a prototype...
  
float4 ColorBands( sample_t src) {
    return src.rgba;//float4(1.0, 0.2, 0.8,1.0)
}
  
} }  // extern C, coreimage namespace


I have adapted the venerable RosyWriter sample to use a CIFilter subclass in place of the Rosy color just to verify the problem. This is using the latest (beta3) iOS 11 on a 12.9" iPad Pro. I haven't found any other samples that use the new CIKernel metal funtionality, so it may be that there's something simple i'm overlooking, or it may just not work.

Thanks in advance for any ideas or answers!

Replies

Beta 4 doesn't help, in fact, the RosyWriter example crashs on launch in the debugger. It runs OK standalone however... Beta 4 of xcode and iOS 11. I filed a Radar on this, BTW.

Update: The crash with beta4 was unrelated to the app, and wasdue to this issue with xcode.

I heard back from Apple on the bug I filed. Here is their crucial insight:


CIImage filter graphs containing Metal CIKernels cannot be rendered with GL-based CIContexts.


Replacing the CIContext backed by an EAGL context with one based on a MetalDevice did indeed fix the problem.

The question now is how to build mutiple metal kernels into multiple .metallib files with xcode...