[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36617] branches/particles-2010/source/ blender: Fix for GLSL material nodes: GPU socket stack types were initialized from the source socket type instead of the target socket type .
Lukas Toenne
lukas.toenne at googlemail.com
Wed May 11 19:28:03 CEST 2011
Revision: 36617
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36617
Author: lukastoenne
Date: 2011-05-11 17:28:02 +0000 (Wed, 11 May 2011)
Log Message:
-----------
Fix for GLSL material nodes: GPU socket stack types were initialized from the source socket type instead of the target socket type.
Modified Paths:
--------------
branches/particles-2010/source/blender/gpu/intern/gpu_codegen.c
branches/particles-2010/source/blender/nodes/intern/node_exec.c
branches/particles-2010/source/blender/nodes/shader/node_shader_util.c
branches/particles-2010/source/blender/nodes/shader/node_shader_util.h
branches/particles-2010/source/blender/nodes/shader/nodes/node_shader_common.c
Modified: branches/particles-2010/source/blender/gpu/intern/gpu_codegen.c
===================================================================
--- branches/particles-2010/source/blender/gpu/intern/gpu_codegen.c 2011-05-11 14:28:56 UTC (rev 36616)
+++ branches/particles-2010/source/blender/gpu/intern/gpu_codegen.c 2011-05-11 17:28:02 UTC (rev 36617)
@@ -390,6 +390,8 @@
{
char name[1024];
+ printf("CONVERT: from=%d, to=%d\n", from, to);
+
snprintf(name, sizeof(name), "%s%d", tmp, id);
if (from == to) {
Modified: branches/particles-2010/source/blender/nodes/intern/node_exec.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/node_exec.c 2011-05-11 14:28:56 UTC (rev 36616)
+++ branches/particles-2010/source/blender/nodes/intern/node_exec.c 2011-05-11 17:28:02 UTC (rev 36617)
@@ -78,11 +78,16 @@
sock->stack_index = (*index)++;
}
-static void prepare_input_stack(bNodeStack *stack, bNodeSocket *sock)
+/* basic preparation of socket stacks */
+static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeSocket *sock)
{
bNodeStack *ns = node_get_socket_stack(stack, sock);
float null_value[4]= {0.0f, 0.0f, 0.0f, 0.0f};
+ /* don't mess with remote socket stacks, these are initialized by other nodes! */
+ if (sock->link)
+ return ns;
+
ns->sockettype = sock->type;
if (sock->default_value) {
@@ -111,6 +116,8 @@
break;
}
}
+
+ return ns;
}
bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree)
@@ -124,8 +131,6 @@
bNode **nodelist;
int totnodes, n;
- /* XXX should do an update for adapting socket types here */
-
if((ntree->init & NTREE_TYPE_INIT)==0)
ntreeInitTypes(ntree);
@@ -163,39 +168,30 @@
exec->stacksize = index;
exec->stack = MEM_callocN(exec->stacksize * sizeof(bNodeStack), "bNodeStack");
- /* XXX the input/output tagging could be more precise, but that's also part of the compo redesign */
-
+ /* prepare group tree inputs */
+ for (sock=ntree->inputs.first; sock; sock=sock->next) {
+ ns = setup_stack(exec->stack, sock);
+ if (ns->hasoutput)
+ ns->hasinput = 1;
+ }
/* prepare all internal nodes for execution */
for(n=0, nodeexec= exec->nodeexec; n < totnodes; ++n, ++nodeexec) {
node = nodeexec->node = nodelist[n];
/* tag inputs */
for (sock=node->inputs.first; sock; sock=sock->next) {
- /* this is the test for a cyclic case */
- if(sock->link) {
- bNodeLink *link= sock->link;
- if(link->fromnode && link->tonode) {
- if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF);
- else {
- node->need_exec= 0;
- }
- }
- }
- else
- prepare_input_stack(exec->stack, sock);
+ /* disable the node if an input link is invalid */
+ if(sock->link && !(sock->link->flag & NODE_LINK_VALID))
+ node->need_exec= 0;
- ns = node_get_socket_stack(exec->stack, sock);
- ns->sockettype = sock->type;
- if (ns->hasoutput) {
+ ns = setup_stack(exec->stack, sock);
+ if (ns->hasoutput)
ns->hasinput = 1;
- }
}
- /* XXX could restrict this for some node types */
/* tag all outputs */
for (sock=node->outputs.first; sock; sock=sock->next) {
- ns = node_get_socket_stack(exec->stack, sock);
- ns->sockettype = sock->type;
+ ns = setup_stack(exec->stack, sock);
ns->hasoutput = 1;
}
@@ -204,8 +200,8 @@
}
/* prepare group tree outputs */
for (sock=ntree->outputs.first; sock; sock=sock->next) {
- if (sock->link==NULL)
- prepare_input_stack(exec->stack, sock);
+ ns = setup_stack(exec->stack, sock);
+ ns->hasoutput = 1;
}
if (nodelist)
Modified: branches/particles-2010/source/blender/nodes/shader/node_shader_util.c
===================================================================
--- branches/particles-2010/source/blender/nodes/shader/node_shader_util.c 2011-05-11 14:28:56 UTC (rev 36616)
+++ branches/particles-2010/source/blender/nodes/shader/node_shader_util.c 2011-05-11 17:28:02 UTC (rev 36617)
@@ -194,18 +194,18 @@
}
-void node_gpu_stack_from_data(struct GPUNodeStack *gs, bNodeStack *ns)
+void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
{
memset(gs, 0, sizeof(*gs));
QUATCOPY(gs->vec, ns->vec);
gs->link= ns->data;
- if (ns->sockettype == SOCK_FLOAT)
+ if (type == SOCK_FLOAT)
gs->type= GPU_FLOAT;
- else if (ns->sockettype == SOCK_VECTOR)
+ else if (type == SOCK_VECTOR)
gs->type= GPU_VEC3;
- else if (ns->sockettype == SOCK_RGBA)
+ else if (type == SOCK_RGBA)
gs->type= GPU_VEC4;
else
gs->type= GPU_NONE;
@@ -228,7 +228,7 @@
int i;
for (sock=sockets->first, i=0; sock; sock=sock->next, i++)
- node_gpu_stack_from_data(&gs[i], ns[i]);
+ node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
gs[i].type= GPU_NONE;
}
Modified: branches/particles-2010/source/blender/nodes/shader/node_shader_util.h
===================================================================
--- branches/particles-2010/source/blender/nodes/shader/node_shader_util.h 2011-05-11 14:28:56 UTC (rev 36616)
+++ branches/particles-2010/source/blender/nodes/shader/node_shader_util.h 2011-05-11 17:28:02 UTC (rev 36617)
@@ -121,7 +121,7 @@
extern void node_ID_title_cb(void *node_v, void *unused_v);
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns);
-void node_gpu_stack_from_data(struct GPUNodeStack *gs, struct bNodeStack *ns);
+void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeStack *ns);
void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
Modified: branches/particles-2010/source/blender/nodes/shader/nodes/node_shader_common.c
===================================================================
--- branches/particles-2010/source/blender/nodes/shader/nodes/node_shader_common.c 2011-05-11 14:28:56 UTC (rev 36616)
+++ branches/particles-2010/source/blender/nodes/shader/nodes/node_shader_common.c 2011-05-11 17:28:02 UTC (rev 36617)
@@ -166,7 +166,7 @@
if (sock->groupsock) {
ns = node_get_socket_stack(gstack, sock->groupsock);
/* convert the node stack data result back to gpu stack */
- node_gpu_stack_from_data(&out[a], ns);
+ node_gpu_stack_from_data(&out[a], sock->type, ns);
}
}
}
More information about the Bf-blender-cvs
mailing list