mitsuba-renderer / enoki

Enoki: structured vectorization and differentiation on modern processor architectures
Other
1.26k stars 94 forks source link

How to dereference? #49

Closed ykozw closed 4 years ago

ykozw commented 4 years ago

Hi,

I would like to do dereference, something like this...

using PtrP   = enoki::Packet<uintptr_t, 8>;
using Uint16P   = enoki::Packet<uint16_t, 8>;
PtrP p = fun();
Uint16P i = *p;

But can't compile this code. Secondly, I think enoki::gather<>() fits for this situation.

Uint16P i = enoki::gather<Uint16P>(p,0);

But it doesn't return desired result. Maybe gather<> presuppose pointer is not packet, I thought.

Any solution?

Thanks.

ykozw commented 4 years ago

I figured out the function need mono-pointer, and I should calculate offsets together.

using Int32P   = enoki::Packet<int32_t, 8>;
using Uint16P   = enoki::Packet<uint16_t, 8>;
void** ptr;
Int32P offsets = fun(&ptr);
Uint16P i = enoki::gather<Uint16P>(ptr,offsets);