2011-02-21 06:58:46 +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-21 06:58:46 +00:00
|
|
|
/** \file GPU_buffers.h
|
|
|
|
* \ingroup gpu
|
|
|
|
*/
|
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
#ifndef __GPU_BUFFERS_H__
|
|
|
|
#define __GPU_BUFFERS_H__
|
|
|
|
|
2014-08-27 18:57:53 +10:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* #define DEBUG_VBO(X) printf(X)*/
|
|
|
|
# define DEBUG_VBO(X)
|
2009-10-03 15:35:01 +00:00
|
|
|
#else
|
2014-08-27 18:57:53 +10:00
|
|
|
# define DEBUG_VBO(X)
|
2009-10-03 15:35:01 +00:00
|
|
|
#endif
|
|
|
|
|
2015-07-17 12:25:05 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2012-12-30 18:24:54 +00:00
|
|
|
struct BMesh;
|
2012-05-10 20:33:09 +00:00
|
|
|
struct CCGElem;
|
|
|
|
struct CCGKey;
|
|
|
|
struct DMFlagMat;
|
|
|
|
struct DerivedMesh;
|
2013-08-25 20:03:45 +00:00
|
|
|
struct GSet;
|
== 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
|
|
|
struct GPUVertPointLink;
|
2015-07-25 13:17:37 +02:00
|
|
|
struct GPUDrawObject;
|
2012-12-30 18:24:54 +00:00
|
|
|
struct PBVH;
|
2015-07-16 16:22:28 +02:00
|
|
|
struct MVert;
|
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
|
|
|
typedef struct GPUBuffer {
|
2015-07-17 12:25:05 +02:00
|
|
|
size_t size; /* in bytes */
|
2015-03-23 15:29:42 -04:00
|
|
|
void *pointer; /* used with vertex arrays */
|
|
|
|
unsigned int id; /* used with vertex buffer objects */
|
|
|
|
bool use_vbo; /* true for VBOs, false for vertex arrays */
|
2009-10-03 15:35:01 +00:00
|
|
|
} GPUBuffer;
|
|
|
|
|
== 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 GPUBufferMaterial {
|
|
|
|
/* range of points used for this material */
|
2015-07-17 12:25:05 +02:00
|
|
|
unsigned int start;
|
|
|
|
unsigned int totelements;
|
|
|
|
unsigned int totloops;
|
|
|
|
unsigned int *polys; /* array of polygons for this material */
|
|
|
|
unsigned int totpolys; /* total polygons in polys */
|
|
|
|
unsigned int counter; /* general purpose counter, initialize first! */
|
2015-07-25 20:00:49 +02:00
|
|
|
unsigned int totvisiblepolys; /* total visible polygons */
|
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
|
|
|
/* original material index */
|
|
|
|
short mat_nr;
|
|
|
|
} GPUBufferMaterial;
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2015-07-25 13:17:37 +02:00
|
|
|
void GPU_buffer_material_finalize(struct GPUDrawObject *gdo, GPUBufferMaterial *matinfo, int totmat);
|
|
|
|
|
== 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
|
|
|
/* meshes are split up by material since changing materials requires
|
2012-03-09 18:28:30 +00:00
|
|
|
* GL state changes that can't occur in the middle of drawing an
|
|
|
|
* array.
|
|
|
|
*
|
|
|
|
* some simplifying assumptions are made:
|
|
|
|
* - all quads are treated as two triangles.
|
|
|
|
* - no vertex sharing is used; each triangle gets its own copy of the
|
|
|
|
* vertices it uses (this makes it easy to deal with a vertex used
|
|
|
|
* by faces with different properties, such as smooth/solid shading,
|
|
|
|
* different MCols, etc.)
|
|
|
|
*
|
|
|
|
* to avoid confusion between the original MVert vertices and the
|
|
|
|
* arrays of OpenGL vertices, the latter are referred to here and in
|
|
|
|
* the source as `points'. similarly, the OpenGL triangles generated
|
|
|
|
* for MFaces are referred to as triangles rather than faces.
|
== 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 GPUDrawObject {
|
|
|
|
GPUBuffer *points;
|
2009-10-03 15:35:01 +00:00
|
|
|
GPUBuffer *normals;
|
|
|
|
GPUBuffer *uv;
|
2014-11-28 14:38:18 +01:00
|
|
|
GPUBuffer *uv_tex;
|
2009-10-03 15:35:01 +00:00
|
|
|
GPUBuffer *colors;
|
|
|
|
GPUBuffer *edges;
|
|
|
|
GPUBuffer *uvedges;
|
2015-07-14 16:48:23 +02:00
|
|
|
GPUBuffer *triangles; /* triangle index 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
|
|
|
|
|
|
|
/* for each original vertex, the list of related points */
|
|
|
|
struct GPUVertPointLink *vert_points;
|
2014-04-09 15:38:37 +10:00
|
|
|
|
|
|
|
/* see: USE_GPU_POINT_LINK define */
|
|
|
|
#if 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
|
|
|
/* storage for the vert_points lists */
|
|
|
|
struct GPUVertPointLink *vert_points_mem;
|
|
|
|
int vert_points_usage;
|
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
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
int colType;
|
|
|
|
|
|
|
|
GPUBufferMaterial *materials;
|
== 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 totmaterial;
|
|
|
|
|
2015-07-17 12:25:05 +02:00
|
|
|
unsigned int tot_triangle_point;
|
|
|
|
unsigned int tot_loose_point;
|
2015-07-14 16:48:23 +02:00
|
|
|
/* different than total loops since ngons get tesselated still */
|
2015-07-17 12:25:05 +02:00
|
|
|
unsigned int tot_loop_verts;
|
== 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
|
|
|
|
|
|
|
/* caches of the original DerivedMesh values */
|
2015-07-17 12:25:05 +02:00
|
|
|
unsigned int totvert;
|
|
|
|
unsigned int totedge;
|
2015-06-16 20:55:37 +02:00
|
|
|
|
2015-07-17 12:25:05 +02:00
|
|
|
unsigned int loose_edge_offset;
|
|
|
|
unsigned int tot_loose_edge_drawn;
|
|
|
|
unsigned int tot_edge_drawn;
|
2015-07-23 16:05:00 +02:00
|
|
|
|
|
|
|
/* for subsurf, offset where drawing of interior edges starts */
|
|
|
|
unsigned int interior_offset;
|
|
|
|
unsigned int totinterior;
|
2009-10-03 15:35:01 +00:00
|
|
|
} GPUDrawObject;
|
|
|
|
|
2015-07-14 16:48:23 +02:00
|
|
|
/* currently unused */
|
|
|
|
// #define USE_GPU_POINT_LINK
|
|
|
|
|
|
|
|
typedef struct GPUVertPointLink {
|
|
|
|
#ifdef USE_GPU_POINT_LINK
|
|
|
|
struct GPUVertPointLink *next;
|
|
|
|
#endif
|
|
|
|
/* -1 means uninitialized */
|
|
|
|
int point_index;
|
|
|
|
} GPUVertPointLink;
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-02-15 19:04:00 +00:00
|
|
|
/* used for GLSL materials */
|
== 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 GPUAttrib {
|
2009-10-03 15:35:01 +00:00
|
|
|
int index;
|
|
|
|
int size;
|
|
|
|
int type;
|
|
|
|
} GPUAttrib;
|
|
|
|
|
== 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);
|
2013-08-09 19:55:43 +00:00
|
|
|
void GPU_global_buffer_pool_free_unused(void);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2015-07-14 16:48:23 +02:00
|
|
|
GPUBuffer *GPU_buffer_alloc(size_t size, bool force_vertex_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
|
|
|
void GPU_buffer_free(GPUBuffer *buffer);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2012-10-30 11:00:06 +00:00
|
|
|
void GPU_drawobject_free(struct DerivedMesh *dm);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2015-07-16 16:22:28 +02:00
|
|
|
/* free special global multires grid buffer */
|
|
|
|
void GPU_buffer_multires_free(bool force);
|
|
|
|
|
2015-07-14 16:48:23 +02:00
|
|
|
/* flag that controls data type to fill buffer with, a modifier will prepare. */
|
|
|
|
typedef enum {
|
|
|
|
GPU_BUFFER_VERTEX = 0,
|
|
|
|
GPU_BUFFER_NORMAL,
|
|
|
|
GPU_BUFFER_COLOR,
|
|
|
|
GPU_BUFFER_UV,
|
|
|
|
GPU_BUFFER_UV_TEXPAINT,
|
|
|
|
GPU_BUFFER_EDGE,
|
|
|
|
GPU_BUFFER_UVEDGE,
|
|
|
|
GPU_BUFFER_TRIANGLES
|
|
|
|
} GPUBufferType;
|
|
|
|
|
2015-07-16 16:22:28 +02:00
|
|
|
typedef enum {
|
|
|
|
GPU_BINDING_ARRAY = 0,
|
|
|
|
GPU_BINDING_INDEX = 1,
|
|
|
|
} GPUBindingType;
|
2015-07-14 16:48:23 +02:00
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
/* called before drawing */
|
2012-10-30 11:00:06 +00:00
|
|
|
void GPU_vertex_setup(struct DerivedMesh *dm);
|
|
|
|
void GPU_normal_setup(struct DerivedMesh *dm);
|
|
|
|
void GPU_uv_setup(struct DerivedMesh *dm);
|
2014-07-21 12:02:05 +02:00
|
|
|
void GPU_texpaint_uv_setup(struct DerivedMesh *dm);
|
2012-10-30 11:00:06 +00:00
|
|
|
/* colType is the cddata MCol type to use! */
|
|
|
|
void GPU_color_setup(struct DerivedMesh *dm, int colType);
|
2015-07-15 18:50:02 +02:00
|
|
|
void GPU_buffer_bind_as_color(GPUBuffer *buffer);
|
2012-10-30 11:00:06 +00:00
|
|
|
void GPU_edge_setup(struct DerivedMesh *dm); /* does not mix with other data */
|
|
|
|
void GPU_uvedge_setup(struct DerivedMesh *dm);
|
2015-07-14 16:48:23 +02:00
|
|
|
|
|
|
|
void GPU_triangle_setup(struct DerivedMesh *dm);
|
|
|
|
|
2012-10-30 11:00:06 +00:00
|
|
|
int GPU_attrib_element_size(GPUAttrib data[], int numdata);
|
2015-07-14 16:48:23 +02:00
|
|
|
void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numdata, int element_size);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2015-07-16 16:22:28 +02:00
|
|
|
void GPU_buffer_bind(GPUBuffer *buffer, GPUBindingType binding);
|
2015-07-20 12:12:28 +02:00
|
|
|
void GPU_buffer_unbind(GPUBuffer *buffer, GPUBindingType binding);
|
2015-07-16 16:22:28 +02:00
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
/* can't lock more than one buffer at once */
|
2015-07-16 16:22:28 +02:00
|
|
|
void *GPU_buffer_lock(GPUBuffer *buffer, GPUBindingType binding);
|
|
|
|
void *GPU_buffer_lock_stream(GPUBuffer *buffer, GPUBindingType binding);
|
|
|
|
void GPU_buffer_unlock(GPUBuffer *buffer, GPUBindingType binding);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
|
|
|
/* switch color rendering on=1/off=0 */
|
2012-10-30 11:00:06 +00:00
|
|
|
void GPU_color_switch(int mode);
|
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
|
|
|
/* used for drawing edges */
|
2012-10-30 11:00:06 +00:00
|
|
|
void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
|
|
|
/* called after drawing */
|
2015-07-20 12:12:28 +02:00
|
|
|
void GPU_buffers_unbind(void);
|
2009-10-03 15:35:01 +00:00
|
|
|
|
2015-07-14 16:48:23 +02:00
|
|
|
/* only unbind interleaved data */
|
|
|
|
void GPU_interleaved_attrib_unbind(void);
|
|
|
|
|
== 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 for non-DerivedMesh drawing */
|
2014-01-02 22:22:36 +02:00
|
|
|
typedef struct GPU_PBVH_Buffers GPU_PBVH_Buffers;
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2014-05-05 21:13:27 +03:00
|
|
|
/* build */
|
2015-07-17 03:36:03 +10:00
|
|
|
GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers(
|
|
|
|
const int (*face_vert_indices)[4],
|
|
|
|
const struct MPoly *mpoly, const struct MLoop *mloop, const struct MLoopTri *looptri,
|
|
|
|
const struct MVert *verts,
|
|
|
|
const int *face_indices,
|
|
|
|
const int face_indices_len);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
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
|
|
|
unsigned int **grid_hidden, int gridsize, const struct CCGKey *key);
|
2012-02-22 22:48:34 +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-05-05 21:13:27 +03:00
|
|
|
/* update */
|
|
|
|
|
2015-07-11 03:25:28 +10:00
|
|
|
void GPU_update_mesh_pbvh_buffers(
|
2015-07-16 16:22:28 +02:00
|
|
|
GPU_PBVH_Buffers *buffers, const struct MVert *mvert,
|
2015-07-11 03:25:28 +10:00
|
|
|
const int *vert_indices, int totvert, const float *vmask,
|
|
|
|
const int (*face_vert_indices)[4], bool show_diffuse_color);
|
2014-05-05 21:13:27 +03:00
|
|
|
|
2014-01-02 22:22:36 +02:00
|
|
|
void GPU_update_bmesh_pbvh_buffers(GPU_PBVH_Buffers *buffers,
|
2013-08-25 20:03:45 +00:00
|
|
|
struct BMesh *bm,
|
2014-04-08 14:45:48 +10:00
|
|
|
struct GSet *bm_faces,
|
2013-08-25 20:03:45 +00:00
|
|
|
struct GSet *bm_unique_verts,
|
2014-04-02 18:56:19 +03:00
|
|
|
struct GSet *bm_other_verts,
|
2014-04-02 17:33:47 +03:00
|
|
|
bool show_diffuse_color);
|
2012-12-30 18:24:54 +00:00
|
|
|
|
2014-01-02 22:22:36 +02:00
|
|
|
void GPU_update_grid_pbvh_buffers(GPU_PBVH_Buffers *buffers, struct CCGElem **grids,
|
2012-09-04 01:23:50 +00:00
|
|
|
const struct DMFlagMat *grid_flag_mats,
|
2012-10-22 17:33:53 +00:00
|
|
|
int *grid_indices, int totgrid, const struct CCGKey *key,
|
2014-04-01 11:34:00 +11:00
|
|
|
bool show_diffuse_color);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2014-05-05 21:13:27 +03:00
|
|
|
/* draw */
|
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);
|
2012-02-22 22:48:34 +00:00
|
|
|
|
2014-05-05 21:13:27 +03:00
|
|
|
/* debug PBVH draw*/
|
2014-04-30 23:42:58 +03:00
|
|
|
void GPU_draw_pbvh_BB(float min[3], float max[3], bool leaf);
|
|
|
|
void GPU_end_draw_pbvh_BB(void);
|
|
|
|
void GPU_init_draw_pbvh_BB(void);
|
|
|
|
|
2014-04-08 14:45:48 +10:00
|
|
|
bool GPU_pbvh_buffers_diffuse_changed(GPU_PBVH_Buffers *buffers, struct GSet *bm_faces, bool show_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
|
|
|
|
2009-10-03 15:35:01 +00:00
|
|
|
#endif
|