| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							| 
									
										
										
										
											2011-11-29 10:54:47 +00:00
										 |  |  |  * of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2005 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is: all of this file. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Brecht Van Lommel. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-27 20:25:53 +00:00
										 |  |  | /** \file blender/gpu/intern/gpu_buffers.c
 | 
					
						
							|  |  |  |  *  \ingroup gpu | 
					
						
							| 
									
										
										
										
											2014-01-19 23:14:24 +11:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Mesh drawing using OpenGL VBO (Vertex Buffer Objects), | 
					
						
							|  |  |  |  * with fall-back to vertex arrays. | 
					
						
							| 
									
										
										
										
											2011-02-27 20:25:53 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | #include <limits.h>
 | 
					
						
							| 
									
										
										
										
											2009-11-25 18:20:46 +00:00
										 |  |  | #include <stddef.h>
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | #include <string.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-07 15:46:19 -05:00
										 |  |  | #include "GPU_glew.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | #include "BLI_bitmap.h"
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | #include "BLI_math.h"
 | 
					
						
							| 
									
										
										
										
											2011-01-07 18:36:47 +00:00
										 |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | #include "BLI_ghash.h"
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | #include "BLI_threads.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_meshdata_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | #include "BKE_ccg.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | #include "BKE_DerivedMesh.h"
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | #include "BKE_paint.h"
 | 
					
						
							| 
									
										
										
										
											2014-05-05 22:21:30 +03:00
										 |  |  | #include "BKE_pbvh.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "DNA_userdef_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-14 10:46:12 +00:00
										 |  |  | #include "GPU_buffers.h"
 | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | #include "GPU_draw.h"
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | #include "bmesh.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | typedef enum { | 
					
						
							| 
									
										
										
										
											2014-09-02 15:57:22 +02:00
										 |  |  | 	GPU_BUFFER_VERTEX_STATE = (1 << 0), | 
					
						
							|  |  |  | 	GPU_BUFFER_NORMAL_STATE = (1 << 1), | 
					
						
							|  |  |  | 	GPU_BUFFER_TEXCOORD_UNIT_0_STATE = (1 << 2), | 
					
						
							|  |  |  | 	GPU_BUFFER_TEXCOORD_UNIT_2_STATE = (1 << 3), | 
					
						
							|  |  |  | 	GPU_BUFFER_COLOR_STATE = (1 << 4), | 
					
						
							|  |  |  | 	GPU_BUFFER_ELEMENT_STATE = (1 << 5), | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } GPUBufferState; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  | 	GLenum gl_buffer_type; | 
					
						
							|  |  |  | 	int num_components; /* number of data components for one vertex */ | 
					
						
							|  |  |  | } GPUBufferTypeSettings; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 12:25:05 +02:00
										 |  |  | static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const GPUBufferTypeSettings gpu_buffer_type_settings[] = { | 
					
						
							|  |  |  |     /* vertex */ | 
					
						
							|  |  |  |     {GL_ARRAY_BUFFER_ARB, 3}, | 
					
						
							|  |  |  |     /* normal */ | 
					
						
							|  |  |  |     {GL_ARRAY_BUFFER_ARB, 4}, /* we copy 3 shorts per normal but we add a fourth for alignment */ | 
					
						
							|  |  |  |     /* mcol */ | 
					
						
							|  |  |  |     {GL_ARRAY_BUFFER_ARB, 3}, | 
					
						
							|  |  |  |     /* uv */ | 
					
						
							|  |  |  |     {GL_ARRAY_BUFFER_ARB, 2}, | 
					
						
							|  |  |  |     /* uv for texpaint */ | 
					
						
							|  |  |  |     {GL_ARRAY_BUFFER_ARB, 4}, | 
					
						
							|  |  |  |     /* edge */ | 
					
						
							|  |  |  |     {GL_ELEMENT_ARRAY_BUFFER_ARB, 2}, | 
					
						
							|  |  |  |     /* uv edge */ | 
					
						
							|  |  |  |     {GL_ELEMENT_ARRAY_BUFFER_ARB, 4}, | 
					
						
							|  |  |  |     /* triangles, 1 point since we are allocating from tottriangle points, which account for all points */ | 
					
						
							|  |  |  |     {GL_ELEMENT_ARRAY_BUFFER_ARB, 1}, | 
					
						
							|  |  |  |     /* fast triangles */ | 
					
						
							|  |  |  |     {GL_ELEMENT_ARRAY_BUFFER_ARB, 1}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | #define MAX_GPU_ATTRIB_DATA 32
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | #define BUFFER_OFFSET(n) ((GLubyte *)NULL + (n))
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | /* -1 - undefined, 0 - vertex arrays, 1 - VBOs */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBufferState GLStates = 0; | 
					
						
							| 
									
										
										
										
											2011-02-13 14:16:36 +00:00
										 |  |  | static GPUAttrib attribData[MAX_GPU_ATTRIB_DATA] = { { -1, 0, 0 } }; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | static ThreadMutex buffer_mutex = BLI_MUTEX_INITIALIZER; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | /* multires global buffer, can be used for many grids having the same grid size */ | 
					
						
							|  |  |  | static GPUBuffer *mres_glob_buffer = NULL; | 
					
						
							|  |  |  | static int mres_prev_gridsize = -1; | 
					
						
							|  |  |  | static GLenum mres_prev_index_type = 0; | 
					
						
							|  |  |  | static unsigned mres_prev_totquad = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* stores recently-deleted buffers so that new buffers won't have to
 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  |  * be recreated as often | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * only one instance of this pool is created, stored in | 
					
						
							|  |  |  |  * gpu_buffer_pool | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * note that the number of buffers in the pool is usually limited to | 
					
						
							|  |  |  |  * MAX_FREE_GPU_BUFFERS, but this limit may be exceeded temporarily | 
					
						
							|  |  |  |  * when a GPUBuffer is released outside the main thread; due to OpenGL | 
					
						
							|  |  |  |  * restrictions it cannot be immediately released | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | typedef struct GPUBufferPool { | 
					
						
							|  |  |  | 	/* number of allocated buffers stored */ | 
					
						
							|  |  |  | 	int totbuf; | 
					
						
							| 
									
										
										
										
											2014-01-05 04:58:27 +02:00
										 |  |  | 	/* actual allocated length of the arrays */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	int maxsize; | 
					
						
							|  |  |  | 	GPUBuffer **buffers; | 
					
						
							|  |  |  | } GPUBufferPool; | 
					
						
							|  |  |  | #define MAX_FREE_GPU_BUFFERS 8
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* create a new GPUBufferPool */ | 
					
						
							|  |  |  | static GPUBufferPool *gpu_buffer_pool_new(void) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUBufferPool *pool; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-22 17:33:58 +00:00
										 |  |  | 	pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer_Pool"); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 	pool->maxsize = MAX_FREE_GPU_BUFFERS; | 
					
						
							| 
									
										
										
										
											2014-04-09 09:30:00 +10:00
										 |  |  | 	pool->buffers = MEM_mallocN(sizeof(*pool->buffers) * pool->maxsize, | 
					
						
							|  |  |  | 	                            "GPUBufferPool.buffers"); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	return pool; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* remove a GPUBuffer from the pool (does not free the GPUBuffer) */ | 
					
						
							|  |  |  | static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!pool || index < 0 || index >= pool->totbuf) | 
					
						
							| 
									
										
										
										
											2010-02-17 18:48:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* shift entries down, overwriting the buffer at `index' */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = index; i < pool->totbuf - 1; i++) | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		pool->buffers[i] = pool->buffers[i + 1]; | 
					
						
							| 
									
										
										
										
											2010-02-15 19:09:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* clear the last entry */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (pool->totbuf > 0) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		pool->buffers[pool->totbuf - 1] = NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pool->totbuf--; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* delete the last entry in the pool */ | 
					
						
							|  |  |  | static void gpu_buffer_pool_delete_last(GPUBufferPool *pool) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUBuffer *last; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (pool->totbuf <= 0) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* get the last entry */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!(last = pool->buffers[pool->totbuf - 1])) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* delete the buffer's data */ | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (last->use_vbo) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDeleteBuffersARB(1, &last->id); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		MEM_freeN(last->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* delete the buffer and remove from pool */ | 
					
						
							|  |  |  | 	MEM_freeN(last); | 
					
						
							|  |  |  | 	pool->totbuf--; | 
					
						
							|  |  |  | 	pool->buffers[pool->totbuf] = NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* free a GPUBufferPool; also frees the data in the pool's
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * GPUBuffers */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static void gpu_buffer_pool_free(GPUBufferPool *pool) | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!pool) | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 	while (pool->totbuf) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		gpu_buffer_pool_delete_last(pool); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	MEM_freeN(pool->buffers); | 
					
						
							|  |  |  | 	MEM_freeN(pool); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-09 19:55:43 +00:00
										 |  |  | static void gpu_buffer_pool_free_unused(GPUBufferPool *pool) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!pool) | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2014-02-07 13:33:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	BLI_mutex_lock(&buffer_mutex); | 
					
						
							| 
									
										
										
										
											2013-08-09 19:55:43 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	while (pool->totbuf) | 
					
						
							|  |  |  | 		gpu_buffer_pool_delete_last(pool); | 
					
						
							| 
									
										
										
										
											2014-01-05 04:58:27 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-07 13:33:15 +01:00
										 |  |  | 	BLI_mutex_unlock(&buffer_mutex); | 
					
						
							| 
									
										
										
										
											2013-08-09 19:55:43 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBufferPool *gpu_buffer_pool = NULL; | 
					
						
							|  |  |  | static GPUBufferPool *gpu_get_global_buffer_pool(void) | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* initialize the pool */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_pool) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		gpu_buffer_pool = gpu_buffer_pool_new(); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return gpu_buffer_pool; | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_global_buffer_pool_free(void) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	gpu_buffer_pool_free(gpu_buffer_pool); | 
					
						
							|  |  |  | 	gpu_buffer_pool = NULL; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-09 19:55:43 +00:00
										 |  |  | void GPU_global_buffer_pool_free_unused(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	gpu_buffer_pool_free_unused(gpu_buffer_pool); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get a GPUBuffer of at least `size' bytes; uses one from the buffer
 | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  |  * pool if possible, otherwise creates a new one | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Thread-unsafe version for internal usage only. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | static GPUBuffer *gpu_buffer_alloc_intern(size_t size, bool use_VBO) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUBufferPool *pool; | 
					
						
							|  |  |  | 	GPUBuffer *buf; | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	int i, bestfit = -1; | 
					
						
							|  |  |  | 	size_t bufsize; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-22 17:33:58 +00:00
										 |  |  | 	/* bad case, leads to leak of buf since buf->pointer will allocate
 | 
					
						
							|  |  |  | 	 * NULL, leading to return without cleanup. In any case better detect early | 
					
						
							|  |  |  | 	 * psy-fi */ | 
					
						
							| 
									
										
										
										
											2012-05-22 22:03:41 +00:00
										 |  |  | 	if (size == 0) | 
					
						
							| 
									
										
										
										
											2012-05-22 17:33:58 +00:00
										 |  |  | 		return NULL; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	pool = gpu_get_global_buffer_pool(); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* not sure if this buffer pool code has been profiled much,
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * seems to me that the graphics driver and system memory | 
					
						
							|  |  |  | 	 * management might do this stuff anyway. --nicholas | 
					
						
							|  |  |  | 	 */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* check the global buffer pool for a recently-deleted buffer
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * that is at least as big as the request, but not more than | 
					
						
							|  |  |  | 	 * twice as big */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < pool->totbuf; i++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		bufsize = pool->buffers[i]->size; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		/* only return a buffer that matches the VBO preference */ | 
					
						
							| 
									
										
										
										
											2015-02-11 18:38:41 +11:00
										 |  |  | 		if (pool->buffers[i]->use_vbo != use_VBO) { | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 			 continue; | 
					
						
							| 
									
										
										
										
											2015-02-11 18:38:41 +11:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* check for an exact size match */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (bufsize == size) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			bestfit = i; | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* smaller buffers won't fit data and buffers at least
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * twice as big are a waste of memory */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		else if (bufsize > size && size > (bufsize / 2)) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* is it closer to the required size than the
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 			 * last appropriate buffer found. try to save | 
					
						
							|  |  |  | 			 * memory */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (bestfit == -1 || pool->buffers[bestfit]->size > bufsize) { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 				bestfit = i; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* if an acceptable buffer was found in the pool, remove it
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * from the pool and return it */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (bestfit != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		buf = pool->buffers[bestfit]; | 
					
						
							|  |  |  | 		gpu_buffer_pool_remove_index(pool, bestfit); | 
					
						
							|  |  |  | 		return buf; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* no acceptable buffer found in the pool, create a new one */ | 
					
						
							|  |  |  | 	buf = MEM_callocN(sizeof(GPUBuffer), "GPUBuffer"); | 
					
						
							|  |  |  | 	buf->size = size; | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	buf->use_vbo = use_VBO; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (use_VBO) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* create a new VBO and initialize it to the requested
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * size */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glGenBuffersARB(1, &buf->id); | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buf->id); | 
					
						
							| 
									
										
										
										
											2011-09-16 08:20:21 +00:00
										 |  |  | 		glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		static int time = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer"); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		time++; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* purpose of this seems to be dealing with
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * out-of-memory errors? looks a bit iffy to me | 
					
						
							|  |  |  | 		 * though, at least on Linux I expect malloc() would | 
					
						
							|  |  |  | 		 * just overcommit. --nicholas */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		while (!buf->pointer && pool->totbuf > 0) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gpu_buffer_pool_delete_last(pool); | 
					
						
							|  |  |  | 			buf->pointer = MEM_mallocN(size, "GPUBuffer.pointer"); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (!buf->pointer) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			return NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return buf; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | /* Same as above, but safe for threading. */ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | GPUBuffer *GPU_buffer_alloc(size_t size, bool force_vertex_arrays) | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUBuffer *buffer; | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	bool use_VBOs = (GLEW_ARB_vertex_buffer_object) && !(U.gameflags & USER_DISABLE_VBO) && !force_vertex_arrays; | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (size == 0) { | 
					
						
							|  |  |  | 		/* Early out, no lock needed in this case. */ | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BLI_mutex_lock(&buffer_mutex); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	buffer = gpu_buffer_alloc_intern(size, use_VBOs); | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | 	BLI_mutex_unlock(&buffer_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return buffer; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* release a GPUBuffer; does not free the actual buffer or its data,
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * but rather moves it to the pool of recently-freed buffers for | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  |  * possible re-use | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Thread-unsafe version for internal usage only. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | static void gpu_buffer_free_intern(GPUBuffer *buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUBufferPool *pool; | 
					
						
							| 
									
										
										
										
											2010-02-17 18:48:02 +00:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	pool = gpu_get_global_buffer_pool(); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 	/* free the last used buffer in the queue if no more space, but only
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 	 * if we are in the main thread. for e.g. rendering or baking it can | 
					
						
							|  |  |  | 	 * happen that we are in other thread and can't call OpenGL, in that | 
					
						
							|  |  |  | 	 * case cleanup will be done GPU_buffer_pool_free_unused */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (BLI_thread_is_main()) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* in main thread, safe to decrease size of pool back
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * down to MAX_FREE_GPU_BUFFERS */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		while (pool->totbuf >= MAX_FREE_GPU_BUFFERS) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			gpu_buffer_pool_delete_last(pool); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* outside of main thread, can't safely delete the
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * buffer, so increase pool size */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (pool->maxsize == pool->totbuf) { | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 			pool->maxsize += MAX_FREE_GPU_BUFFERS; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			pool->buffers = MEM_reallocN(pool->buffers, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			                             sizeof(GPUBuffer *) * pool->maxsize); | 
					
						
							| 
									
										
										
										
											2010-07-13 13:31:43 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* shift pool entries up by one */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = pool->totbuf; i > 0; i--) | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		pool->buffers[i] = pool->buffers[i - 1]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* insert the buffer into the beginning of the pool */ | 
					
						
							| 
									
										
										
										
											2010-02-17 18:48:02 +00:00
										 |  |  | 	pool->buffers[0] = buffer; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	pool->totbuf++; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | /* Same as above, but safe for threading. */ | 
					
						
							|  |  |  | void GPU_buffer_free(GPUBuffer *buffer) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!buffer) { | 
					
						
							|  |  |  | 		/* Early output, no need to lock in this case, */ | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BLI_mutex_lock(&buffer_mutex); | 
					
						
							|  |  |  | 	gpu_buffer_free_intern(buffer); | 
					
						
							|  |  |  | 	BLI_mutex_unlock(&buffer_mutex); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | void GPU_buffer_multires_free(bool force) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!mres_glob_buffer) { | 
					
						
							|  |  |  | 		/* Early output, no need to lock in this case, */ | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (force && BLI_thread_is_main()) { | 
					
						
							|  |  |  | 		if (mres_glob_buffer) { | 
					
						
							|  |  |  | 			if (mres_glob_buffer->id) | 
					
						
							|  |  |  | 				glDeleteBuffersARB(1, &mres_glob_buffer->id); | 
					
						
							|  |  |  | 			else if (mres_glob_buffer->pointer) | 
					
						
							|  |  |  | 				MEM_freeN(mres_glob_buffer->pointer); | 
					
						
							|  |  |  | 			MEM_freeN(mres_glob_buffer); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		BLI_mutex_lock(&buffer_mutex); | 
					
						
							|  |  |  | 		gpu_buffer_free_intern(mres_glob_buffer); | 
					
						
							|  |  |  | 		BLI_mutex_unlock(&buffer_mutex); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mres_glob_buffer = NULL; | 
					
						
							|  |  |  | 	mres_prev_gridsize = -1; | 
					
						
							|  |  |  | 	mres_prev_index_type = 0; | 
					
						
							|  |  |  | 	mres_prev_totquad = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_drawobject_free(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPUDrawObject *gdo; | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!dm || !(gdo = dm->drawObject)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	for (i = 0; i < gdo->totmaterial; i++) { | 
					
						
							|  |  |  | 		if (gdo->materials[i].polys) | 
					
						
							|  |  |  | 			MEM_freeN(gdo->materials[i].polys); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MEM_freeN(gdo->materials); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	if (gdo->vert_points) | 
					
						
							|  |  |  | 		MEM_freeN(gdo->vert_points); | 
					
						
							| 
									
										
										
										
											2014-04-09 15:38:37 +10:00
										 |  |  | #ifdef USE_GPU_POINT_LINK
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	MEM_freeN(gdo->vert_points_mem); | 
					
						
							| 
									
										
										
										
											2014-04-09 15:38:37 +10:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPU_buffer_free(gdo->points); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->normals); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->uv); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	GPU_buffer_free(gdo->uv_tex); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GPU_buffer_free(gdo->colors); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->edges); | 
					
						
							|  |  |  | 	GPU_buffer_free(gdo->uvedges); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	GPU_buffer_free(gdo->triangles); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	MEM_freeN(gdo); | 
					
						
							|  |  |  | 	dm->drawObject = NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 12:25:05 +02:00
										 |  |  | static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t size, bool use_VBOs) | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	gpu_buffer_free_intern(buffer); | 
					
						
							|  |  |  | 	gpu_buffer_pool_delete_last(pool); | 
					
						
							|  |  |  | 	buffer = NULL; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	/* try freeing an entry from the pool
 | 
					
						
							|  |  |  | 	 * and reallocating the buffer */ | 
					
						
							|  |  |  | 	if (pool->totbuf > 0) { | 
					
						
							|  |  |  | 		gpu_buffer_pool_delete_last(pool); | 
					
						
							|  |  |  | 		buffer = gpu_buffer_alloc_intern(size, use_VBOs); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	return buffer; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  |                                    int type, void *user) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	GPUBufferPool *pool; | 
					
						
							|  |  |  | 	GPUBuffer *buffer; | 
					
						
							|  |  |  | 	float *varray; | 
					
						
							| 
									
										
										
										
											2014-04-09 04:42:26 +03:00
										 |  |  | 	int *mat_orig_to_new; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	int i; | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	const GPUBufferTypeSettings *ts = &gpu_buffer_type_settings[type]; | 
					
						
							|  |  |  | 	GLenum target = ts->gl_buffer_type; | 
					
						
							|  |  |  | 	int num_components = ts->num_components; | 
					
						
							| 
									
										
										
										
											2015-07-17 12:25:05 +02:00
										 |  |  | 	size_t size = gpu_buffer_size_from_type(dm, type); | 
					
						
							| 
									
										
										
										
											2014-12-03 20:20:04 +01:00
										 |  |  | 	bool use_VBOs = (GLEW_ARB_vertex_buffer_object) && !(U.gameflags & USER_DISABLE_VBO); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GLboolean uploaded; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	pool = gpu_get_global_buffer_pool(); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | 	BLI_mutex_lock(&buffer_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* alloc a GPUBuffer; fall back to legacy mode on failure */ | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (!(buffer = gpu_buffer_alloc_intern(size, use_VBOs))) { | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | 		BLI_mutex_unlock(&buffer_mutex); | 
					
						
							| 
									
										
										
										
											2011-09-16 08:20:21 +00:00
										 |  |  | 		return NULL; | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-09 04:42:26 +03:00
										 |  |  | 	mat_orig_to_new = MEM_mallocN(sizeof(*mat_orig_to_new) * dm->totmat, | 
					
						
							| 
									
										
										
										
											2014-08-05 13:36:35 +10:00
										 |  |  | 	                              "GPU_buffer_setup.mat_orig_to_new"); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < object->totmaterial; i++) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* for each material, the current index to copy data to */ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		object->materials[i].counter = object->materials[i].start * num_components; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* map from original material index to new
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 		 * GPUBufferMaterial index */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		mat_orig_to_new[object->materials[i].mat_nr] = i; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (use_VBOs) { | 
					
						
							|  |  |  | 		bool success = false; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 		while (!success) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			/* bind the buffer and discard previous data,
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 			 * avoids stalling gpu */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glBindBufferARB(target, buffer->id); | 
					
						
							| 
									
										
										
										
											2011-09-16 08:20:21 +00:00
										 |  |  | 			glBufferDataARB(target, buffer->size, NULL, GL_STATIC_DRAW_ARB); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			/* attempt to map the buffer */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (!(varray = glMapBufferARB(target, GL_WRITE_ONLY_ARB))) { | 
					
						
							| 
									
										
										
										
											2015-02-11 18:38:41 +11:00
										 |  |  | 				buffer = gpu_try_realloc(pool, buffer, size, true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				/* allocation still failed; fall back
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 				 * to legacy mode */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (!buffer) { | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 					use_VBOs = false; | 
					
						
							|  |  |  | 					success = true; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 				success = true; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* check legacy fallback didn't happen */ | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		if (use_VBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			uploaded = GL_FALSE; | 
					
						
							|  |  |  | 			/* attempt to upload the data to the VBO */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | 			while (uploaded == GL_FALSE) { | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 				dm->copy_gpu_data(dm, type, varray, mat_orig_to_new, user); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				/* glUnmapBuffer returns GL_FALSE if
 | 
					
						
							| 
									
										
										
										
											2011-11-11 13:09:14 +00:00
										 |  |  | 				 * the data store is corrupted; retry | 
					
						
							|  |  |  | 				 * in that case */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				uploaded = glUnmapBufferARB(target); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		glBindBufferARB(target, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (!use_VBOs) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* VBO not supported, use vertex array fallback */ | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		if (!buffer || !buffer->pointer) { | 
					
						
							|  |  |  | 			buffer = gpu_try_realloc(pool, buffer, size, false); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		if (buffer) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			varray = buffer->pointer; | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			dm->copy_gpu_data(dm, type, varray, mat_orig_to_new, user); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-09 04:42:26 +03:00
										 |  |  | 	MEM_freeN(mat_orig_to_new); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-19 10:06:05 +00:00
										 |  |  | 	BLI_mutex_unlock(&buffer_mutex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return buffer; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get the GPUDrawObject buffer associated with a type */ | 
					
						
							|  |  |  | static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (type) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_VERTEX: | 
					
						
							|  |  |  | 			return &gdo->points; | 
					
						
							|  |  |  | 		case GPU_BUFFER_NORMAL: | 
					
						
							|  |  |  | 			return &gdo->normals; | 
					
						
							|  |  |  | 		case GPU_BUFFER_COLOR: | 
					
						
							|  |  |  | 			return &gdo->colors; | 
					
						
							|  |  |  | 		case GPU_BUFFER_UV: | 
					
						
							|  |  |  | 			return &gdo->uv; | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		case GPU_BUFFER_UV_TEXPAINT: | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 			return &gdo->uv_tex; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_EDGE: | 
					
						
							|  |  |  | 			return &gdo->edges; | 
					
						
							|  |  |  | 		case GPU_BUFFER_UVEDGE: | 
					
						
							|  |  |  | 			return &gdo->uvedges; | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		case GPU_BUFFER_TRIANGLES: | 
					
						
							|  |  |  | 			return &gdo->triangles; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		default: | 
					
						
							|  |  |  | 			return NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get the amount of space to allocate for a buffer of a particular type */ | 
					
						
							| 
									
										
										
										
											2015-07-17 12:25:05 +02:00
										 |  |  | static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type) | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (type) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_VERTEX: | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(float) * gpu_buffer_type_settings[type].num_components * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_NORMAL: | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(short) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_COLOR: | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(char) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_UV: | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(float) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point; | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		case GPU_BUFFER_UV_TEXPAINT: | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(float) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_EDGE: | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(int) * gpu_buffer_type_settings[type].num_components * dm->drawObject->totedge; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GPU_BUFFER_UVEDGE: | 
					
						
							|  |  |  | 			/* each face gets 3 points, 3 edges per triangle, and
 | 
					
						
							|  |  |  | 			 * each edge has its own, non-shared coords, so each | 
					
						
							|  |  |  | 			 * tri corner needs minimum of 4 floats, quads used | 
					
						
							|  |  |  | 			 * less so here we can over allocate and assume all | 
					
						
							|  |  |  | 			 * tris. */ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 			return sizeof(int) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point; | 
					
						
							|  |  |  | 		case GPU_BUFFER_TRIANGLES: | 
					
						
							|  |  |  | 			return sizeof(int) * gpu_buffer_type_settings[type].num_components * dm->drawObject->tot_triangle_point; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		default: | 
					
						
							|  |  |  | 			return -1; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* call gpu_buffer_setup with settings for a particular type of buffer */ | 
					
						
							|  |  |  | static GPUBuffer *gpu_buffer_setup_type(DerivedMesh *dm, GPUBufferType type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	void *user_data = NULL; | 
					
						
							|  |  |  | 	GPUBuffer *buf; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* special handling for MCol and UV buffers */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (type == GPU_BUFFER_COLOR) { | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 		if (!(user_data = DM_get_loop_data_layer(dm, dm->drawObject->colType))) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 	else if (ELEM(type, GPU_BUFFER_UV, GPU_BUFFER_UV_TEXPAINT)) { | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 		if (!DM_get_loop_data_layer(dm, CD_MLOOPUV)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			return NULL; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	buf = gpu_buffer_setup(dm, dm->drawObject, type, user_data); | 
					
						
							| 
									
										
										
										
											2010-01-31 15:06:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return buf; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* get the buffer of `type', initializing the GPUDrawObject and
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * buffer if needed */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | static GPUBuffer *gpu_buffer_setup_common(DerivedMesh *dm, GPUBufferType type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	GPUBuffer **buf; | 
					
						
							| 
									
										
										
										
											2012-10-29 16:26:18 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!dm->drawObject) | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		dm->drawObject = dm->gpuObjectNew(dm); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	buf = gpu_drawobject_buffer_from_type(dm->drawObject, type); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!(*buf)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		*buf = gpu_buffer_setup_type(dm, type); | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	return *buf; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_vertex_setup(DerivedMesh *dm) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-12-09 15:20:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->points->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->points->id); | 
					
						
							|  |  |  | 		glVertexPointer(3, GL_FLOAT, 0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		glVertexPointer(3, GL_FLOAT, 0, dm->drawObject->points->pointer); | 
					
						
							| 
									
										
										
										
											2009-11-25 13:40:43 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_VERTEX_STATE; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_normal_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_NORMAL)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_NORMAL_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->normals->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->normals->id); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		glNormalPointer(GL_SHORT, 4 * sizeof(short), 0); | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		glNormalPointer(GL_SHORT, 4 * sizeof(short), dm->drawObject->normals->pointer); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_NORMAL_STATE; | 
					
						
							| 
									
										
										
										
											2009-10-27 19:53:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_uv_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->uv->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uv->id); | 
					
						
							|  |  |  | 		glTexCoordPointer(2, GL_FLOAT, 0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		glTexCoordPointer(2, GL_FLOAT, 0, dm->drawObject->uv->pointer); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 	GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | void GPU_texpaint_uv_setup(DerivedMesh *dm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UV_TEXPAINT)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->uv_tex->use_vbo) { | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uv_tex->id); | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), 0); | 
					
						
							| 
									
										
										
										
											2014-09-02 15:57:22 +02:00
										 |  |  | 		glClientActiveTexture(GL_TEXTURE2); | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							|  |  |  | 		glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), BUFFER_OFFSET(2 * sizeof(float))); | 
					
						
							|  |  |  | 		glClientActiveTexture(GL_TEXTURE0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), dm->drawObject->uv_tex->pointer); | 
					
						
							| 
									
										
										
										
											2014-09-02 15:57:22 +02:00
										 |  |  | 		glClientActiveTexture(GL_TEXTURE2); | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		glEnableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), (char *)dm->drawObject->uv_tex->pointer + 2 * sizeof(float)); | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		glClientActiveTexture(GL_TEXTURE0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-02 15:57:22 +02:00
										 |  |  | 	GLStates |= GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE; | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-30 11:00:06 +00:00
										 |  |  | void GPU_color_setup(DerivedMesh *dm, int colType) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-30 11:00:06 +00:00
										 |  |  | 	if (!dm->drawObject) { | 
					
						
							|  |  |  | 		/* XXX Not really nice, but we need a valid gpu draw object to set the colType...
 | 
					
						
							|  |  |  | 		 *     Else we would have to add a new param to gpu_buffer_setup_common. */ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		dm->drawObject = dm->gpuObjectNew(dm); | 
					
						
							| 
									
										
										
										
											2012-10-30 11:00:06 +00:00
										 |  |  | 		dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW; | 
					
						
							|  |  |  | 		dm->drawObject->colType = colType; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* In paint mode, dm may stay the same during stroke, however we still want to update colors!
 | 
					
						
							|  |  |  | 	 * Also check in case we changed color type (i.e. which MCol cdlayer we use). */ | 
					
						
							|  |  |  | 	else if ((dm->dirty & DM_DIRTY_MCOL_UPDATE_DRAW) || (colType != dm->drawObject->colType)) { | 
					
						
							| 
									
										
										
										
											2012-10-29 16:26:18 +00:00
										 |  |  | 		GPUBuffer **buf = gpu_drawobject_buffer_from_type(dm->drawObject, GPU_BUFFER_COLOR); | 
					
						
							| 
									
										
										
										
											2012-10-30 11:00:06 +00:00
										 |  |  | 		/* XXX Freeing this buffer is a bit stupid, as geometry has not changed, size should remain the same.
 | 
					
						
							|  |  |  | 		 *     Not sure though it would be worth defining a sort of gpu_buffer_update func - nor whether | 
					
						
							|  |  |  | 		 *     it is even possible ! */ | 
					
						
							| 
									
										
										
										
											2012-10-29 16:26:18 +00:00
										 |  |  | 		GPU_buffer_free(*buf); | 
					
						
							|  |  |  | 		*buf = NULL; | 
					
						
							| 
									
										
										
										
											2012-10-30 11:00:06 +00:00
										 |  |  | 		dm->dirty &= ~DM_DIRTY_MCOL_UPDATE_DRAW; | 
					
						
							|  |  |  | 		dm->drawObject->colType = colType; | 
					
						
							| 
									
										
										
										
											2012-10-29 16:26:18 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_COLOR)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->colors->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->colors->id); | 
					
						
							|  |  |  | 		glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		glColorPointer(3, GL_UNSIGNED_BYTE, 0, dm->drawObject->colors->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GLStates |= GPU_BUFFER_COLOR_STATE; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-15 18:50:02 +02:00
										 |  |  | void GPU_buffer_bind_as_color(GPUBuffer *buffer) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							|  |  |  | 	if (buffer->use_vbo) { | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); | 
					
						
							|  |  |  | 		glColorPointer(4, GL_UNSIGNED_BYTE, 0, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		glColorPointer(4, GL_UNSIGNED_BYTE, 0, buffer->pointer); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_COLOR_STATE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_edge_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_EDGE)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_VERTEX)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-12-16 20:20:28 +01:00
										 |  |  | 	if (dm->drawObject->points->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->points->id); | 
					
						
							|  |  |  | 		glVertexPointer(3, GL_FLOAT, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glVertexPointer(3, GL_FLOAT, 0, dm->drawObject->points->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_VERTEX_STATE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->edges->use_vbo) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, dm->drawObject->edges->id); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_ELEMENT_STATE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_uvedge_setup(DerivedMesh *dm) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_UVEDGE)) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (dm->drawObject->uvedges->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, dm->drawObject->uvedges->id); | 
					
						
							|  |  |  | 		glVertexPointer(2, GL_FLOAT, 0, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glVertexPointer(2, GL_FLOAT, 0, dm->drawObject->uvedges->pointer); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_VERTEX_STATE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | void GPU_triangle_setup(struct DerivedMesh *dm) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (!gpu_buffer_setup_common(dm, GPU_BUFFER_TRIANGLES)) | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (dm->drawObject->triangles->use_vbo) { | 
					
						
							|  |  |  | 		glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, dm->drawObject->triangles->id); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	GLStates |= GPU_BUFFER_ELEMENT_STATE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | static int GPU_typesize(int type) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-04-28 06:31:57 +00:00
										 |  |  | 	switch (type) { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 		case GL_FLOAT: | 
					
						
							|  |  |  | 			return sizeof(float); | 
					
						
							|  |  |  | 		case GL_INT: | 
					
						
							|  |  |  | 			return sizeof(int); | 
					
						
							|  |  |  | 		case GL_UNSIGNED_INT: | 
					
						
							|  |  |  | 			return sizeof(unsigned int); | 
					
						
							|  |  |  | 		case GL_BYTE: | 
					
						
							|  |  |  | 			return sizeof(char); | 
					
						
							|  |  |  | 		case GL_UNSIGNED_BYTE: | 
					
						
							|  |  |  | 			return sizeof(unsigned char); | 
					
						
							|  |  |  | 		default: | 
					
						
							|  |  |  | 			return 0; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | int GPU_attrib_element_size(GPUAttrib data[], int numdata) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	int i, elementsize = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < numdata; i++) { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		int typesize = GPU_typesize(data[i].type); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (typesize != 0) | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 			elementsize += typesize * data[i].size; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return elementsize; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata, int element_size) | 
					
						
							| 
									
										
										
										
											2011-09-28 05:53:40 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	int i; | 
					
						
							|  |  |  | 	int elementsize; | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | 	intptr_t offset = 0; | 
					
						
							| 
									
										
										
										
											2014-12-12 17:59:06 +01:00
										 |  |  | 	char *basep; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | 
					
						
							|  |  |  | 		if (attribData[i].index != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDisableVertexAttribArrayARB(attribData[i].index); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	if (element_size == 0) | 
					
						
							|  |  |  | 		elementsize = GPU_attrib_element_size(data, numdata); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		elementsize = element_size; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (buffer->use_vbo) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffer->id); | 
					
						
							| 
									
										
										
										
											2014-12-12 17:59:06 +01:00
										 |  |  | 		basep = NULL; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2014-12-12 17:59:06 +01:00
										 |  |  | 		basep = buffer->pointer; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-12-12 17:59:06 +01:00
										 |  |  | 	 | 
					
						
							|  |  |  | 	for (i = 0; i < numdata; i++) { | 
					
						
							|  |  |  | 		glEnableVertexAttribArrayARB(data[i].index); | 
					
						
							|  |  |  | 		glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, | 
					
						
							|  |  |  | 		                         GL_FALSE, elementsize, (void *)(basep + offset)); | 
					
						
							|  |  |  | 		offset += data[i].size * GPU_typesize(data[i].type); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		attribData[i].index = data[i].index; | 
					
						
							|  |  |  | 		attribData[i].size = data[i].size; | 
					
						
							|  |  |  | 		attribData[i].type = data[i].type; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	attribData[numdata].index = -1;	 | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | void GPU_interleaved_attrib_unbind(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							|  |  |  | 	for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | 
					
						
							|  |  |  | 		if (attribData[i].index != -1) { | 
					
						
							|  |  |  | 			glDisableVertexAttribArrayARB(attribData[i].index); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	attribData[0].index = -1; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 12:12:28 +02:00
										 |  |  | void GPU_buffers_unbind(void) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int i; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_VERTEX_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_NORMAL_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_NORMAL_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 	if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_0_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							| 
									
										
										
										
											2014-09-02 15:57:22 +02:00
										 |  |  | 	if (GLStates & GPU_BUFFER_TEXCOORD_UNIT_2_STATE) { | 
					
						
							|  |  |  | 		glClientActiveTexture(GL_TEXTURE2); | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 		glDisableClientState(GL_TEXTURE_COORD_ARRAY); | 
					
						
							|  |  |  | 		glClientActiveTexture(GL_TEXTURE0); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_COLOR_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (GLStates & GPU_BUFFER_ELEMENT_STATE) { | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 		/* not guaranteed we used VBOs but in that case it's just a no-op */ | 
					
						
							|  |  |  | 		if (GLEW_ARB_vertex_buffer_object) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-06-05 08:41:53 +00:00
										 |  |  | 	GLStates &= ~(GPU_BUFFER_VERTEX_STATE | GPU_BUFFER_NORMAL_STATE | | 
					
						
							| 
									
										
										
										
											2014-09-02 15:57:22 +02:00
										 |  |  | 	              GPU_BUFFER_TEXCOORD_UNIT_0_STATE | GPU_BUFFER_TEXCOORD_UNIT_2_STATE | | 
					
						
							| 
									
										
										
										
											2014-07-21 12:02:05 +02:00
										 |  |  | 	              GPU_BUFFER_COLOR_STATE | GPU_BUFFER_ELEMENT_STATE); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	for (i = 0; i < MAX_GPU_ATTRIB_DATA; i++) { | 
					
						
							|  |  |  | 		if (attribData[i].index != -1) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDisableVertexAttribArrayARB(attribData[i].index); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-03-16 12:14:13 +01:00
										 |  |  | 	attribData[0].index = -1; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	/* not guaranteed we used VBOs but in that case it's just a no-op */ | 
					
						
							|  |  |  | 	if (GLEW_ARB_vertex_buffer_object) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | void GPU_color_switch(int mode) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (mode) { | 
					
						
							|  |  |  | 		if (!(GLStates & GPU_BUFFER_COLOR_STATE)) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		GLStates |= GPU_BUFFER_COLOR_STATE; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (GLStates & GPU_BUFFER_COLOR_STATE) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-06-05 08:41:53 +00:00
										 |  |  | 		GLStates &= ~GPU_BUFFER_COLOR_STATE; | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | static int gpu_binding_type_gl[] = | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	GL_ARRAY_BUFFER_ARB, | 
					
						
							|  |  |  | 	GL_ELEMENT_ARRAY_BUFFER_ARB | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void *GPU_buffer_lock(GPUBuffer *buffer, GPUBindingType binding) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float *varray; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (buffer->use_vbo) { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		int bindtypegl = gpu_binding_type_gl[binding]; | 
					
						
							|  |  |  | 		glBindBufferARB(bindtypegl, buffer->id); | 
					
						
							|  |  |  | 		varray = glMapBufferARB(bindtypegl, GL_WRITE_ONLY_ARB); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return varray; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return buffer->pointer; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | void *GPU_buffer_lock_stream(GPUBuffer *buffer, GPUBindingType binding) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float *varray; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (!buffer) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (buffer->use_vbo) { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		int bindtypegl = gpu_binding_type_gl[binding]; | 
					
						
							|  |  |  | 		glBindBufferARB(bindtypegl, buffer->id); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* discard previous data, avoid stalling gpu */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		glBufferDataARB(bindtypegl, buffer->size, 0, GL_STREAM_DRAW_ARB); | 
					
						
							|  |  |  | 		varray = glMapBufferARB(bindtypegl, GL_WRITE_ONLY_ARB); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 		return varray; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		return buffer->pointer; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | void GPU_buffer_unlock(GPUBuffer *buffer, GPUBindingType binding) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	if (buffer->use_vbo) { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		int bindtypegl = gpu_binding_type_gl[binding]; | 
					
						
							| 
									
										
										
										
											2014-12-16 12:09:24 +01:00
										 |  |  | 		/* note: this operation can fail, could return
 | 
					
						
							|  |  |  | 		 * an error code from this function? */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		glUnmapBufferARB(bindtypegl); | 
					
						
							|  |  |  | 		glBindBufferARB(bindtypegl, 0); | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | void GPU_buffer_bind(GPUBuffer *buffer, GPUBindingType binding) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (buffer->use_vbo) { | 
					
						
							|  |  |  | 		int bindtypegl = gpu_binding_type_gl[binding]; | 
					
						
							|  |  |  | 		glBindBufferARB(bindtypegl, buffer->id); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 12:12:28 +02:00
										 |  |  | void GPU_buffer_unbind(GPUBuffer *buffer, GPUBindingType binding) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	if (buffer->use_vbo) { | 
					
						
							|  |  |  | 		int bindtypegl = gpu_binding_type_gl[binding]; | 
					
						
							|  |  |  | 		glBindBufferARB(bindtypegl, 0); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | /* used for drawing edges */ | 
					
						
							|  |  |  | void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glDrawElements(mode, count, GL_UNSIGNED_INT, | 
					
						
							| 
									
										
										
										
											2014-11-28 14:38:18 +01:00
										 |  |  | 	               (elements->use_vbo ? | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	                (void *)(start * sizeof(unsigned int)) : | 
					
						
							|  |  |  | 	                ((int *)elements->pointer) + start)); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* XXX: the rest of the code in this file is used for optimized PBVH
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * drawing and doesn't interact at all with the buffer code above */ | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Convenience struct for building the VBO. */ | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	float co[3]; | 
					
						
							|  |  |  | 	short no[3]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* inserting this to align the 'color' field to a four-byte
 | 
					
						
							| 
									
										
										
										
											2012-05-16 23:37:23 +00:00
										 |  |  | 	 * boundary; drastically increases viewport performance on my | 
					
						
							|  |  |  | 	 * drivers (Gallium/Radeon) --nicholasbishop */ | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	char pad[2]; | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	unsigned char color[3]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } VertexBufferFormat; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | struct GPU_PBVH_Buffers { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* opengl buffer handles */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	GPUBuffer *vert_buf, *index_buf, *index_buf_fast; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	GLenum index_type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* mesh pointers in case buffer allocation fails */ | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	const MPoly *mpoly; | 
					
						
							|  |  |  | 	const MLoop *mloop; | 
					
						
							|  |  |  | 	const MLoopTri *looptri; | 
					
						
							| 
									
										
										
										
											2015-07-11 03:25:28 +10:00
										 |  |  | 	const MVert *mvert; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-27 00:24:11 +10:00
										 |  |  | 	const int *face_indices; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	int        face_indices_len; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	const float *vmask; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* grid pointers */ | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 	CCGKey gridkey; | 
					
						
							|  |  |  | 	CCGElem **grids; | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	const DMFlagMat *grid_flag_mats; | 
					
						
							| 
									
										
										
										
											2013-07-22 23:20:48 +00:00
										 |  |  | 	BLI_bitmap * const *grid_hidden; | 
					
						
							| 
									
										
										
										
											2014-04-27 00:24:11 +10:00
										 |  |  | 	const int *grid_indices; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	int totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	int has_hidden; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	int use_bmesh; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	unsigned int tot_tri, tot_quad; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:42:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* The PBVH ensures that either all faces in the node are
 | 
					
						
							| 
									
										
										
										
											2013-06-06 06:02:46 +00:00
										 |  |  | 	 * smooth-shaded or all faces are flat-shaded */ | 
					
						
							| 
									
										
										
										
											2012-10-06 16:42:11 +00:00
										 |  |  | 	int smooth; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	bool show_diffuse_color; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	bool use_matcaps; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	float diffuse_color[4]; | 
					
						
							| 
									
										
										
										
											2011-11-05 03:29:37 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | typedef enum { | 
					
						
							|  |  |  | 	VBO_ENABLED, | 
					
						
							|  |  |  | 	VBO_DISABLED | 
					
						
							|  |  |  | } VBO_State; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_colors_enable(VBO_State vbo_state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); | 
					
						
							|  |  |  | 	glEnable(GL_COLOR_MATERIAL); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	if (vbo_state == VBO_ENABLED) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 		glEnableClientState(GL_COLOR_ARRAY); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_colors_disable(VBO_State vbo_state) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glDisable(GL_COLOR_MATERIAL); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	if (vbo_state == VBO_ENABLED) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 		glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static float gpu_color_from_mask(float mask) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	return 1.0f - mask * 0.75f; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | static void gpu_color_from_mask_copy(float mask, const float diffuse_color[4], unsigned char out[3]) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	float mask_color; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	mask_color = gpu_color_from_mask(mask) * 255.0f; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	out[0] = diffuse_color[0] * mask_color; | 
					
						
							|  |  |  | 	out[1] = diffuse_color[1] * mask_color; | 
					
						
							|  |  |  | 	out[2] = diffuse_color[2] * mask_color; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void gpu_color_from_mask_quad_copy(const CCGKey *key, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                           CCGElem *a, CCGElem *b, | 
					
						
							|  |  |  |                                           CCGElem *c, CCGElem *d, | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  |                                           const float *diffuse_color, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  |                                           unsigned char out[3]) | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	float mask_color = | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	    gpu_color_from_mask((*CCG_elem_mask(key, a) + | 
					
						
							|  |  |  | 	                         *CCG_elem_mask(key, b) + | 
					
						
							|  |  |  | 	                         *CCG_elem_mask(key, c) + | 
					
						
							|  |  |  | 	                         *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	out[0] = diffuse_color[0] * mask_color; | 
					
						
							|  |  |  | 	out[1] = diffuse_color[1] * mask_color; | 
					
						
							|  |  |  | 	out[2] = diffuse_color[2] * mask_color; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-11 03:25:28 +10:00
										 |  |  | void GPU_update_mesh_pbvh_buffers( | 
					
						
							|  |  |  |         GPU_PBVH_Buffers *buffers, const MVert *mvert, | 
					
						
							|  |  |  |         const int *vert_indices, int totvert, const float *vmask, | 
					
						
							|  |  |  |         const int (*face_vert_indices)[4], bool show_diffuse_color) | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	VertexBufferFormat *vert_data; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	int i, j; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 	buffers->vmask = vmask; | 
					
						
							| 
									
										
										
										
											2014-04-01 20:17:23 +03:00
										 |  |  | 	buffers->show_diffuse_color = show_diffuse_color; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	buffers->use_matcaps = GPU_material_use_matcaps_get(); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 		int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3)); | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 		float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 0.8f}; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 		if (buffers->use_matcaps) | 
					
						
							|  |  |  | 			diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0; | 
					
						
							|  |  |  | 		else if (show_diffuse_color) { | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 			const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; | 
					
						
							|  |  |  | 			const MPoly *mp = &buffers->mpoly[lt->poly]; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 			GPU_material_diffuse_get(mp->mat_nr + 1, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		copy_v4_v4(buffers->diffuse_color, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* Build VBO */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		if (buffers->vert_buf) | 
					
						
							|  |  |  | 			GPU_buffer_free(buffers->vert_buf); | 
					
						
							|  |  |  | 		buffers->vert_buf = GPU_buffer_alloc(sizeof(VertexBufferFormat) * totelem, false); | 
					
						
							|  |  |  | 		vert_data = GPU_buffer_lock(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (vert_data) { | 
					
						
							| 
									
										
										
										
											2013-02-03 10:28:28 +00:00
										 |  |  | 			/* Vertex data is shared if smooth-shaded, but separate
 | 
					
						
							| 
									
										
										
										
											2013-06-06 06:02:46 +00:00
										 |  |  | 			 * copies are made for flat shading because normals | 
					
						
							|  |  |  | 			 * shouldn't be shared. */ | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 			if (buffers->smooth) { | 
					
						
							|  |  |  | 				for (i = 0; i < totvert; ++i) { | 
					
						
							| 
									
										
										
										
											2015-07-11 03:25:28 +10:00
										 |  |  | 					const MVert *v = &mvert[vert_indices[i]]; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 					VertexBufferFormat *out = vert_data + i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					copy_v3_v3(out->co, v->co); | 
					
						
							|  |  |  | 					memcpy(out->no, v->no, sizeof(short) * 3); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define UPDATE_VERTEX(face, vertex, index, diffuse_color) \
 | 
					
						
							|  |  |  | 				{ \ | 
					
						
							|  |  |  | 					VertexBufferFormat *out = vert_data + face_vert_indices[face][index]; \ | 
					
						
							|  |  |  | 					if (vmask) \ | 
					
						
							|  |  |  | 						gpu_color_from_mask_copy(vmask[vertex], diffuse_color, out->color); \ | 
					
						
							|  |  |  | 					else \ | 
					
						
							|  |  |  | 						rgb_float_to_uchar(out->color, diffuse_color); \ | 
					
						
							|  |  |  | 				} (void)0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 				for (i = 0; i < buffers->face_indices_len; i++) { | 
					
						
							|  |  |  | 					const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; | 
					
						
							|  |  |  | 					const unsigned int vtri[3] = { | 
					
						
							|  |  |  | 					    buffers->mloop[lt->tri[0]].v, | 
					
						
							|  |  |  | 					    buffers->mloop[lt->tri[1]].v, | 
					
						
							|  |  |  | 					    buffers->mloop[lt->tri[2]].v, | 
					
						
							|  |  |  | 					}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					UPDATE_VERTEX(i, vtri[0], 0, diffuse_color); | 
					
						
							|  |  |  | 					UPDATE_VERTEX(i, vtri[1], 1, diffuse_color); | 
					
						
							|  |  |  | 					UPDATE_VERTEX(i, vtri[2], 2, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | #undef UPDATE_VERTEX
 | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			else { | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 				for (i = 0; i < buffers->face_indices_len; ++i) { | 
					
						
							|  |  |  | 					const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]]; | 
					
						
							|  |  |  | 					const unsigned int vtri[3] = { | 
					
						
							|  |  |  | 					    buffers->mloop[lt->tri[0]].v, | 
					
						
							|  |  |  | 					    buffers->mloop[lt->tri[1]].v, | 
					
						
							|  |  |  | 					    buffers->mloop[lt->tri[2]].v, | 
					
						
							|  |  |  | 					}; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 					float fno[3]; | 
					
						
							|  |  |  | 					short no[3]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					float fmask; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 					if (paint_is_face_hidden(lt, mvert, buffers->mloop)) | 
					
						
							| 
									
										
										
										
											2012-10-23 11:07:05 +00:00
										 |  |  | 						continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 					/* Face normal and mask */ | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 					normal_tri_v3(fno, | 
					
						
							|  |  |  | 					              mvert[vtri[0]].co, | 
					
						
							|  |  |  | 					              mvert[vtri[1]].co, | 
					
						
							|  |  |  | 					              mvert[vtri[2]].co); | 
					
						
							|  |  |  | 					if (vmask) { | 
					
						
							|  |  |  | 						fmask = (vmask[vtri[0]] + | 
					
						
							|  |  |  | 						         vmask[vtri[1]] + | 
					
						
							|  |  |  | 						         vmask[vtri[2]]) / 3.0f; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					normal_float_to_short_v3(no, fno); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 					for (j = 0; j < 3; j++) { | 
					
						
							|  |  |  | 						const MVert *v = &mvert[vtri[j]]; | 
					
						
							|  |  |  | 						VertexBufferFormat *out = vert_data; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 						copy_v3_v3(out->co, v->co); | 
					
						
							|  |  |  | 						copy_v3_v3_short(out->no, no); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 						if (vmask) | 
					
						
							|  |  |  | 							gpu_color_from_mask_copy(fmask, diffuse_color, out->color); | 
					
						
							|  |  |  | 						else | 
					
						
							|  |  |  | 							rgb_float_to_uchar(out->color, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 						vert_data++; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 					} | 
					
						
							| 
									
										
										
										
											2012-10-01 05:19:57 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_unlock(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->vert_buf); | 
					
						
							|  |  |  | 			buffers->vert_buf = NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	buffers->mvert = mvert; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers( | 
					
						
							|  |  |  |         const int (*face_vert_indices)[4], | 
					
						
							|  |  |  |         const MPoly *mpoly, const MLoop *mloop, const MLoopTri *looptri, | 
					
						
							|  |  |  |         const MVert *mvert, | 
					
						
							| 
									
										
										
										
											2015-07-11 03:25:28 +10:00
										 |  |  |         const int *face_indices, | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  |         const int  face_indices_len) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | 	GPU_PBVH_Buffers *buffers; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	unsigned short *tri_data; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	int i, j, tottri; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | 	buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers"); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	buffers->index_type = GL_UNSIGNED_SHORT; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	buffers->smooth = mpoly[face_indices[0]].flag & ME_SMOOTH; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	buffers->show_diffuse_color = false; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	buffers->use_matcaps = false; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	/* Count the number of visible triangles */ | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	for (i = 0, tottri = 0; i < face_indices_len; ++i) { | 
					
						
							|  |  |  | 		const MLoopTri *lt = &looptri[face_indices[i]]; | 
					
						
							|  |  |  | 		if (!paint_is_face_hidden(lt, mvert, mloop)) | 
					
						
							|  |  |  | 			tottri++; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-05 21:13:27 +03:00
										 |  |  | 	if (tottri == 0) { | 
					
						
							|  |  |  | 		buffers->tot_tri = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 		buffers->mpoly = mpoly; | 
					
						
							|  |  |  | 		buffers->mloop = mloop; | 
					
						
							|  |  |  | 		buffers->looptri = looptri; | 
					
						
							| 
									
										
										
										
											2014-05-05 21:13:27 +03:00
										 |  |  | 		buffers->face_indices = face_indices; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 		buffers->face_indices_len = 0; | 
					
						
							| 
									
										
										
										
											2014-05-05 21:13:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		return buffers; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 	/* An element index buffer is used for smooth shading, but flat
 | 
					
						
							| 
									
										
										
										
											2013-06-06 06:02:46 +00:00
										 |  |  | 	 * shading requires separate vertex normals so an index buffer is | 
					
						
							|  |  |  | 	 * can't be used there. */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	if (buffers->smooth) | 
					
						
							|  |  |  | 		buffers->index_buf = GPU_buffer_alloc(sizeof(unsigned short) * tottri * 3, false); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->index_buf) { | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		/* Fill the triangle buffer */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		tri_data = GPU_buffer_lock(buffers->index_buf, GPU_BINDING_INDEX); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (tri_data) { | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 			for (i = 0; i < face_indices_len; ++i) { | 
					
						
							|  |  |  | 				const MLoopTri *lt = &looptri[face_indices[i]]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 				/* Skip hidden faces */ | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 				if (paint_is_face_hidden(lt, mvert, mloop)) | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 					continue; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 				for (j = 0; j < 3; ++j) { | 
					
						
							|  |  |  | 					*tri_data = face_vert_indices[i][j]; | 
					
						
							|  |  |  | 					tri_data++; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_unlock(buffers->index_buf, GPU_BINDING_INDEX); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->index_buf); | 
					
						
							|  |  |  | 			buffers->index_buf = NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2009-10-03 15:35:01 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	buffers->tot_tri = tottri; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	buffers->mpoly = mpoly; | 
					
						
							|  |  |  | 	buffers->mloop = mloop; | 
					
						
							|  |  |  | 	buffers->looptri = looptri; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	buffers->face_indices = face_indices; | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	buffers->face_indices_len = face_indices_len; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return buffers; | 
					
						
							| 
									
										
										
										
											2009-10-05 16:48:52 +00:00
										 |  |  | } | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, CCGElem **grids, | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |                                   const DMFlagMat *grid_flag_mats, int *grid_indices, | 
					
						
							|  |  |  |                                   int totgrid, const CCGKey *key, bool show_diffuse_color) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 	VertexBufferFormat *vert_data; | 
					
						
							|  |  |  | 	int i, j, k, x, y; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 20:17:23 +03:00
										 |  |  | 	buffers->show_diffuse_color = show_diffuse_color; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	buffers->use_matcaps = GPU_material_use_matcaps_get(); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	/* Build VBO */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->vert_buf) { | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 		int smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; | 
					
						
							| 
									
										
										
										
											2012-10-01 05:19:57 +00:00
										 |  |  | 		const int has_mask = key->has_mask; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 		float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 		if (buffers->use_matcaps) | 
					
						
							|  |  |  | 			diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0; | 
					
						
							|  |  |  | 		else if (show_diffuse_color) { | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 			const DMFlagMat *flags = &grid_flag_mats[grid_indices[0]]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		copy_v4_v4(buffers->diffuse_color, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		vert_data = GPU_buffer_lock_stream(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (vert_data) { | 
					
						
							|  |  |  | 			for (i = 0; i < totgrid; ++i) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				VertexBufferFormat *vd = vert_data; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				CCGElem *grid = grids[grid_indices[i]]; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				for (y = 0; y < key->grid_size; y++) { | 
					
						
							|  |  |  | 					for (x = 0; x < key->grid_size; x++) { | 
					
						
							|  |  |  | 						CCGElem *elem = CCG_grid_elem(key, grid, x, y); | 
					
						
							|  |  |  | 						 | 
					
						
							|  |  |  | 						copy_v3_v3(vd->co, CCG_elem_co(key, elem)); | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 						if (smooth) { | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 							normal_float_to_short_v3(vd->no, CCG_elem_no(key, elem)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-01 05:19:57 +00:00
										 |  |  | 							if (has_mask) { | 
					
						
							|  |  |  | 								gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 								                         diffuse_color, vd->color); | 
					
						
							| 
									
										
										
										
											2012-10-01 05:19:57 +00:00
										 |  |  | 							} | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 						vd++; | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (!smooth) { | 
					
						
							| 
									
										
										
										
											2014-03-29 11:56:32 +02:00
										 |  |  | 					/* for flat shading, recalc normals and set the last vertex of
 | 
					
						
							|  |  |  | 					 * each triangle in the index buffer to have the flat normal as | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  | 					 * that is what opengl will use */ | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 					for (j = 0; j < key->grid_size - 1; j++) { | 
					
						
							|  |  |  | 						for (k = 0; k < key->grid_size - 1; k++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 							CCGElem *elems[4] = { | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 								CCG_grid_elem(key, grid, k, j + 1), | 
					
						
							|  |  |  | 								CCG_grid_elem(key, grid, k + 1, j + 1), | 
					
						
							|  |  |  | 								CCG_grid_elem(key, grid, k + 1, j), | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 								CCG_grid_elem(key, grid, k, j) | 
					
						
							|  |  |  | 							}; | 
					
						
							| 
									
										
										
										
											2012-02-28 05:00:28 +00:00
										 |  |  | 							float fno[3]; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-28 05:00:28 +00:00
										 |  |  | 							normal_quad_v3(fno, | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 							               CCG_elem_co(key, elems[0]), | 
					
						
							|  |  |  | 							               CCG_elem_co(key, elems[1]), | 
					
						
							|  |  |  | 							               CCG_elem_co(key, elems[2]), | 
					
						
							|  |  |  | 							               CCG_elem_co(key, elems[3])); | 
					
						
							| 
									
										
										
										
											2012-02-28 05:00:28 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-29 11:39:25 +02:00
										 |  |  | 							vd = vert_data + (j + 1) * key->grid_size + k; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 							normal_float_to_short_v3(vd->no, fno); | 
					
						
							| 
									
										
										
										
											2012-10-01 05:19:57 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 							if (has_mask) { | 
					
						
							|  |  |  | 								gpu_color_from_mask_quad_copy(key, | 
					
						
							|  |  |  | 								                              elems[0], | 
					
						
							|  |  |  | 								                              elems[1], | 
					
						
							|  |  |  | 								                              elems[2], | 
					
						
							|  |  |  | 								                              elems[3], | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 								                              diffuse_color, | 
					
						
							| 
									
										
										
										
											2012-10-01 05:19:57 +00:00
										 |  |  | 								                              vd->color); | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 						} | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				vert_data += key->grid_area; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			GPU_buffer_unlock(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->vert_buf); | 
					
						
							|  |  |  | 			buffers->vert_buf = NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	buffers->grids = grids; | 
					
						
							|  |  |  | 	buffers->grid_indices = grid_indices; | 
					
						
							|  |  |  | 	buffers->totgrid = totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 	buffers->grid_flag_mats = grid_flag_mats; | 
					
						
							| 
									
										
										
										
											2012-05-10 20:33:09 +00:00
										 |  |  | 	buffers->gridkey = *key; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-06 16:42:11 +00:00
										 |  |  | 	buffers->smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-02 19:01:16 +00:00
										 |  |  | 	//printf("node updated %p\n", buffers);
 | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | /* Build the element array buffer of grid indices using either
 | 
					
						
							| 
									
										
										
										
											2012-04-22 11:54:53 +00:00
										 |  |  |  * unsigned shorts or unsigned ints. */ | 
					
						
							| 
									
										
										
										
											2012-03-24 07:36:32 +00:00
										 |  |  | #define FILL_QUAD_BUFFER(type_, tot_quad_, buffer_)                     \
 | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |     {                                                                   \ | 
					
						
							|  |  |  |         type_ *tri_data;                                                \ | 
					
						
							|  |  |  |         int offset = 0;                                                 \ | 
					
						
							|  |  |  |         int i, j, k;                                                    \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |         buffer_ = GPU_buffer_alloc(sizeof(type_) * (tot_quad_) * 6,     \ | 
					
						
							|  |  |  |                                   false);                               \ | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |                                                                         \ | 
					
						
							|  |  |  |         /* Fill the buffer */                                           \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |         tri_data = GPU_buffer_lock(buffer_, GPU_BINDING_INDEX);         \ | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |         if (tri_data) {                                                 \ | 
					
						
							|  |  |  |             for (i = 0; i < totgrid; ++i) {                             \ | 
					
						
							|  |  |  |                 BLI_bitmap *gh = NULL;                                  \ | 
					
						
							|  |  |  |                 if (grid_hidden)                                        \ | 
					
						
							|  |  |  |                     gh = grid_hidden[(grid_indices)[i]];                \ | 
					
						
							|  |  |  |                                                                         \ | 
					
						
							|  |  |  |                 for (j = 0; j < gridsize - 1; ++j) {                    \ | 
					
						
							|  |  |  |                     for (k = 0; k < gridsize - 1; ++k) {                \ | 
					
						
							|  |  |  |                         /* Skip hidden grid face */                     \ | 
					
						
							|  |  |  |                         if (gh &&                                       \ | 
					
						
							|  |  |  |                             paint_is_grid_face_hidden(gh,               \ | 
					
						
							|  |  |  |                                                       gridsize, k, j))  \ | 
					
						
							|  |  |  |                             continue;                                    \ | 
					
						
							|  |  |  |                                                                           \ | 
					
						
							|  |  |  |                         *(tri_data++) = offset + j * gridsize + k + 1;     \ | 
					
						
							|  |  |  |                         *(tri_data++) = offset + j * gridsize + k;          \ | 
					
						
							|  |  |  |                         *(tri_data++) = offset + (j + 1) * gridsize + k;     \ | 
					
						
							|  |  |  |                                                                              \ | 
					
						
							|  |  |  |                         *(tri_data++) = offset + (j + 1) * gridsize + k + 1; \ | 
					
						
							|  |  |  |                         *(tri_data++) = offset + j * gridsize + k + 1;       \ | 
					
						
							|  |  |  |                         *(tri_data++) = offset + (j + 1) * gridsize + k;    \ | 
					
						
							|  |  |  |                     }                                                      \ | 
					
						
							|  |  |  |                 }                                                         \ | 
					
						
							|  |  |  |                                                                          \ | 
					
						
							|  |  |  |                 offset += gridsize * gridsize;                          \ | 
					
						
							|  |  |  |             }                                                           \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |             GPU_buffer_unlock(buffer_, GPU_BINDING_INDEX);                         \ | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |         }                                                               \ | 
					
						
							|  |  |  |         else {                                                          \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |             GPU_buffer_free(buffer_);                                   \ | 
					
						
							|  |  |  |             (buffer_) = NULL;                                           \ | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |         }                                                               \ | 
					
						
							|  |  |  |     } (void)0 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | /* end FILL_QUAD_BUFFER */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | static GPUBuffer *gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *totquad) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	/* used in the FILL_QUAD_BUFFER macro */ | 
					
						
							| 
									
										
										
										
											2013-07-22 23:20:48 +00:00
										 |  |  | 	BLI_bitmap * const *grid_hidden = NULL; | 
					
						
							| 
									
										
										
										
											2014-04-27 00:24:11 +10:00
										 |  |  | 	const int *grid_indices = NULL; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	int totgrid = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	/* VBO is already built */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	if (mres_glob_buffer && mres_prev_gridsize == gridsize) { | 
					
						
							|  |  |  | 		*index_type = mres_prev_index_type; | 
					
						
							|  |  |  | 		*totquad = mres_prev_totquad; | 
					
						
							|  |  |  | 		return mres_glob_buffer; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	/* we can't reuse old, delete the existing buffer */ | 
					
						
							|  |  |  | 	else if (mres_glob_buffer) { | 
					
						
							|  |  |  | 		GPU_buffer_free(mres_glob_buffer); | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 	/* Build new VBO */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	*totquad = (gridsize - 1) * (gridsize - 1); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	if (gridsize * gridsize < USHRT_MAX) { | 
					
						
							|  |  |  | 		*index_type = GL_UNSIGNED_SHORT; | 
					
						
							|  |  |  | 		FILL_QUAD_BUFFER(unsigned short, *totquad, mres_glob_buffer); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		*index_type = GL_UNSIGNED_INT; | 
					
						
							|  |  |  | 		FILL_QUAD_BUFFER(unsigned int, *totquad, mres_glob_buffer); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	mres_prev_gridsize = gridsize; | 
					
						
							|  |  |  | 	mres_prev_index_type = *index_type; | 
					
						
							|  |  |  | 	mres_prev_totquad = *totquad; | 
					
						
							|  |  |  | 	return mres_glob_buffer; | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | #define FILL_FAST_BUFFER(type_) \
 | 
					
						
							|  |  |  | { \ | 
					
						
							|  |  |  |     type_ *buffer; \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |     buffers->index_buf_fast = GPU_buffer_alloc(sizeof(type_) * 6 * totgrid, false); \ | 
					
						
							|  |  |  |     buffer = GPU_buffer_lock(buffers->index_buf_fast, GPU_BINDING_INDEX); \ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  |     if (buffer) { \ | 
					
						
							|  |  |  |         int i; \ | 
					
						
							|  |  |  |         for (i = 0; i < totgrid; i++) { \ | 
					
						
							|  |  |  |             int currentquad = i * 6; \ | 
					
						
							|  |  |  |             buffer[currentquad] = i * gridsize * gridsize; \ | 
					
						
							|  |  |  |             buffer[currentquad + 1] = i * gridsize * gridsize + gridsize - 1; \ | 
					
						
							|  |  |  |             buffer[currentquad + 2] = (i + 1) * gridsize * gridsize - gridsize; \ | 
					
						
							|  |  |  |             buffer[currentquad + 3] = (i + 1) * gridsize * gridsize - 1; \ | 
					
						
							|  |  |  |             buffer[currentquad + 4] = i * gridsize * gridsize + gridsize - 1; \ | 
					
						
							|  |  |  |             buffer[currentquad + 5] = (i + 1) * gridsize * gridsize - gridsize; \ | 
					
						
							|  |  |  |         } \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |         GPU_buffer_unlock(buffers->index_buf_fast, GPU_BINDING_INDEX); \ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	} \ | 
					
						
							|  |  |  | 	else { \ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |         GPU_buffer_free(buffers->index_buf_fast); \ | 
					
						
							|  |  |  |         buffers->index_buf_fast = NULL; \ | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  |     } \ | 
					
						
							|  |  |  | } (void)0 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers(int *grid_indices, int totgrid, | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  |                                               BLI_bitmap **grid_hidden, int gridsize, const CCGKey *key) | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | 	GPU_PBVH_Buffers *buffers; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	int totquad; | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 	int fully_visible_totquad = (gridsize - 1) * (gridsize - 1) * totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | 	buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers"); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	buffers->grid_hidden = grid_hidden; | 
					
						
							|  |  |  | 	buffers->totgrid = totgrid; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	buffers->show_diffuse_color = false; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	buffers->use_matcaps = false; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 	/* Count the number of quads */ | 
					
						
							| 
									
										
										
										
											2014-05-05 22:21:30 +03:00
										 |  |  | 	totquad = BKE_pbvh_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-05 21:13:27 +03:00
										 |  |  | 	/* totally hidden node, return here to avoid BufferData with zero below. */ | 
					
						
							|  |  |  | 	if (totquad == 0) | 
					
						
							|  |  |  | 		return buffers; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	/* create and fill indices of the fast buffer too */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	if (totgrid * gridsize * gridsize < USHRT_MAX) { | 
					
						
							|  |  |  | 		FILL_FAST_BUFFER(unsigned short); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		FILL_FAST_BUFFER(unsigned int); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (totquad == fully_visible_totquad) { | 
					
						
							| 
									
										
										
										
											2012-03-16 04:11:35 +00:00
										 |  |  | 		buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		buffers->has_hidden = 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		buffers->tot_quad = totquad; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		if (totgrid * gridsize * gridsize < USHRT_MAX) { | 
					
						
							|  |  |  | 			buffers->index_type = GL_UNSIGNED_SHORT; | 
					
						
							|  |  |  | 			FILL_QUAD_BUFFER(unsigned short, totquad, buffers->index_buf); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			buffers->index_type = GL_UNSIGNED_INT; | 
					
						
							|  |  |  | 			FILL_QUAD_BUFFER(unsigned int, totquad, buffers->index_buf); | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		buffers->has_hidden = 1; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Build coord/normal VBO */ | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers->index_buf) | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		buffers->vert_buf = GPU_buffer_alloc(sizeof(VertexBufferFormat) * totgrid * key->grid_area, false); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return buffers; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-22 23:30:56 +00:00
										 |  |  | #undef FILL_QUAD_BUFFER
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | /* Output a BMVert into a VertexBufferFormat array
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The vertex is skipped if hidden, otherwise the output goes into | 
					
						
							|  |  |  |  * index '*v_index' in the 'vert_data' array and '*v_index' is | 
					
						
							|  |  |  |  * incremented. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | static void gpu_bmesh_vert_to_buffer_copy(BMVert *v, | 
					
						
							|  |  |  |                                           VertexBufferFormat *vert_data, | 
					
						
							|  |  |  |                                           int *v_index, | 
					
						
							|  |  |  |                                           const float fno[3], | 
					
						
							|  |  |  |                                           const float *fmask, | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  |                                           const int cd_vert_mask_offset, | 
					
						
							|  |  |  |                                           const float diffuse_color[4]) | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) { | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 		VertexBufferFormat *vd = &vert_data[*v_index]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		/* Set coord, normal, and mask */ | 
					
						
							|  |  |  | 		copy_v3_v3(vd->co, v->co); | 
					
						
							|  |  |  | 		normal_float_to_short_v3(vd->no, fno ? fno : v->no); | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		gpu_color_from_mask_copy( | 
					
						
							|  |  |  | 		        fmask ? *fmask : | 
					
						
							|  |  |  | 		                BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset), | 
					
						
							|  |  |  | 		        diffuse_color, | 
					
						
							|  |  |  | 		        vd->color); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Assign index for use in the triangle index buffer */ | 
					
						
							| 
									
										
										
										
											2013-08-24 11:46:08 +00:00
										 |  |  | 		/* note: caller must set:  bm->elem_index_dirty |= BM_VERT; */ | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		BM_elem_index_set(v, (*v_index)); /* set_dirty! */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		(*v_index)++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Return the total number of vertices that don't have BM_ELEM_HIDDEN set */ | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | static int gpu_bmesh_vert_visible_count(GSet *bm_unique_verts, | 
					
						
							|  |  |  |                                         GSet *bm_other_verts) | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 	GSetIterator gs_iter; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	int totvert = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 	GSET_ITER (gs_iter, bm_unique_verts) { | 
					
						
							|  |  |  | 		BMVert *v = BLI_gsetIterator_getKey(&gs_iter); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) | 
					
						
							|  |  |  | 			totvert++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 	GSET_ITER (gs_iter, bm_other_verts) { | 
					
						
							|  |  |  | 		BMVert *v = BLI_gsetIterator_getKey(&gs_iter); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		if (!BM_elem_flag_test(v, BM_ELEM_HIDDEN)) | 
					
						
							|  |  |  | 			totvert++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return totvert; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Return the total number of visible faces */ | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | static int gpu_bmesh_face_visible_count(GSet *bm_faces) | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 	GSetIterator gh_iter; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	int totface = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 	GSET_ITER (gh_iter, bm_faces) { | 
					
						
							|  |  |  | 		BMFace *f = BLI_gsetIterator_getKey(&gh_iter); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-10 22:31:39 +03:00
										 |  |  | 		if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 			totface++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return totface; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Creates a vertex buffer (coordinate, normal, color) and, if smooth
 | 
					
						
							| 
									
										
										
										
											2013-06-06 06:02:46 +00:00
										 |  |  |  * shading, an element index buffer. */ | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers, | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  |                                    BMesh *bm, | 
					
						
							|  |  |  |                                    GSet *bm_faces, | 
					
						
							|  |  |  |                                    GSet *bm_unique_verts, | 
					
						
							|  |  |  |                                    GSet *bm_other_verts, | 
					
						
							|  |  |  |                                    bool show_diffuse_color) | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	VertexBufferFormat *vert_data; | 
					
						
							|  |  |  | 	void *tri_data; | 
					
						
							|  |  |  | 	int tottri, totvert, maxvert = 0; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 	/* TODO, make mask layer optional for bmesh buffer */ | 
					
						
							|  |  |  | 	const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 	buffers->show_diffuse_color = show_diffuse_color; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	buffers->use_matcaps = GPU_material_use_matcaps_get(); | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	/* Count visible triangles */ | 
					
						
							|  |  |  | 	tottri = gpu_bmesh_face_visible_count(bm_faces); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (buffers->smooth) { | 
					
						
							|  |  |  | 		/* Count visible vertices */ | 
					
						
							|  |  |  | 		totvert = gpu_bmesh_vert_visible_count(bm_unique_verts, bm_other_verts); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		totvert = tottri * 3; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-02 01:40:05 +03:00
										 |  |  | 	if (!tottri) { | 
					
						
							|  |  |  | 		buffers->tot_tri = 0; | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	if (buffers->use_matcaps) | 
					
						
							|  |  |  | 		diffuse_color[0] = diffuse_color[1] = diffuse_color[2] = 1.0; | 
					
						
							|  |  |  | 	else if (show_diffuse_color) { | 
					
						
							|  |  |  | 		/* due to dynamic nature of dyntopo, only get first material */ | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 		GSetIterator gs_iter; | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 		BMFace *f; | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 		BLI_gsetIterator_init(&gs_iter, bm_faces); | 
					
						
							|  |  |  | 		f = BLI_gsetIterator_getKey(&gs_iter); | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 		GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-03 04:03:46 +03:00
										 |  |  | 	copy_v4_v4(buffers->diffuse_color, diffuse_color); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	/* Initialize vertex buffer */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	if (buffers->vert_buf) | 
					
						
							|  |  |  | 		GPU_buffer_free(buffers->vert_buf); | 
					
						
							|  |  |  | 	buffers->vert_buf = GPU_buffer_alloc(sizeof(VertexBufferFormat) * totvert, false); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Fill vertex buffer */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	vert_data = GPU_buffer_lock(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	if (vert_data) { | 
					
						
							|  |  |  | 		int v_index = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (buffers->smooth) { | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 			GSetIterator gs_iter; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 			/* Vertices get an index assigned for use in the triangle
 | 
					
						
							| 
									
										
										
										
											2013-06-06 06:02:46 +00:00
										 |  |  | 			 * index buffer */ | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 			bm->elem_index_dirty |= BM_VERT; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 			GSET_ITER (gs_iter, bm_unique_verts) { | 
					
						
							|  |  |  | 				gpu_bmesh_vert_to_buffer_copy(BLI_gsetIterator_getKey(&gs_iter), | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 				                              vert_data, &v_index, NULL, NULL, | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 				                              cd_vert_mask_offset, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 			GSET_ITER (gs_iter, bm_other_verts) { | 
					
						
							|  |  |  | 				gpu_bmesh_vert_to_buffer_copy(BLI_gsetIterator_getKey(&gs_iter), | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 				                              vert_data, &v_index, NULL, NULL, | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 				                              cd_vert_mask_offset, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			maxvert = v_index; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 			GSetIterator gs_iter; | 
					
						
							| 
									
										
										
										
											2013-08-25 20:03:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 			GSET_ITER (gs_iter, bm_faces) { | 
					
						
							|  |  |  | 				BMFace *f = BLI_gsetIterator_getKey(&gs_iter); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				BLI_assert(f->len == 3); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-11 07:51:14 +10:00
										 |  |  | 				if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 					BMVert *v[3]; | 
					
						
							|  |  |  | 					float fmask = 0; | 
					
						
							|  |  |  | 					int i; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  | #if 0
 | 
					
						
							|  |  |  | 					BM_iter_as_array(bm, BM_VERTS_OF_FACE, f, (void**)v, 3); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2013-01-16 21:09:54 +00:00
										 |  |  | 					BM_face_as_array_vert_tri(f, v); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					/* Average mask value */ | 
					
						
							|  |  |  | 					for (i = 0; i < 3; i++) { | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 						fmask += BM_ELEM_CD_GET_FLOAT(v[i], cd_vert_mask_offset); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 					fmask /= 3.0f; | 
					
						
							|  |  |  | 					 | 
					
						
							|  |  |  | 					for (i = 0; i < 3; i++) { | 
					
						
							| 
									
										
										
										
											2013-05-02 06:09:05 +00:00
										 |  |  | 						gpu_bmesh_vert_to_buffer_copy(v[i], vert_data, | 
					
						
							|  |  |  | 						                              &v_index, f->no, &fmask, | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 						                              cd_vert_mask_offset, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			buffers->tot_tri = tottri; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		GPU_buffer_unlock(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
										
										
											2013-08-24 11:46:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* gpu_bmesh_vert_to_buffer_copy sets dirty index values */ | 
					
						
							|  |  |  | 		bm->elem_index_dirty |= BM_VERT; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* Memory map failed */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		GPU_buffer_free(buffers->vert_buf); | 
					
						
							|  |  |  | 		buffers->vert_buf = NULL; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (buffers->smooth) { | 
					
						
							|  |  |  | 		const int use_short = (maxvert < USHRT_MAX); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		/* Initialize triangle index buffer */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		if (buffers->index_buf) | 
					
						
							|  |  |  | 			GPU_buffer_free(buffers->index_buf); | 
					
						
							|  |  |  | 		buffers->index_buf = GPU_buffer_alloc((use_short ? | 
					
						
							|  |  |  | 		                                      sizeof(unsigned short) : | 
					
						
							|  |  |  | 		                                      sizeof(unsigned int)) * 3 * tottri, false); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		/* Fill triangle index buffer */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		tri_data = GPU_buffer_lock(buffers->index_buf, GPU_BINDING_INDEX); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		if (tri_data) { | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 			GSetIterator gs_iter; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | 			GSET_ITER (gs_iter, bm_faces) { | 
					
						
							|  |  |  | 				BMFace *f = BLI_gsetIterator_getKey(&gs_iter); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-11 07:51:14 +10:00
										 |  |  | 				if (!BM_elem_flag_test(f, BM_ELEM_HIDDEN)) { | 
					
						
							| 
									
										
										
										
											2013-01-16 21:09:54 +00:00
										 |  |  | 					BMLoop *l_iter; | 
					
						
							|  |  |  | 					BMLoop *l_first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					l_iter = l_first = BM_FACE_FIRST_LOOP(f); | 
					
						
							|  |  |  | 					do { | 
					
						
							|  |  |  | 						BMVert *v = l_iter->v; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 						if (use_short) { | 
					
						
							|  |  |  | 							unsigned short *elem = tri_data; | 
					
						
							|  |  |  | 							(*elem) = BM_elem_index_get(v); | 
					
						
							|  |  |  | 							elem++; | 
					
						
							|  |  |  | 							tri_data = elem; | 
					
						
							|  |  |  | 						} | 
					
						
							|  |  |  | 						else { | 
					
						
							|  |  |  | 							unsigned int *elem = tri_data; | 
					
						
							|  |  |  | 							(*elem) = BM_elem_index_get(v); | 
					
						
							|  |  |  | 							elem++; | 
					
						
							|  |  |  | 							tri_data = elem; | 
					
						
							|  |  |  | 						} | 
					
						
							| 
									
										
										
										
											2013-01-16 21:09:54 +00:00
										 |  |  | 					} while ((l_iter = l_iter->next) != l_first); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_unlock(buffers->index_buf, GPU_BINDING_INDEX); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			buffers->tot_tri = tottri; | 
					
						
							|  |  |  | 			buffers->index_type = (use_short ? | 
					
						
							|  |  |  | 								   GL_UNSIGNED_SHORT : | 
					
						
							|  |  |  | 								   GL_UNSIGNED_INT); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* Memory map failed */ | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->index_buf); | 
					
						
							|  |  |  | 			buffers->index_buf = NULL; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 	else if (buffers->index_buf) { | 
					
						
							|  |  |  | 		GPU_buffer_free(buffers->index_buf); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(int smooth_shading) | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | 	GPU_PBVH_Buffers *buffers; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | 	buffers = MEM_callocN(sizeof(GPU_PBVH_Buffers), "GPU_Buffers"); | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 	buffers->use_bmesh = true; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 	buffers->smooth = smooth_shading; | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 	buffers->show_diffuse_color = false; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 	buffers->use_matcaps = false; | 
					
						
							| 
									
										
										
										
											2012-12-30 18:24:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return buffers; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial, | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  |                            bool wireframe, bool fast) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 	bool do_fast = fast && buffers->index_buf_fast; | 
					
						
							| 
									
										
										
										
											2013-06-04 17:10:57 +00:00
										 |  |  | 	/* sets material from the first face, to solve properly face would need to
 | 
					
						
							|  |  |  | 	 * be sorted in buckets by materials */ | 
					
						
							| 
									
										
										
										
											2013-06-05 15:54:41 +00:00
										 |  |  | 	if (setMaterial) { | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 		if (buffers->face_indices_len) { | 
					
						
							|  |  |  | 			const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; | 
					
						
							|  |  |  | 			const MPoly *mp = &buffers->mpoly[lt->poly]; | 
					
						
							|  |  |  | 			if (!setMaterial(mp->mat_nr + 1, NULL)) | 
					
						
							| 
									
										
										
										
											2013-06-05 15:54:41 +00:00
										 |  |  | 				return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (buffers->totgrid) { | 
					
						
							|  |  |  | 			const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; | 
					
						
							|  |  |  | 			if (!setMaterial(f->mat_nr + 1, NULL)) | 
					
						
							|  |  |  | 				return; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			if (!setMaterial(1, NULL)) | 
					
						
							|  |  |  | 				return; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-06-04 17:10:57 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-03-06 02:40:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	glShadeModel((buffers->smooth || buffers->face_indices_len) ? GL_SMOOTH : GL_FLAT); | 
					
						
							| 
									
										
										
										
											2012-10-06 16:42:11 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 	if (buffers->vert_buf) { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		char *base = NULL; | 
					
						
							|  |  |  | 		char *index_base = NULL; | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:30:13 +00:00
										 |  |  | 		if (!wireframe) { | 
					
						
							|  |  |  | 			glEnableClientState(GL_NORMAL_ARRAY); | 
					
						
							|  |  |  | 			gpu_colors_enable(VBO_ENABLED); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		GPU_buffer_bind(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!buffers->vert_buf->use_vbo) | 
					
						
							|  |  |  | 			base = (char *)buffers->vert_buf->pointer; | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		if (do_fast) { | 
					
						
							|  |  |  | 			GPU_buffer_bind(buffers->index_buf_fast, GPU_BINDING_INDEX); | 
					
						
							|  |  |  | 			if (!buffers->index_buf_fast->use_vbo) | 
					
						
							|  |  |  | 				index_base = buffers->index_buf_fast->pointer; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else if (buffers->index_buf) { | 
					
						
							|  |  |  | 			GPU_buffer_bind(buffers->index_buf, GPU_BINDING_INDEX); | 
					
						
							|  |  |  | 			if (!buffers->index_buf->use_vbo) | 
					
						
							|  |  |  | 				index_base = buffers->index_buf->pointer; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:30:13 +00:00
										 |  |  | 		if (wireframe) | 
					
						
							|  |  |  | 			glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (buffers->tot_quad) { | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			const char *offset = base; | 
					
						
							| 
									
										
										
										
											2012-03-14 06:32:25 +00:00
										 |  |  | 			int i, last = buffers->has_hidden ? 1 : buffers->totgrid; | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			for (i = 0; i < last; i++) { | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				                offset + offsetof(VertexBufferFormat, co)); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2012-05-11 08:05:47 +00:00
										 |  |  | 				                offset + offsetof(VertexBufferFormat, no)); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 				glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | 
					
						
							|  |  |  | 				               offset + offsetof(VertexBufferFormat, color)); | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 				 | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 				if (do_fast) | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 					glDrawElements(GL_TRIANGLES, buffers->totgrid * 6, buffers->index_type, index_base); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 				else | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 					glDrawElements(GL_TRIANGLES, buffers->tot_quad * 6, buffers->index_type, index_base); | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 				offset += buffers->gridkey.grid_area * sizeof(VertexBufferFormat); | 
					
						
							| 
									
										
										
										
											2012-03-09 09:30:03 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-04-11 03:16:16 +03:00
										 |  |  | 		else if (buffers->tot_tri) { | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 			int totelem = buffers->tot_tri * 3; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 			glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			                (void *)(base + offsetof(VertexBufferFormat, co))); | 
					
						
							| 
									
										
										
										
											2012-05-10 20:36:24 +00:00
										 |  |  | 			glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			                (void *)(base + offsetof(VertexBufferFormat, no))); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 			glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			               (void *)(base + offsetof(VertexBufferFormat, color))); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 			if (buffers->index_buf) | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 				glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, index_base); | 
					
						
							| 
									
										
										
										
											2012-10-06 16:52:52 +00:00
										 |  |  | 			else | 
					
						
							|  |  |  | 				glDrawArrays(GL_TRIANGLES, 0, totelem); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-12-30 18:30:13 +00:00
										 |  |  | 		if (wireframe) | 
					
						
							|  |  |  | 			glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-20 12:12:28 +02:00
										 |  |  | 		GPU_buffer_unbind(buffers->vert_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 		if (buffers->index_buf || do_fast) | 
					
						
							| 
									
										
										
										
											2015-07-20 12:12:28 +02:00
										 |  |  | 			GPU_buffer_unbind(do_fast ? buffers->index_buf_fast : buffers->index_buf, GPU_BINDING_ARRAY); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		glDisableClientState(GL_VERTEX_ARRAY); | 
					
						
							| 
									
										
										
										
											2012-12-30 18:30:13 +00:00
										 |  |  | 		if (!wireframe) { | 
					
						
							|  |  |  | 			glDisableClientState(GL_NORMAL_ARRAY); | 
					
						
							|  |  |  | 			gpu_colors_disable(VBO_ENABLED); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-08 14:45:48 +10:00
										 |  |  | bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, GSet *bm_faces, bool show_diffuse_color) | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	float diffuse_color[4]; | 
					
						
							| 
									
										
										
										
											2014-04-15 20:12:35 +03:00
										 |  |  | 	bool use_matcaps = GPU_material_use_matcaps_get(); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (buffers->show_diffuse_color != show_diffuse_color) | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-15 20:12:35 +03:00
										 |  |  | 	if (buffers->use_matcaps != use_matcaps) | 
					
						
							| 
									
										
										
										
											2014-04-02 17:33:47 +03:00
										 |  |  | 		return true; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-15 20:12:35 +03:00
										 |  |  | 	if ((buffers->show_diffuse_color == false) || use_matcaps) | 
					
						
							| 
									
										
										
										
											2014-04-01 11:34:00 +11:00
										 |  |  | 		return false; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 	if (buffers->looptri) { | 
					
						
							|  |  |  | 		const MLoopTri *lt = &buffers->looptri[buffers->face_indices[0]]; | 
					
						
							|  |  |  | 		const MPoly *mp = &buffers->mpoly[lt->poly]; | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-17 03:36:03 +10:00
										 |  |  | 		GPU_material_diffuse_get(mp->mat_nr + 1, diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 	else if (buffers->use_bmesh) { | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  | 		/* due to dynamic nature of dyntopo, only get first material */ | 
					
						
							| 
									
										
										
										
											2014-08-07 14:57:59 +02:00
										 |  |  | 		if (BLI_gset_size(bm_faces) > 0) { | 
					
						
							|  |  |  | 			GSetIterator gs_iter; | 
					
						
							|  |  |  | 			BMFace *f; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			BLI_gsetIterator_init(&gs_iter, bm_faces); | 
					
						
							|  |  |  | 			f = BLI_gsetIterator_getKey(&gs_iter); | 
					
						
							|  |  |  | 			GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-08-13 10:38:08 +10:00
										 |  |  | 		else { | 
					
						
							|  |  |  | 			return false; | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2014-04-02 18:56:19 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | 	else { | 
					
						
							|  |  |  | 		const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-13 10:38:08 +10:00
										 |  |  | 	return !equals_v3v3(diffuse_color, buffers->diffuse_color); | 
					
						
							| 
									
										
										
										
											2012-10-22 17:33:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-01-02 22:22:36 +02:00
										 |  |  | void GPU_free_pbvh_buffers(GPU_PBVH_Buffers *buffers) | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (buffers) { | 
					
						
							|  |  |  | 		if (buffers->vert_buf) | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->vert_buf); | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (buffers->index_buf && (buffers->tot_tri || buffers->has_hidden)) | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->index_buf); | 
					
						
							| 
									
										
										
										
											2015-07-14 16:48:23 +02:00
										 |  |  | 		if (buffers->index_buf_fast) | 
					
						
							| 
									
										
										
										
											2015-07-16 16:22:28 +02:00
										 |  |  | 			GPU_buffer_free(buffers->index_buf_fast); | 
					
						
							| 
									
										
											  
											
												== GPU Buffers ==
This patch attempts to clean up and document the GPU buffers
code. There are a few bug fixes as well.
Patch reviewed here: http://codereview.appspot.com/4631052/
Summary:
* Bugfix: make GPU_buffer_copy_normal convert from shorts to floats
  correctly, also fixed the use of cached face normal CustomData.
* Bugfix: changed the `mat_nr' field of GPUBufferMaterial from char to
  short.
* Changed color buffer setup to not alloc a temporary copy of color
  data, just passes the MCol data in directly.
* Changed the GPU buffer pool code to make clearer what operates
  specifically on the global pool.
* Lots of refactoring for GPU_drawobject_new; should operate mostly
  the same (except got rid of one unecessary allocation), just split
  into more functions and without macros now.
* Converted some #defines into enumerations.
* Made some stuff private, pulled out of header file.
* Deleted unused function GPU_buffer_pool_free_unused().
* Removed GPU_interleaved_setup and related #defines. (I think this
  was used for editmode VBOs, but those were disabled.)
* Added lots of comments.
* Added a few comments in the code signed `--nicholas' to note places
  where I am unsure about design or usage, would be good to address
  these better.
* Code formatting changed to be more consistent with the rest of
  Blender.
* Renamed some fields and variables to be more consistent with
  Blender's naming conventions.
* Renamed some fields and variables to use more descriptive names,
  e.g. renamed `redir' to `mat_orig_to_new'.
* Removed print outs with DEBUG_VBO -- don't feel too strongly about
  this one, just not used elsewhere in Blender, could be easily added
  back if others disagree though.
* Moved the PBVH drawing code down to the bottom of the file, before
  was sitting in the middle of the other VBO code
											
										 
											2011-07-08 19:58:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		MEM_freeN(buffers); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-04-30 23:42:58 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* debug function, draws the pbvh BB */ | 
					
						
							|  |  |  | void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2014-11-29 17:49:38 +01:00
										 |  |  | 	const float quads[4][4][3] = { | 
					
						
							| 
									
										
										
										
											2015-03-23 15:29:42 -04:00
										 |  |  | 		{ | 
					
						
							|  |  |  | 			{min[0], min[1], min[2]}, | 
					
						
							|  |  |  | 			{max[0], min[1], min[2]}, | 
					
						
							|  |  |  | 			{max[0], min[1], max[2]}, | 
					
						
							|  |  |  | 			{min[0], min[1], max[2]} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			{min[0], min[1], min[2]}, | 
					
						
							|  |  |  | 			{min[0], max[1], min[2]}, | 
					
						
							|  |  |  | 			{min[0], max[1], max[2]}, | 
					
						
							|  |  |  | 			{min[0], min[1], max[2]} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			{max[0], max[1], min[2]}, | 
					
						
							|  |  |  | 			{max[0], min[1], min[2]}, | 
					
						
							|  |  |  | 			{max[0], min[1], max[2]}, | 
					
						
							|  |  |  | 			{max[0], max[1], max[2]} | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		{ | 
					
						
							|  |  |  | 			{max[0], max[1], min[2]}, | 
					
						
							|  |  |  | 			{min[0], max[1], min[2]}, | 
					
						
							|  |  |  | 			{min[0], max[1], max[2]}, | 
					
						
							|  |  |  | 			{max[0], max[1], max[2]} | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2014-04-30 23:42:58 +03:00
										 |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (leaf) | 
					
						
							|  |  |  | 		glColor4f(0.0, 1.0, 0.0, 0.5); | 
					
						
							|  |  |  | 	else | 
					
						
							|  |  |  | 		glColor4f(1.0, 0.0, 0.0, 0.5); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	glVertexPointer(3, GL_FLOAT, 0, &quads[0][0][0]); | 
					
						
							|  |  |  | 	glDrawArrays(GL_QUADS, 0, 16); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GPU_init_draw_pbvh_BB(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glPushAttrib(GL_ENABLE_BIT); | 
					
						
							|  |  |  | 	glDisable(GL_CULL_FACE); | 
					
						
							|  |  |  | 	glEnableClientState(GL_VERTEX_ARRAY); | 
					
						
							|  |  |  | 	glDisableClientState(GL_COLOR_ARRAY); | 
					
						
							|  |  |  | 	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | 
					
						
							|  |  |  | 	glDisable(GL_LIGHTING); | 
					
						
							|  |  |  | 	glDisable(GL_COLOR_MATERIAL); | 
					
						
							|  |  |  | 	glEnable(GL_BLEND); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void GPU_end_draw_pbvh_BB(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | 
					
						
							|  |  |  | 	glPopAttrib(); | 
					
						
							|  |  |  | } |