@@ -28,8 +28,10 @@ extern CellRef findCell(const AMR *uniform self,
2828 for (uniform int i= 0 ;any (true );i++ ) {
2929 const AMRBrick * uniform brick = leaf-> brickList[i];
3030 if (brick-> cellWidth >= minWidth) {
31- const vec3f relBrickPos
31+ vec3f relBrickPosUnclamped
3232 = (worldSpacePos - brick-> bounds. lower) * brick-> bounds_scale;
33+ // clamp to 1ULP-less-1 for f_bc stay in valid index range
34+ const vec3f relBrickPos = min (relBrickPosUnclamped, make_vec3f (0x1 . fffffep- 1f));
3335 // brick coords: integer cell coordinates inside brick
3436 // OPT: the same calculations as below, just in
3537 // floats. this works as long as all values we calculate
@@ -75,8 +77,10 @@ extern CellRef findLeafCell(const AMR *uniform self,
7577 if (isLeaf (node)) {
7678 const AMRLeaf * uniform leaf = &self-> leaf[getOfs (node)];
7779 const AMRBrick * uniform brick = leaf-> brickList[0 ];
78- const vec3f relBrickPos
80+ const vec3f relBrickPosUnclamped
7981 = (worldSpacePos - brick-> bounds. lower) * brick-> bounds_scale;
82+ // clamp to 1ULP-less-1 for f_bc stay in valid index range
83+ const vec3f relBrickPos = min (relBrickPosUnclamped, make_vec3f (0x1 . fffffep- 1f));
8084 // brick coords: integer cell coordinates inside brick
8185 // OPT: the same calculations as below, just in
8286 // floats. this works as long as all values we calculate
0 commit comments