[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21319] branches/soc-2009-imbusy/source/ blender: should be a lot more stable when running out of memory, but there is still a bug, debugger doesn' t give any hints and when stepping through code, does not appear
Lukas Steiblys
imbusy at imbusy.org
Thu Jul 2 17:05:46 CEST 2009
Revision: 21319
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21319
Author: imbusy
Date: 2009-07-02 17:05:46 +0200 (Thu, 02 Jul 2009)
Log Message:
-----------
should be a lot more stable when running out of memory, but there is still a bug, debugger doesn't give any hints and when stepping through code, does not appear
Modified Paths:
--------------
branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c
branches/soc-2009-imbusy/source/blender/gpu/SConscript
branches/soc-2009-imbusy/source/blender/gpu/gpu_buffers.h
branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c
Modified: branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c 2009-07-02 12:41:03 UTC (rev 21318)
+++ branches/soc-2009-imbusy/source/blender/blenkernel/intern/cdderivedmesh.c 2009-07-02 15:05:46 UTC (rev 21319)
@@ -268,7 +268,7 @@
}
if( GPU_buffer_legacy(dm) ) {
- DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid" );
+ DEBUG_VBO( "Using legacy code. cdDM_drawFacesSolid\n" );
glBegin(glmode = GL_QUADS);
for(a = 0; a < dm->numFaceData; a++, mface++) {
int new_glmode, new_matnr, new_shademodel;
@@ -357,7 +357,7 @@
glEnable(GL_CULL_FACE);
if( GPU_buffer_legacy(dm) ) {
- DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored" );
+ DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored\n" );
glShadeModel(GL_SMOOTH);
glBegin(glmode = GL_QUADS);
for(a = 0; a < dm->numFaceData; a++, mface++, cp1 += 16) {
@@ -431,7 +431,7 @@
int startFace = 0, lastFlag = 0xdeadbeef;
if( GPU_buffer_legacy(dm) ) {
- DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common" );
+ DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
for(i = 0; i < dm->numFaceData; i++, mf++) {
MVert *mvert;
int flag;
@@ -590,7 +590,7 @@
mc = DM_get_face_data_layer(dm, CD_MCOL);
if( GPU_buffer_legacy(dm) ) {
- DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common" );
+ DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" );
for(i = 0; i < dm->numFaceData; i++, mf++) {
int drawSmooth = (mf->flag & ME_SMOOTH);
Modified: branches/soc-2009-imbusy/source/blender/gpu/SConscript
===================================================================
--- branches/soc-2009-imbusy/source/blender/gpu/SConscript 2009-07-02 12:41:03 UTC (rev 21318)
+++ branches/soc-2009-imbusy/source/blender/gpu/SConscript 2009-07-02 15:05:46 UTC (rev 21319)
@@ -1,11 +1,11 @@
-#!/usr/bin/python
-Import ('env')
-
-sources = env.Glob('intern/*.c')
-
-incs = '../blenlib ../blenkernel ../makesdna ../include'
-incs += ' #/extern/glew/include #intern/guardedalloc ../imbuf .'
-
-incs += ' ' + env['BF_OPENGL_INC']
-
-env.BlenderLib ( 'bf_gpu', sources, Split(incs), [], libtype=['core', 'player'], priority=[160, 20] )
+#!/usr/bin/python
+Import ('env')
+
+sources = env.Glob('intern/*.c')
+
+incs = '../blenlib ../blenkernel ../makesdna ../include'
+incs += ' #/extern/glew/include #intern/guardedalloc ../imbuf .'
+
+incs += ' ' + env['BF_OPENGL_INC']
+
+env.BlenderLib ( 'bf_gpu', sources, Split(incs), [], libtype=['core', 'player'], priority=[166, 20] )
Modified: branches/soc-2009-imbusy/source/blender/gpu/gpu_buffers.h
===================================================================
--- branches/soc-2009-imbusy/source/blender/gpu/gpu_buffers.h 2009-07-02 12:41:03 UTC (rev 21318)
+++ branches/soc-2009-imbusy/source/blender/gpu/gpu_buffers.h 2009-07-02 15:05:46 UTC (rev 21319)
@@ -34,7 +34,12 @@
#define __GPU_BUFFERS_H__
#define MAX_FREE_GPU_BUFFERS 8
+
+#ifdef _DEBUG
#define DEBUG_VBO(X) printf(X)
+#else
+#define DEBUG_VBO(X)
+#endif
struct DerivedMesh;
@@ -79,7 +84,7 @@
} GPUDrawObject;
GPUBufferPool *GPU_buffer_pool_new();
-void GPU_buffer_pool_free( GPUBufferPool *pool );
+void GPU_buffer_pool_free( GPUBufferPool *pool ); /* TODO: Find a place where to call this function on exit */
GPUBuffer *GPU_buffer_alloc( int size, GPUBufferPool *pool );
void GPU_buffer_free( GPUBuffer *buffer, GPUBufferPool *pool );
Modified: branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c
===================================================================
--- branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c 2009-07-02 12:41:03 UTC (rev 21318)
+++ branches/soc-2009-imbusy/source/blender/gpu/intern/gpu_buffers.c 2009-07-02 15:05:46 UTC (rev 21319)
@@ -311,19 +311,22 @@
DEBUG_VBO("GPU_buffer_setup\n");
- index = MEM_mallocN(sizeof(int)*object->nmaterials,"GPU_buffer_setup");
- for( i = 0; i < object->nmaterials; i++ ) {
- index[i] = object->materials[i].start;
- redir[object->materials[i].mat_nr+127] = i;
- }
-
if( globalPool == 0 )
globalPool = GPU_buffer_pool_new();
buffer = GPU_buffer_alloc(size,globalPool);
if( buffer == 0 ) {
dm->drawObject->legacy = 1;
}
+ if( dm->drawObject->legacy ) {
+ return 0;
+ }
+ index = MEM_mallocN(sizeof(int)*object->nmaterials,"GPU_buffer_setup");
+ for( i = 0; i < object->nmaterials; i++ ) {
+ index[i] = object->materials[i].start;
+ redir[object->materials[i].mat_nr+127] = i;
+ }
+
if( useVBOs ) {
success = 0;
while( success == 0 ) {
@@ -331,7 +334,7 @@
glBufferDataARB( GL_ARRAY_BUFFER_ARB, buffer->size, 0, GL_STATIC_DRAW_ARB ); /* discard previous data, avoid stalling gpu */
varray = glMapBufferARB( GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB );
if( varray == 0 ) {
- DEBUG_VBO( "Failed to map buffer to client address space" );
+ DEBUG_VBO( "Failed to map buffer to client address space\n" );
GPU_buffer_free( buffer, globalPool );
GPU_buffer_pool_delete_last( globalPool );
if( globalPool->size > 0 ) {
@@ -352,10 +355,12 @@
}
}
- uploaded = GL_FALSE;
- while( !uploaded ) {
- (*copy_f)( dm, varray, index, redir, user );
- uploaded = glUnmapBufferARB( GL_ARRAY_BUFFER_ARB ); /* returns false if data got corruped during transfer */
+ if( dm->drawObject->legacy == 0 ) {
+ uploaded = GL_FALSE;
+ while( !uploaded ) {
+ (*copy_f)( dm, varray, index, redir, user );
+ uploaded = glUnmapBufferARB( GL_ARRAY_BUFFER_ARB ); /* returns false if data got corruped during transfer */
+ }
}
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
}
@@ -630,6 +635,10 @@
dm->drawObject = GPU_drawobject_new( dm );
if( dm->drawObject->vertices == 0 )
dm->drawObject->vertices = GPU_buffer_vertex( dm );
+ if( dm->drawObject->vertices == 0 ) {
+ DEBUG_VBO( "Failed to setup vertices\n" );
+ return;
+ }
glEnableClientState( GL_VERTEX_ARRAY );
if( useVBOs ) {
@@ -650,7 +659,10 @@
dm->drawObject = GPU_drawobject_new( dm );
if( dm->drawObject->normals == 0 )
dm->drawObject->normals = GPU_buffer_normal( dm );
-
+ if( dm->drawObject->normals == 0 ) {
+ DEBUG_VBO( "Failed to setup normals\n" );
+ return;
+ }
glEnableClientState( GL_NORMAL_ARRAY );
if( useVBOs ) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, dm->drawObject->normals->id );
@@ -670,7 +682,7 @@
dm->drawObject = GPU_drawobject_new( dm );
if( dm->drawObject->uv == 0 )
dm->drawObject->uv = GPU_buffer_uv( dm );
-
+
if( dm->drawObject->uv != 0 ) {
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
if( useVBOs ) {
@@ -692,6 +704,10 @@
dm->drawObject = GPU_drawobject_new( dm );
if( dm->drawObject->colors == 0 )
dm->drawObject->colors = GPU_buffer_color( dm );
+ if( dm->drawObject->colors == 0 ) {
+ DEBUG_VBO( "Failed to setup colors\n" );
+ return;
+ }
glEnableClientState( GL_COLOR_ARRAY );
if( useVBOs ) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, dm->drawObject->colors->id );
More information about the Bf-blender-cvs
mailing list