In my CPU ray tracer, I used polymorphism intensively.
For example, I had a bunch of different light types, point light, area light, etc., all derived from a Light base class.
When rendering, all I need is to loop through an arrary of Light pointers.
Now, without this capability, I have to explicitly store an array for each of the light types, and in order to query all light sources I need to loop through several arrays.
This is really ugly and inelegant to me.
Another alternative is to have a big switch-case clause, and choose different query methods, which also ugly.
I know that we can construct objects locally in the kernel code to call virtual functions too, but that’s not cool to me either and I am afraid it wil hurt performance.
So I am asking is there a good solution to polymorphism in CUDA kernel? Such as a smart way to use template somehow and I can call different implementation of a methods just like in C++?