From 5f03e4c392b5eb92bd0e1e10e7504898c91da1f5 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Sun, 9 Nov 2025 12:12:08 -0400 Subject: [PATCH] livoxG1:collateDgrams.cl: Clarify collation offsetting --- stimBuffApis/livoxGen1/collateDgrams.cl | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/stimBuffApis/livoxGen1/collateDgrams.cl b/stimBuffApis/livoxGen1/collateDgrams.cl index 91e6d49..67211d4 100644 --- a/stimBuffApis/livoxGen1/collateDgrams.cl +++ b/stimBuffApis/livoxGen1/collateDgrams.cl @@ -37,8 +37,10 @@ __kernel void collate( // Get points array pointer (after 18-byte header) __global uchar* pointsArray = slotStart + 18; - // Base offset in collation buffer for this slot (in floats, 4 per PointXYZI) - uint collationBaseOffset = slotIndex * nPointsPerSlot * 4; + // Base offset in collation buffer for this slot (in floats) + // Each PointXYZI is 4 floats (x, y, z, intensity) + #define FLOATS_PER_POINT 4 + uint collationBaseOffset = slotIndex * nPointsPerSlot * FLOATS_PER_POINT; // Process based on data type using nested ifs (outer) with loops (inner) if (dataType == 0) @@ -62,7 +64,7 @@ __kernel void collate( float intensity = (float)reflectivity; // Write to collation buffer - uint offset = collationBaseOffset + (i * 4); + uint offset = collationBaseOffset + (i * FLOATS_PER_POINT); collation[offset + 0] = x; collation[offset + 1] = y; collation[offset + 2] = z; @@ -91,7 +93,7 @@ __kernel void collate( float intensity = (float)reflectivity; // Write to collation buffer - uint offset = collationBaseOffset + (i * 4); + uint offset = collationBaseOffset + (i * FLOATS_PER_POINT); collation[offset + 0] = x; collation[offset + 1] = y; collation[offset + 2] = z; @@ -122,7 +124,8 @@ __kernel void collate( float z1 = (float)z1_mm / 1000.0f; float intensity1 = (float)reflectivity1; - uint offset1 = collationBaseOffset + (pointIndex * 4); + uint offset1 = collationBaseOffset + + (pointIndex * FLOATS_PER_POINT); collation[offset1 + 0] = x1; collation[offset1 + 1] = y1; collation[offset1 + 2] = z1; @@ -141,7 +144,8 @@ __kernel void collate( float z2 = (float)z2_mm / 1000.0f; float intensity2 = (float)reflectivity2; - uint offset2 = collationBaseOffset + (pointIndex * 4); + uint offset2 = collationBaseOffset + + (pointIndex * FLOATS_PER_POINT); collation[offset2 + 0] = x2; collation[offset2 + 1] = y2; collation[offset2 + 2] = z2; @@ -173,7 +177,8 @@ __kernel void collate( float z1 = (float)z1_mm / 1000.0f; float intensity1 = (float)reflectivity1; - uint offset1 = collationBaseOffset + (pointIndex * 4); + uint offset1 = collationBaseOffset + + (pointIndex * FLOATS_PER_POINT); collation[offset1 + 0] = x1; collation[offset1 + 1] = y1; collation[offset1 + 2] = z1; @@ -192,7 +197,8 @@ __kernel void collate( float z2 = (float)z2_mm / 1000.0f; float intensity2 = (float)reflectivity2; - uint offset2 = collationBaseOffset + (pointIndex * 4); + uint offset2 = collationBaseOffset + + (pointIndex * FLOATS_PER_POINT); collation[offset2 + 0] = x2; collation[offset2 + 1] = y2; collation[offset2 + 2] = z2; @@ -211,7 +217,8 @@ __kernel void collate( float z3 = (float)z3_mm / 1000.0f; float intensity3 = (float)reflectivity3; - uint offset3 = collationBaseOffset + (pointIndex * 4); + uint offset3 = collationBaseOffset + + (pointIndex * FLOATS_PER_POINT); collation[offset3 + 0] = x3; collation[offset3 + 1] = y3; collation[offset3 + 2] = z3;