Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-07-17 13:25:05 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-07-17 13:25:44 +0300
commit1b8e0d03d413a54ceb7d6397c696b59bb7c6f91b (patch)
tree1c6701e983f95b7236a85c300871d21c9f4fad47 /source/blender
parent0b121d6a5ddb0605011cf89782d46df656f0deeb (diff)
Fix no longer being possible to display a suzanne with 8 levels of
subdivision. Classic integet overflow/size_t substitution case. Machines are getting powerful enough to easily expose these kinds of error now.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/cdderivedmesh.c2
-rw-r--r--source/blender/gpu/GPU_buffers.h33
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c8
3 files changed, 22 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c
index 5f53fa6dca1..69e69bf1b92 100644
--- a/source/blender/blenkernel/intern/cdderivedmesh.c
+++ b/source/blender/blenkernel/intern/cdderivedmesh.c
@@ -945,7 +945,7 @@ static void cdDM_drawMappedFacesGLSL(
int tot_active_mat;
GPUBuffer *buffer = NULL;
char *varray;
- int max_element_size = 0;
+ size_t max_element_size = 0;
int tot_loops = 0;
GPU_vertex_setup(dm);
diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h
index 12e66264661..779521aa00c 100644
--- a/source/blender/gpu/GPU_buffers.h
+++ b/source/blender/gpu/GPU_buffers.h
@@ -39,6 +39,8 @@
# define DEBUG_VBO(X)
#endif
+#include <stddef.h>
+
struct BMesh;
struct CCGElem;
struct CCGKey;
@@ -50,7 +52,7 @@ struct PBVH;
struct MVert;
typedef struct GPUBuffer {
- int size; /* in bytes */
+ size_t size; /* in bytes */
void *pointer; /* used with vertex arrays */
unsigned int id; /* used with vertex buffer objects */
bool use_vbo; /* true for VBOs, false for vertex arrays */
@@ -58,12 +60,12 @@ typedef struct GPUBuffer {
typedef struct GPUBufferMaterial {
/* range of points used for this material */
- int start;
- int totelements;
- int totloops;
- int *polys; /* array of polygons for this material */
- int totpolys; /* total polygons in polys */
- int counter; /* general purpose counter, initialize first! */
+ 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! */
/* original material index */
short mat_nr;
@@ -106,23 +108,22 @@ typedef struct GPUDrawObject {
#endif
int colType;
- int index_setup; /* how indices are setup, starting from start of buffer or start of material */
GPUBufferMaterial *materials;
int totmaterial;
- int tot_triangle_point;
- int tot_loose_point;
+ unsigned int tot_triangle_point;
+ unsigned int tot_loose_point;
/* different than total loops since ngons get tesselated still */
- int tot_loop_verts;
+ unsigned int tot_loop_verts;
/* caches of the original DerivedMesh values */
- int totvert;
- int totedge;
+ unsigned int totvert;
+ unsigned int totedge;
- int loose_edge_offset;
- int tot_loose_edge_drawn;
- int tot_edge_drawn;
+ unsigned int loose_edge_offset;
+ unsigned int tot_loose_edge_drawn;
+ unsigned int tot_edge_drawn;
} GPUDrawObject;
/* currently unused */
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index cd3a5d6d725..e86ca0fba94 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -75,7 +75,7 @@ typedef struct {
} GPUBufferTypeSettings;
-static int gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type);
+static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type);
const GPUBufferTypeSettings gpu_buffer_type_settings[] = {
/* vertex */
@@ -471,7 +471,7 @@ void GPU_drawobject_free(DerivedMesh *dm)
dm->drawObject = NULL;
}
-static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, int size, bool use_VBOs)
+static GPUBuffer *gpu_try_realloc(GPUBufferPool *pool, GPUBuffer *buffer, size_t size, bool use_VBOs)
{
gpu_buffer_free_intern(buffer);
gpu_buffer_pool_delete_last(pool);
@@ -498,7 +498,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object,
const GPUBufferTypeSettings *ts = &gpu_buffer_type_settings[type];
GLenum target = ts->gl_buffer_type;
int num_components = ts->num_components;
- int size = gpu_buffer_size_from_type(dm, type);
+ size_t size = gpu_buffer_size_from_type(dm, type);
bool use_VBOs = (GLEW_ARB_vertex_buffer_object) && !(U.gameflags & USER_DISABLE_VBO);
GLboolean uploaded;
@@ -607,7 +607,7 @@ static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBuffer
}
/* get the amount of space to allocate for a buffer of a particular type */
-static int gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type)
+static size_t gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type)
{
switch (type) {
case GPU_BUFFER_VERTEX: