To find the median value in a set, I need to sort the set from lowest to highest color values and then find the value in the middle if the set is odd, or average the 2 middle values if the set is even. Since this is my first attempt at graphics programming on the GPU I don't know if it makes sense for this problem (sorting)?
Any advise?


give up?

But seriously. CoreImage doesn't allow data-dependent branching, so sorting with it isn't really possible. (There's the ternary operator, but for sorting non-trivial data sets that's going to get exponentially complex)

You _can_ make CPU-based core image filters, but not through the QC interface. This doesn't satisfy the "on-gpu" aspect, but it does satisfy the "is possible" aspect. ;)

If you really really really want/need on-GPU sorting, there are some academic papers that describe some possible approaches. Due to the overwhelmingly parallel nature of GPUs, these algorithms are usually non-trivial from what I've seen, and might not be directly applicable to CI (CI's a narrow subset of gpu functionality, so you can't implement everything in CI that you can on a GPU in general). http://mgarland.org/papers.html#gpusort-tr describes a fairly accessible one (it uses radix sort, which isn't crazy) -- I think this just needs a few scatter/gather operations to perform the sort (CI can't do this except in very simple cases -- it can gather (read from multiple locations on the texture), but it can't scatter (write to arbitrary locations) from what I've seen done).

--
[ christopher wright ]
[email protected]
http://kineme.net/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to