[Bf-blender-cvs] [a068dda] master: Code cleanup: ifdef unused linklist for GPU drawobject's

Campbell Barton noreply at git.blender.org
Wed Apr 9 07:42:51 CEST 2014


Commit: a068dda5f381c59c96ff1fc0fdc60cc0296c7c1e
Author: Campbell Barton
Date:   Wed Apr 9 15:38:37 2014 +1000
https://developer.blender.org/rBa068dda5f381c59c96ff1fc0fdc60cc0296c7c1e

Code cleanup: ifdef unused linklist for GPU drawobject's

===================================================================

M	source/blender/gpu/GPU_buffers.h
M	source/blender/gpu/intern/gpu_buffers.c

===================================================================

diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 1d27824..a1ab145 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -94,9 +94,13 @@ typedef struct GPUDrawObject {
 
 	/* for each original vertex, the list of related points */
 	struct GPUVertPointLink *vert_points;
+
+	/* see: USE_GPU_POINT_LINK define */
+#if 0
 	/* storage for the vert_points lists */
 	struct GPUVertPointLink *vert_points_mem;
 	int vert_points_usage;
+#endif
 	
 	int colType;
 
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 1eddd90..82c1469 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -377,14 +377,22 @@ void GPU_buffer_free(GPUBuffer *buffer)
 	BLI_mutex_unlock(&buffer_mutex);
 }
 
+/* currently unused */
+// #define USE_GPU_POINT_LINK
+
 typedef struct GPUVertPointLink {
+#ifdef USE_GPU_POINT_LINK
 	struct GPUVertPointLink *next;
+#endif
 	/* -1 means uninitialized */
 	int point_index;
 } GPUVertPointLink;
 
+
 /* add a new point to the list of points related to a particular
  * vertex */
+#ifdef USE_GPU_POINT_LINK
+
 static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index)
 {
 	GPUVertPointLink *lnk;
@@ -404,6 +412,19 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in
 	lnk->point_index = point_index;
 }
 
+#else
+
+static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, int point_index)
+{
+	GPUVertPointLink *lnk;
+	lnk = &gdo->vert_points[vert_index];
+	if (lnk->point_index == -1) {
+		lnk->point_index = point_index;
+	}
+}
+
+#endif  /* USE_GPU_POINT_LINK */
+
 /* update the vert_points and triangle_to_mface fields with a new
  * triangle */
 static void gpu_drawobject_add_triangle(GPUDrawObject *gdo,
@@ -427,11 +448,13 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
 	mat_orig_to_new = MEM_callocN(sizeof(*mat_orig_to_new) * totmat,
 	                                             "GPUDrawObject.mat_orig_to_new");
 	/* allocate the array and space for links */
-	gdo->vert_points = MEM_callocN(sizeof(GPUVertPointLink) * gdo->totvert,
+	gdo->vert_points = MEM_mallocN(sizeof(GPUVertPointLink) * gdo->totvert,
 	                               "GPUDrawObject.vert_points");
+#ifdef USE_GPU_POINT_LINK
 	gdo->vert_points_mem = MEM_callocN(sizeof(GPUVertPointLink) * gdo->tot_triangle_point,
 	                                   "GPUDrawObject.vert_points_mem");
 	gdo->vert_points_usage = 0;
+#endif
 
 	/* build a map from the original material indices to the new
 	 * GPUBufferMaterial indices */
@@ -439,8 +462,12 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to
 		mat_orig_to_new[gdo->materials[i].mat_nr] = i;
 
 	/* -1 indicates the link is not yet used */
-	for (i = 0; i < gdo->totvert; i++)
+	for (i = 0; i < gdo->totvert; i++) {
+#ifdef USE_GPU_POINT_LINK
+		gdo->vert_points[i].link = NULL;
+#endif
 		gdo->vert_points[i].point_index = -1;
+	}
 
 	for (i = 0; i < totface; i++, f++) {
 		mat = &gdo->materials[mat_orig_to_new[f->mat_nr]];
@@ -540,7 +567,9 @@ void GPU_drawobject_free(DerivedMesh *dm)
 	MEM_freeN(gdo->materials);
 	MEM_freeN(gdo->triangle_to_mface);
 	MEM_freeN(gdo->vert_points);
+#ifdef USE_GPU_POINT_LINK
 	MEM_freeN(gdo->vert_points_mem);
+#endif
 	GPU_buffer_free(gdo->points);
 	GPU_buffer_free(gdo->normals);
 	GPU_buffer_free(gdo->uv);




More information about the Bf-blender-cvs mailing list