Safe UUID→Position lookup with automatic bounds checking. More...
#include <BufferIndexing.h>
Public Member Functions | |
| HELIOS_HOST_DEVICE | UUIDLookupHelper (const uint *prim_positions, size_t prim_count) |
| Construct UUID lookup helper. | |
| HELIOS_HOST_DEVICE bool | toPosition (uint UUID, uint &position) const |
| Convert UUID to position with automatic bounds checking. | |
Safe UUID→Position lookup with automatic bounds checking.
Encapsulates the UUID→position conversion pattern used throughout CUDA code. Prevents forgetting bounds check or using UUID as direct array index.
This helper makes it impossible to:
Usage in CUDA ray hit programs:
Historical bugs prevented (commit 0ec2dc25a):
Definition at line 292 of file BufferIndexing.h.
|
inline |
Construct UUID lookup helper.
| prim_positions | Pointer to primitive_positions buffer (sparse array indexed by UUID) |
| prim_count | Total number of primitives (for bounds validation) |
Definition at line 304 of file BufferIndexing.h.
|
inline |
Convert UUID to position with automatic bounds checking.
| UUID | Primitive UUID to look up | |
| [out] | position | Output position (only written if UUID is valid) |
Returns false if:
Position parameter is unchanged if function returns false.
Definition at line 320 of file BufferIndexing.h.