[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29399] branches/soc-2010-moguri/source/ blender: Adding support for int uniforms and completely removing uint and bool support .

Mitchell Stokes mogurijin at gmail.com
Fri Jun 11 05:08:29 CEST 2010


Revision: 29399
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29399
Author:   moguri
Date:     2010-06-11 05:08:27 +0200 (Fri, 11 Jun 2010)

Log Message:
-----------
Adding support for int uniforms and completely removing uint and bool support. Both have been buggy. When I get further along, I can look into adding these types back in if there is enough interest in having them (both can be represented with ints).

Modified Paths:
--------------
    branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h
    branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c
    branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c
    branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
    branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c

Modified: branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h	2010-06-11 01:34:13 UTC (rev 29398)
+++ branches/soc-2010-moguri/source/blender/gpu/GPU_extensions.h	2010-06-11 03:08:27 UTC (rev 29399)
@@ -161,6 +161,8 @@
 int GPU_shader_get_uniform(GPUShader *shader, char *name);
 void GPU_shader_uniform_vector(GPUShader *shader, int location, int length,
 	int arraysize, float *value);
+void GPU_shader_uniform_ivector(GPUShader *shader, int location, int length,
+	int arraysize, int *value);
 void GPU_shader_uniform_texture(GPUShader *shader, int location, GPUTexture *tex);
 
 int GPU_shader_get_attribute(GPUShader *shader, char *name);

Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c	2010-06-11 01:34:13 UTC (rev 29398)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_extensions.c	2010-06-11 03:08:27 UTC (rev 29399)
@@ -1149,6 +1149,21 @@
 	GPU_print_error("Post Uniform Vector");
 }
 
+void GPU_shader_uniform_ivector(GPUShader *shader, int location, int length, int arraysize, int *value)
+{
+	if(location == -1)
+		return;
+
+	GPU_print_error("Pre Uniform Int Vector");
+
+	if (length == 1) glUniform1ivARB(location, arraysize, value);
+	else if (length == 2) glUniform2ivARB(location, arraysize, value);
+	else if (length == 3) glUniform3ivARB(location, arraysize, value);
+	else if (length == 4) glUniform4ivARB(location, arraysize, value);
+
+	GPU_print_error("Post Uniform Int Vector");
+}
+
 void GPU_shader_uniform_texture(GPUShader *shader, int location, GPUTexture *tex)
 {
 	GLenum arbnumber;

Modified: branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c	2010-06-11 01:34:13 UTC (rev 29398)
+++ branches/soc-2010-moguri/source/blender/gpu/intern/gpu_material.c	2010-06-11 03:08:27 UTC (rev 29399)
@@ -390,8 +390,10 @@
 		/* handle custom uniforms */
 		for(cu=material->ma->csi.uniforms.first; cu; cu=cu->next) {
 			loc = GPU_shader_get_uniform(shader, cu->name);
-			if(cu->type = MA_UNF_FLOAT)
+			if(cu->type == MA_UNF_FLOAT)
 				GPU_shader_uniform_vector(shader, loc, 1, 1, (float*)(&cu->data));
+			else if(cu->type == MA_UNF_INT)
+				GPU_shader_uniform_ivector(shader, loc, 1, 1, (int*)(&cu->data));
 		}
 
 		/* update lamps */

Modified: branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h	2010-06-11 01:34:13 UTC (rev 29398)
+++ branches/soc-2010-moguri/source/blender/makesdna/DNA_material_types.h	2010-06-11 03:08:27 UTC (rev 29399)
@@ -233,12 +233,8 @@
 #define MA_UNF_VEC		2
 #define MA_UNF_INT		3
 #define MA_UNF_IVEC		4
-#define MA_UNF_UINT		5
-#define MA_UNF_UVEC		6
-#define MA_UNF_BOOL		7
-#define MA_UNF_BVEC		8
-#define MA_UNF_MAT		9
-#define MA_UNF_SAMPLER2D 10
+#define MA_UNF_MAT		5
+#define MA_UNF_SAMPLER2D 6
 
 /* mode (is int) */
 #define MA_TRACEBLE		1

Modified: branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c	2010-06-11 01:34:13 UTC (rev 29398)
+++ branches/soc-2010-moguri/source/blender/makesrna/intern/rna_material.c	2010-06-11 03:08:27 UTC (rev 29399)
@@ -219,12 +219,8 @@
 		return &RNA_FloatUniform;
 	case MA_UNF_INT:
 		return &RNA_IntUniform;
-	case MA_UNF_UINT:
-		return &RNA_UIntUniform;
-	//case MA_UNF_BOOL:
-		//return &RNA_BoolUniform;
-	case MA_UNF_SAMPLER2D:
-		return &RNA_Sampler2DUniform;
+	//case MA_UNF_SAMPLER2D:
+	//	return &RNA_Sampler2DUniform;
 	default:
 		return &RNA_CustomUniform;
 	}
