[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16925] trunk/blender/source/blender/gpu/ intern/gpu_codegen.c: Fix for bug #17684: GLSL bug with shadows and material nodes,

Brecht Van Lommel brecht at blender.org
Sun Oct 5 00:21:46 CEST 2008


Revision: 16925
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16925
Author:   blendix
Date:     2008-10-05 00:21:46 +0200 (Sun, 05 Oct 2008)

Log Message:
-----------
Fix for bug #17684: GLSL bug with shadows and material nodes,
missed unbinding a texture giving extremely slow frontbuffer
drawing.

Modified Paths:
--------------
    trunk/blender/source/blender/gpu/intern/gpu_codegen.c

Modified: trunk/blender/source/blender/gpu/intern/gpu_codegen.c
===================================================================
--- trunk/blender/source/blender/gpu/intern/gpu_codegen.c	2008-10-04 21:26:48 UTC (rev 16924)
+++ trunk/blender/source/blender/gpu/intern/gpu_codegen.c	2008-10-04 22:21:46 UTC (rev 16925)
@@ -516,10 +516,14 @@
 						input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->ima));
 				}
 				else {
-					/* input is user created texture, we know there there is
-					   only one, so assign new texid */
-					input->bindtex = 1;
-					input->texid = texid++;
+					if (!BLI_ghash_haskey(bindhash, input->tex)) {
+						/* input is user created texture, check tex pointer */
+						input->texid = texid++;
+						input->bindtex = 1;
+						BLI_ghash_insert(bindhash, input->tex, SET_INT_IN_POINTER(input->texid));
+					}
+					else
+						input->texid = GET_INT_FROM_POINTER(BLI_ghash_lookup(bindhash, input->tex));
 				}
 
 				/* make sure this pixel is defined exactly once */
@@ -836,11 +840,9 @@
 		if (input->ima)
 			input->tex = GPU_texture_from_blender(input->ima, input->iuser, time);
 
-		if(input->ima || input->tex) {
-			if(input->tex) {
-				GPU_texture_bind(input->tex, input->texid);
-				GPU_shader_uniform_texture(shader, input->shaderloc, input->tex);
-			}
+		if(input->tex && input->bindtex) {
+			GPU_texture_bind(input->tex, input->texid);
+			GPU_shader_uniform_texture(shader, input->shaderloc, input->tex);
 		}
 	}
 }
@@ -871,9 +873,9 @@
 		return;
 
 	for (input=inputs->first; input; input=input->next) {
-		if (input->tex)
-			if(input->bindtex)
-				GPU_texture_unbind(input->tex);
+		if(input->tex && input->bindtex)
+			GPU_texture_unbind(input->tex);
+
 		if (input->ima)
 			input->tex = 0;
 	}





More information about the Bf-blender-cvs mailing list