commit 874f0ea7b23e827455dc3aea72b021b40e0827c9
parent cdc4da27ba24b22697ea879c28d7ed3c70c532aa
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 1 Jun 2023 15:41:41 +0200
Fix an "invalid read" of the Embree geometry buffer
Embree requires the last coordinate in the buffer to be readable using
16-byte SSE load instructions, which was not the case since the size of
a vertex is 12 bytes. We therefore added 4 bytes of padding to the
geometry buffer.
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/s2d_scene_view.c b/src/s2d_scene_view.c
@@ -42,6 +42,10 @@
#include <limits.h>
+/* Number of floats added to the vertex position in order to ensure the Embree
+ * vertex padding constraint */
+#define POSITION_PADDING 1
+
struct intersect_context {
struct RTCRayQueryContext rtc;
struct s2d_scene_view* scnview;
@@ -214,7 +218,9 @@ embree_geometry_setup_positions
nverts = line_segments_get_nverts(geom->lines);
verts = line_segments_get_attr(geom->lines, S2D_POSITION);
- buf = rtcNewBuffer(scnview->scn->dev->rtc, nverts*2*sizeof(float[3]));
+ buf = rtcNewBuffer
+ (scnview->scn->dev->rtc,
+ nverts*2*sizeof(float[3]) + sizeof(float)*POSITION_PADDING);
if(!buf) {
res = rtc_error_to_res_T(rtcGetDeviceError(scnview->scn->dev->rtc));
goto error;