View Full Version : Arrays of Variable Length

01-06-2010, 04:27 PM
I'm working on a port of Paul Bourke's Marching Cubes
http://local.wasp.uwa.edu.au/~pbourke/g ... olygonise/ (http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/)
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.


01-11-2010, 06:05 AM
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.