Marching Cubes - Outputting Variable-Size Array

I’ve been working on a port of Paul Bourke’s Marching-Cubes implementation … olygonise/
trying to make an OpenCL version. I’m now wondering if this is in fact going to be possible, though.

I envisage the stumbling-block being the fact that the kernel needs to return an array containing a variable number of vertices, depending on the input texture (the plan is to use it to render slabs of consecutive pairs of slices through a 3D volume).

I know OpenCL is sensitive about memory-management, so I suspect the answer may be ‘no’, but can anyone tell me definitively if this would in fact be possible? I know I’ve posted on this before, so apologies if you’ve read a similar cry for help in the past, but I never got a definitive answer.

I’ve seen code for a CUDA marching-cubes implementation, incidentally. I don’t know if the fact it works in CUDA makes it necessarily more likely to be possible in OpenCL…



If it works in CUDA it will almost certainly port over easily to OpenCL. They have (at the moment) very similar feature sets and limitations. So the answer is almost certainly that it will work, and a high-performance CUDA implementation should port naturally over to a high-performance OpenCL one. (Modulo the beta status of Nvidia’s drivers, of course.)

Thanks for that dbs2. I’ll have another look at the CUDA version on the NVIDIA site. I did have a look through the code, but it looked a bit over my head, to be honest. It’s obviously built for speed, rather than ease-of-understanding for newbies like me!