I’m going through Ray Tracing in One Weekend and trying to implement it in CUDA.
I’m running into issues with the hittable_list
. My scene is going to be static, so I thought I would store it in constant memory. I get why you can’t use an std::vector
in constant memory.
I tried using
std::array<const hittable*, MAX_ENTITIES> objects;
unsigned int current_size = 0;
but after some compiler errors and thinking I get why that doesn’t worth either.
Specifically, my question is about polymorphism and storing pointers to base classes in constant memory. Are there any tricks to get this to work? More generally, how do people store scenes? Constant memory seems like the obvious choice on the surface but given that you can’t take advantage of any polymorphism I’m wondering what other techniques get used.