@@ -971,7 +967,7 @@
 }
 
 /* Helper function for defining the different uniform data types */
-static void rna_def_uniformtype(BlenderRNA *brna, const char *name, const char *doc, int type, int subtype, int min, int max)
+static void rna_def_uniformtype(BlenderRNA *brna, const char *name, const char *doc, int type, int min, int max)
 {
 	PropertyRNA *prop;
 	StructRNA *srna;
@@ -980,11 +976,9 @@
 	RNA_def_struct_ui_text(srna, name, doc);
 	RNA_def_struct_sdna(srna, "CustomUniform");
 
-	prop= RNA_def_property(srna, "value", type, subtype);
+	prop= RNA_def_property(srna, "value", type, PROP_NONE);
 	if (type == PROP_INT)
 		RNA_def_property_int_sdna(prop, NULL, "data");
-	else if (type == PROP_BOOLEAN)
-		RNA_def_property_boolean_sdna(prop, NULL, "data", 1);
 	else if (type == PROP_FLOAT)
 	{
 		RNA_def_property_float_sdna(prop, NULL, "data");
@@ -1017,11 +1011,7 @@
 		//{MA_UNF_VEC, "VEC", 0, "vec", "vec"},
 		{MA_UNF_INT, "INT", 0, "int", "int"},
 		//{MA_UNF_IVEC2, "IVEC", 0, "ivec", "ivec"},
-		{MA_UNF_UINT, "UINT", 0, "uint", "uint"},
-		//{MA_UNF_UVEC, "UVEC", 0, "uvec", "uvec"},
-	//	{MA_UNF_BOOL, "BOOL", 0, "bool", "bool"},
-		//{MA_UNF_BVEC, "BVEC", 0, "bvec", "bvec"},
-		{MA_UNF_SAMPLER2D, "SAMPLER2D", 0, "sampler2D", "sampler2D"},
+		//{MA_UNF_SAMPLER2D, "SAMPLER2D", 0, "sampler2D", "sampler2D"},
 		{0, NULL, 0, NULL, NULL}};
 
 	srna= RNA_def_struct(brna, "CustomUniform", NULL);
@@ -1043,11 +1033,9 @@
 	RNA_def_property_ui_text(prop, "Uniform type", "The data type of the uniform");
 	RNA_def_property_update(prop, 0, "rna_Material_update");
 
-	rna_def_uniformtype(brna, "FloatUniform", "Custom float uniform", PROP_FLOAT, PROP_NONE, 1, 1);
-	rna_def_uniformtype(brna, "IntUniform", "Custom integer uniform", PROP_INT, PROP_NONE, 1, 1);
-	rna_def_uniformtype(brna, "UIntUniform", "Custom unsigned integer uniform", PROP_INT, PROP_UNSIGNED, 1, 1);
-	rna_def_uniformtype(brna, "Sampler2DUniform", "Custom sampler2D uniform", PROP_POINTER, PROP_NONE, 1, 1);
-	//rna_def_uniformtype(brna, "BoolUniform", "Custom boolean uniform", PROP_BOOLEAN, PROP_NONE, 1, 1);
+	rna_def_uniformtype(brna, "FloatUniform", "Custom float uniform", PROP_FLOAT, 1, 1);
+	rna_def_uniformtype(brna, "IntUniform", "Custom integer uniform", PROP_INT, 1, 1);
+	//rna_def_uniformtype(brna, "Sampler2DUniform", "Custom sampler2D uniform", PROP_POINTER, 1, 1);
 
 }
 static void rna_def_material_raymirror(BlenderRNA *brna)





More information about the Bf-blender-cvs mailing list