-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
I'm experiencing out-of-bounds array accesses with the AMR sampler. I tracked the issue down to this access into the brick voxel list: https://github.com/RenderKit/openvkl/blob/master/openvkl/devices/cpu/volume/amr/CellRef.ispc#L90
Here's some local variable info for a case where this fails (on the 4th SIMD lane):
brickSize: [((512)),((512)),((512)),512] // that's brick->dim.x*brick->dim.y*brick->dim.z
f_bc.x: [((3.000000)),((2.000000)),((2.000000)),2.000000]
f_bc.y: [((7.000000)),((7.000000)),((7.000000)),8.000000]
f_bc.z: [((8.000000)),((7.000000)),((7.000000)),7.000000]
f_dims.x: 8.000000
f_dims.y: 8.000000
f_dims.z: 8.000000
relBrickPos.x: [((0.388464)),((0.359136)),((0.364288)),0.343571]
relBrickPos.y: [((0.985767)),((0.999565)),((0.991043)),1.000000]
relBrickPos.z: [((1.063786)),((0.960573)),((0.995874)),0.915741]
/Users/stefan/openvkl/openvkl/include/../common/Data.ih:128:101: Assertion failed: index32 >= 0 && index32 < data.numItems
This fails as const vec3f f_bc = floor(relBrickPos * brick->f_dims); does not round down if relBrickPos is exactly 1.0.
Not sure what the best fix is. This works for me:
vec3f relBrickPos
= (worldSpacePos - brick->bounds.lower) * brick->bounds_scale;
relBrickPos.x = clamp(relBrickPos.x, 0.f, 0.9999f);
relBrickPos.y = clamp(relBrickPos.y, 0.f, 0.9999f);
relBrickPos.z = clamp(relBrickPos.z, 0.f, 0.9999f);
or another solution would be clamping f_bc to the interval [0.f,f_dims-1.f].
(I can't trigger it there, but the code here might have the same issue.
Metadata
Metadata
Assignees
Labels
No labels