[Bf-blender-cvs] [1178265] GPU_data_request: minor cleanup

Mike Erwin noreply at git.blender.org
Thu Apr 23 11:03:56 CEST 2015


Commit: 1178265b0d2d425d4de184a53f76386758fa4f62
Author: Mike Erwin
Date:   Thu Apr 23 05:00:22 2015 -0400
Branches: GPU_data_request
https://developer.blender.org/rB1178265b0d2d425d4de184a53f76386758fa4f62

minor cleanup

Mostly moving stuff to where it belongs.

UNUSED_VARS macro explains intent better than (void)var, so use it.

Considered replacing calloc with malloc for ElementList.indices, but
it’s safer to zero this in case not all primitives are set. So calloc
it stays!

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

M	source/blender/gpu/intern/gpux_element.c
M	source/blender/gpu/intern/gpux_vbo.c

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

diff --git a/source/blender/gpu/intern/gpux_element.c b/source/blender/gpu/intern/gpux_element.c
index 1864b68..9b1efd9 100644
--- a/source/blender/gpu/intern/gpux_element.c
+++ b/source/blender/gpu/intern/gpux_element.c
@@ -1,6 +1,7 @@
 
 #include "gpux_element_private.h"
 #include "gpux_buffer_id.h"
+#include "BLI_utildefines.h"
 #include "MEM_guardedalloc.h"
 
 #ifdef USE_ELEM_VBO
@@ -79,7 +80,6 @@ ElementList *GPUx_element_list_create(GLenum prim_type, unsigned prim_ct, unsign
 #endif /* TRACK_INDEX_RANGE */
 
 	el->indices = MEM_callocN(GPUx_element_list_size(el), "ElementList.indices");
-	/* TODO: use only one calloc, not two */
 
 	return el;
 }
@@ -232,7 +232,7 @@ void GPUx_set_triangle_vertices(ElementList *el, unsigned prim_idx, unsigned v1,
 
 void GPUx_optimize(ElementList *el)
 {
-	(void)el;
+	UNUSED_VARS(el);
 
 	/* TODO: apply Forsyth's vertex cache algorithm */
 	
@@ -265,7 +265,7 @@ void GPUx_element_list_prime(ElementList *el)
   #endif /* KEEP_SINGLE_COPY */
 	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 #else
-	(void)el;
+	UNUSED_VARS(el);
 #endif /* USE_ELEM_VBO */
 }
 
@@ -277,13 +277,13 @@ void GPUx_element_list_use_primed(const ElementList *el)
   #endif /* TRUST_NO_ONE */
 	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, el->vbo_id);
 #else
-	(void)el;
+	UNUSED_VARS(el);
 #endif /* USE_ELEM_VBO */
 }
 
 void GPUx_element_list_done_using(const ElementList *el)
 {
-	(void)el;
+	UNUSED_VARS(el);
 #ifdef USE_ELEM_VBO
 	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
 #endif /* USE_ELEM_VBO */
diff --git a/source/blender/gpu/intern/gpux_vbo.c b/source/blender/gpu/intern/gpux_vbo.c
index 6beec63..008b76b 100644
--- a/source/blender/gpu/intern/gpux_vbo.c
+++ b/source/blender/gpu/intern/gpux_vbo.c
@@ -1,18 +1,23 @@
 
 #include "GPUx_vbo.h"
 #include "gpux_buffer_id.h"
+#include "BLI_utildefines.h"
 #include "MEM_guardedalloc.h"
 #include <string.h>
 
+#ifdef PRINT
+  #include <stdio.h>
+#endif
+
 /* VBOs are guaranteed for any GL >= 1.5
  * They can be turned off here (mostly for comparison). */
 #define USE_VBO
 
-/* VAOs are part of GL 3.0, and optionally available in 2.1 as an extension:
- * APPLE_vertex_array_object or ARB_vertex_array_object
- * the ARB version of VAOs *must* use VBOs for vertex data
- * so we should follow that restriction on all platforms. */
 #ifdef USE_VBO
+  /* VAOs are part of GL 3.0, and optionally available in 2.1 as an extension:
+   * APPLE_vertex_array_object or ARB_vertex_array_object
+   * the ARB version of VAOs *must* use VBOs for vertex data
+   * so we should follow that restriction on all platforms. */
   #define USE_VAO
 
   /* keep vertex data in main mem or VRAM (not both) */
@@ -26,14 +31,6 @@
   #endif
 #endif
 
-#ifdef TRUST_NO_ONE
-  #include "BLI_utildefines.h"
-#endif /* TRUST_NO_ONE */
-
-#ifdef PRINT
-  #include <stdio.h>
-#endif /* PRINT */
-
 typedef unsigned char byte;
 
 typedef struct {
@@ -451,9 +448,6 @@ void GPUx_vertex_buffer_prime(VertexBuffer *buff)
 	glBindVertexArray(buff->vao_id);
 #endif /* USE_VAO */
 
-	(void)a_idx; /* avoid unused warnings */
-	(void)buff;
-
 #ifdef USE_VBO
 	for (a_idx = 0; a_idx < buff->attrib_ct; ++a_idx) {
 		Attrib *a = buff->attribs + a_idx;
@@ -515,6 +509,8 @@ void GPUx_vertex_buffer_prime(VertexBuffer *buff)
 	}
 
 	glBindBuffer(GL_ARRAY_BUFFER, 0);
+#else
+	UNUSED_VARS(a_idx, buff);
 #endif /* USE_VBO */
 
 #ifdef USE_VAO
@@ -596,7 +592,7 @@ void GPUx_vertex_buffer_use_primed(const VertexBuffer *buff)
 void GPUx_vertex_buffer_done_using(const VertexBuffer *buff)
 {
 #ifdef USE_VAO
-	(void)buff;
+	UNUSED_VARS(buff);
 	glBindVertexArray(0);
 #else
 	unsigned int a_idx;




More information about the Bf-blender-cvs mailing list