commit 24b9f4959426e61397367d7363f3184fb37af734
parent ac989c5f961926b539d825c21062aae9647e6d0c
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Thu, 7 Feb 2019 10:45:06 +0100
Add some debug code
Diffstat:
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/src/senc_scene_analyze.c b/src/senc_scene_analyze.c
@@ -380,6 +380,7 @@ extract_connex_components
/* Compute the normal at the max_z vertex. */
max_nz = 0;
sz = darray_side_id_size_get(&ids_of_sides_around_max_z_vertex);
+ ASSERT(sz > 0);
FOR_EACH(ii, 0, sz) {
const side_id_t side_id =
darray_side_id_cdata_get(&ids_of_sides_around_max_z_vertex)[ii];
@@ -770,7 +771,7 @@ collect_and_link_neighbours
struct darray_neighbour* neighbour_list = &neighbourhood->neighbours;
side_id_t i, neighbour_count;
sz = darray_neighbour_size_get(neighbour_list);
- ASSERT(sz <= SIDE_MAX__);
+ ASSERT(sz > 0 && sz <= SIDE_MAX__);
neighbour_count = (side_id_t)sz;
ASSERT(neighbour_count);
v0 = neighbourhood->edge.vrtx0;
@@ -874,9 +875,15 @@ collect_and_link_neighbours
}
a = current->angle;
/* Link sides */
+ ASSERT(p_crt_side->facing_side_id[crt_edge] == SIDE_NULL__);
+ ASSERT(p_ccw_side->facing_side_id[ccw_edge] == SIDE_NULL__);
p_crt_side->facing_side_id[crt_edge] = ccw_side_idx;
p_ccw_side->facing_side_id[ccw_edge] = crt_side_idx;
/* Record media */
+ ASSERT(p_crt_side->medium == MEDIUM_NULL__
+ || p_crt_side->medium == triangles_in[crt_id].medium[crt_side]);
+ ASSERT(p_ccw_side->medium == MEDIUM_NULL__
+ || p_ccw_side->medium == triangles_in[ccw_id].medium[ccw_side]);
p_crt_side->medium = triangles_in[crt_id].medium[crt_side];
p_ccw_side->medium = triangles_in[ccw_id].medium[ccw_side];
ASSERT(p_crt_side->medium < scn->nmeds);
@@ -1146,6 +1153,14 @@ senc_scene_analyze(struct senc_scene* scn, struct senc_descriptor** out_desc)
res = RES_MEM_ERR;
goto error;
}
+#ifndef NDEBUG
+ else {
+ /* Initialise trgsides to allow assert code */
+ size_t i;
+ FOR_EACH(i, 0, 2 * scn->nutris)
+ init_trgside(scn->dev->allocator, trgsides + i);
+ }
+#endif
/* The end of the analyze is multithreaded */
ASSERT(scn->dev->nthreads > 0);
diff --git a/src/senc_scene_analyze_c.h b/src/senc_scene_analyze_c.h
@@ -78,6 +78,15 @@ struct trgside {
* front(trg_0), back(trg_0), front(trg_1), back(trg_1), ... */
};
+static FINLINE void
+init_trgside(struct mem_allocator* alloc, struct trgside* data)
+{
+ int i;
+ ASSERT(data); (void)alloc;
+ FOR_EACH(i, 0, 3) data->facing_side_id[i] = SIDE_NULL__;
+ data->medium = MEDIUM_NULL__;
+}
+
#define DARRAY_NAME side_id
#define DARRAY_DATA side_id_t
#include <rsys/dynamic_array.h>