[Bf-blender-cvs] [57609993d05] blender2.8: GPU: fixes for string socket types in shader nodes.

Brecht Van Lommel noreply at git.blender.org
Fri Feb 23 19:12:18 CET 2018


Commit: 57609993d051dacc35794682ed6c24d6552e65a6
Author: Brecht Van Lommel
Date:   Thu Feb 22 20:52:08 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB57609993d051dacc35794682ed6c24d6552e65a6

GPU: fixes for string socket types in shader nodes.

These are not passed to GLSL functions, but should be used to load e.g.
a texture or attribute.

===================================================================

M	source/blender/gpu/GPU_material.h
M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/makesrna/intern/rna_nodetree.c
M	source/blender/nodes/shader/node_shader_util.c

===================================================================

diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 8f1ee7ccc59..b486ff14dd1 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -136,12 +136,12 @@ typedef enum GPUBlendMode {
 
 typedef struct GPUNodeStack {
 	GPUType type;
-	const char *name;
 	float vec[4];
 	struct GPUNodeLink *link;
 	bool hasinput;
 	bool hasoutput;
 	short sockettype;
+	bool end;
 } GPUNodeStack;
 
 
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index ce75d944747..ece78d4a5cf 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1960,16 +1960,20 @@ bool GPU_stack_link(GPUMaterial *material, bNode *bnode, const char *name, GPUNo
 	totout = 0;
 
 	if (in) {
-		for (i = 0; in[i].type != GPU_NONE; i++) {
-			gpu_node_input_socket(material, bnode, node, &in[i], i);
-			totin++;
+		for (i = 0; !in[i].end; i++) {
+			if (in[i].type != GPU_NONE) {
+				gpu_node_input_socket(material, bnode, node, &in[i], i);
+				totin++;
+			}
 		}
 	}
 
 	if (out) {
-		for (i = 0; out[i].type != GPU_NONE; i++) {
-			gpu_node_output(node, out[i].type, &out[i].link);
-			totout++;
+		for (i = 0; !out[i].end; i++) {
+			if (out[i].type != GPU_NONE) {
+				gpu_node_output(node, out[i].type, &out[i].link);
+				totout++;
+			}
 		}
 	}
 
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index a148efb859d..2a9e94964e4 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -2306,9 +2306,15 @@ static void rna_NodeSocketStandard_vector_range(PointerRNA *ptr, float *min, flo
 static void rna_NodeSocket_value_update(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
 	bNodeTree *ntree = (bNodeTree *)ptr->id.data;
+	bNodeSocket *sock = ptr->data;
+
 	if (ntree->type == NTREE_SHADER) {
-		DEG_id_tag_update_ex(bmain, ptr->id.data, DEG_TAG_SHADING_UPDATE);
+		DEG_id_tag_update_ex(bmain, &ntree->id, DEG_TAG_SHADING_UPDATE);
 		WM_main_add_notifier(NC_MATERIAL | ND_SHADING, NULL);
+
+		if (sock->type == SOCK_STRING) {
+			rna_NodeSocket_update(bmain, scene, ptr);
+		}
 	}
 	else {
 		rna_NodeSocket_update(bmain, scene, ptr);
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index 8559765e315..22171f28790 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -147,7 +147,6 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
 		zero_v4(gs->vec);
 		gs->link = NULL;
 		gs->type = GPU_NONE;
-		gs->name = "";
 		gs->hasinput = false;
 		gs->hasoutput = false;
 		gs->sockettype = type;
@@ -167,7 +166,6 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
 		else
 			gs->type = GPU_NONE;
 
-		gs->name = "";
 		gs->hasinput = ns->hasinput && ns->data;
 		/* XXX Commented out the ns->data check here, as it seems it's not always set,
 		 *     even though there *is* a valid connection/output... But that might need
@@ -193,7 +191,7 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
 	for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
 		node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
 	
-	gs[i].type = GPU_NONE;
+	gs[i].end = true;
 }
 
 static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNodeStack *gs)



More information about the Bf-blender-cvs mailing list