[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33759] branches/soc-2010-moguri-2/source/ blender: Fix for freeing of Text Datablock (leading to TotBlock error, crashes, ...)

Dalai Felinto dfelinto at gmail.com
Fri Dec 17 23:25:47 CET 2010


Revision: 33759
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33759
Author:   dfelinto
Date:     2010-12-17 23:25:47 +0100 (Fri, 17 Dec 2010)

Log Message:
-----------
Fix for freeing of Text Datablock (leading to TotBlock error, crashes, ...)
+ warning cleaning.
For some reason the material is calling the "free" routine quite often. Maybe something to investigate in trunk. Either way, we should not free the texts (they are merely a pointer, if anything we could decrease the TextDatablock idcounter, but I think this is automagicly handled by the RNA). Instead we should free custom uniforms (the vector ones). Those are the one we used mem*loc functions. Mitchell can you double-check this?

#airport waiting connexion+wifi FTW

Modified Paths:
--------------
    branches/soc-2010-moguri-2/source/blender/blenkernel/BKE_material.h
    branches/soc-2010-moguri-2/source/blender/blenkernel/intern/material.c
    branches/soc-2010-moguri-2/source/blender/editors/render/render_shading.c
    branches/soc-2010-moguri-2/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2010-moguri-2/source/blender/makesrna/intern/rna_material.c

Modified: branches/soc-2010-moguri-2/source/blender/blenkernel/BKE_material.h
===================================================================
--- branches/soc-2010-moguri-2/source/blender/blenkernel/BKE_material.h	2010-12-17 20:54:21 UTC (rev 33758)
+++ branches/soc-2010-moguri-2/source/blender/blenkernel/BKE_material.h	2010-12-17 22:25:47 UTC (rev 33759)
@@ -39,6 +39,7 @@
 struct Material;
 struct ID;
 struct Object;
+struct CustomUniform;
 
 /* materials */
 

Modified: branches/soc-2010-moguri-2/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/soc-2010-moguri-2/source/blender/blenkernel/intern/material.c	2010-12-17 20:54:21 UTC (rev 33758)
+++ branches/soc-2010-moguri-2/source/blender/blenkernel/intern/material.c	2010-12-17 22:25:47 UTC (rev 33759)
@@ -82,9 +82,7 @@
 	if(ma->ramp_col) MEM_freeN(ma->ramp_col);
 	if(ma->ramp_spec) MEM_freeN(ma->ramp_spec);
 
-	if(ma->csi.vert_text) MEM_freeN(ma->csi.vert_text);
-	if(ma->csi.frag_text) MEM_freeN(ma->csi.frag_text);
-	if(ma->csi.geom_text) MEM_freeN(ma->csi.geom_text);
+	/* XXX - To Do - if custom uniforms we need to clear the vector ones */
 	
 	BKE_free_animdata((ID *)ma);
 	

Modified: branches/soc-2010-moguri-2/source/blender/editors/render/render_shading.c
===================================================================
--- branches/soc-2010-moguri-2/source/blender/editors/render/render_shading.c	2010-12-17 20:54:21 UTC (rev 33758)
+++ branches/soc-2010-moguri-2/source/blender/editors/render/render_shading.c	2010-12-17 22:25:47 UTC (rev 33759)
@@ -1078,7 +1078,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-static int uniform_add_exec(bContext *C, wmOperator *op)
+static int uniform_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
 	CustomUniform *cu= MEM_callocN(sizeof(CustomUniform), "New Uniform");
@@ -1138,7 +1138,7 @@
 	RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "Uniform index to remove ", 0, INT_MAX);
 }
 
-static int force_update_exec(bContext *C, wmOperator *op)
+static int force_update_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Material *ma= CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
 	Scene *scene= CTX_data_pointer_get_type(C, "scene", &RNA_Scene).data;

Modified: branches/soc-2010-moguri-2/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/soc-2010-moguri-2/source/blender/gpu/intern/gpu_extensions.c	2010-12-17 20:54:21 UTC (rev 33758)
+++ branches/soc-2010-moguri-2/source/blender/gpu/intern/gpu_extensions.c	2010-12-17 22:25:47 UTC (rev 33759)
@@ -963,7 +963,7 @@
 		shader->vertex = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
 	if(fragcode)
 		shader->fragment = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
-	if(geomcode)
+	if(geomcode) {
 		if(!GL_EXT_geometry_shader4)
 		{
 			shader->geometry = 0;
@@ -971,6 +971,7 @@
 		}
 		else
 			shader->geometry = glCreateShaderObjectARB(GL_GEOMETRY_SHADER_EXT);
+	}
 	shader->object = glCreateProgramObjectARB();
 
 	if (!shader->object ||
@@ -1178,7 +1179,7 @@
 	GPU_print_error("Post Uniform Vector");
 }
 
-void GPU_shader_uniform_ivector(GPUShader *shader, int location, int length, int arraysize, int *value)
+void GPU_shader_uniform_ivector(GPUShader *UNUSED(shader), int location, int length, int arraysize, int *value)
 {
 	if(location == -1)
 		return;

Modified: branches/soc-2010-moguri-2/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/soc-2010-moguri-2/source/blender/makesrna/intern/rna_material.c	2010-12-17 20:54:21 UTC (rev 33758)
+++ branches/soc-2010-moguri-2/source/blender/makesrna/intern/rna_material.c	2010-12-17 22:25:47 UTC (rev 33759)
@@ -226,6 +226,18 @@
 	}
 }
 
+static int rna_IntUniform_value_get(struct PointerRNA *ptr)
+{
+	CustomUniform *cu= (CustomUniform*)ptr->data;
+	return *(int *)(&cu->data);
+}
+
+static void rna_IntUniform_value_set(struct PointerRNA *ptr, int value)
+{
+	CustomUniform *cu= (CustomUniform*)ptr->data;
+	*(int*)(&cu->data)= value;
+}
+
 static float rna_FloatUniform_value_get(struct PointerRNA *ptr)
 {
 	CustomUniform *cu= (CustomUniform*)ptr->data;
@@ -1112,7 +1124,10 @@
 		if (size > 1)
 			RNA_def_property_int_funcs(prop, "rna_IVecUniform_value_get", "rna_IVecUniform_value_set", NULL);
 		else
+		{
 			RNA_def_property_int_sdna(prop, NULL, "data");
+			RNA_def_property_int_funcs(prop, "rna_IntUniform_value_get", "rna_IntUniform_value_set", NULL);
+		}
 	}
 
 	else if (type == PROP_FLOAT)





More information about the Bf-blender-cvs mailing list