Arrays of Variable Length

I’m working on a port of Paul Bourke’s Marching Cubes … olygonise/
code to OpenCL, but I’m now wondering if I might be about to hit an insurmountable obstacle. The code requires an array or triangle vertices to be calculated, but this array will not be of a fixed length (it will vary according to the input, as the plan is to generate geometry slab-wise from pairs of z-axis slices through a 3D volume texture). Looking through the OpenCL Reference card, there don’t seem to be any array-manipulation functions, and a quick search of this forum suggests arrays of variable length are not supported. Is this in fact the case, and if so, is there any workaround to get this to work?

Sorry if this is a stupid question.


Buffers’ sizes are fixed at creation. To simulate a variable length array you need to create one at the maximum size and then pass in a variable that tells the kernel how much of it to use.