[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32396] branches/particles-2010/source/ blender: Moved context setup and buffer allocation out of the individual enqueuing functions .
Lukas Toenne
lukas.toenne at googlemail.com
Sun Oct 10 18:41:21 CEST 2010
Revision: 32396
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32396
Author: lukastoenne
Date: 2010-10-10 18:41:21 +0200 (Sun, 10 Oct 2010)
Log Message:
-----------
Moved context setup and buffer allocation out of the individual enqueuing functions. Nodes can define custom context setup functions if necessary (currently for Get/SetData), otherwise the maximum context is selected from all adaptable input sockets and set for all adaptable outputs. This further simplifies enqueue functions.
Several math nodes updated.
Modified Paths:
--------------
branches/particles-2010/source/blender/blenkernel/BKE_node.h
branches/particles-2010/source/blender/blenkernel/intern/node.c
branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
branches/particles-2010/source/blender/nodes/SIM_node.h
branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.c
branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.h
branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.h
branches/particles-2010/source/blender/nodes/intern/simulation/node_tree_simulation.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_for.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_if.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_math.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_pass.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_program.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_subprogram.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_vectormath.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_while.c
Removed Paths:
-------------
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_vector_compose.c
branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_vector_decompose.c
Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h 2010-10-10 16:41:21 UTC (rev 32396)
@@ -123,6 +123,8 @@
void (*freesocketstoragefunc)(struct bNodeSocket *sock);
/* simulation nodes */
+ void (*prepare_outputs)(struct SimExecData *execdata, struct SimNodeStack *node, struct SimDataContext *self);
+
char *(*generate_source)(struct SimNodeStack *node);
void (*enqueue)(struct SimExecData *execdata, struct SimNodeStack *node, struct SimDataContext *self);
void (*enqueue_op)(struct SimExecData *execdata, struct SimNodeStack *node, struct SimDataContext *self, int execlevel, int *pushop);
@@ -542,10 +544,10 @@
#define SIM_NODE_FILTER 607
/* scalar math */
-#define SIM_NODE_SCALAR_ADD 650
-#define SIM_NODE_SCALAR_SUBTRACT 651
-#define SIM_NODE_SCALAR_MULTIPLY 652
-#define SIM_NODE_SCALAR_DIVIDE 653
+#define SIM_NODE_ADD 650
+#define SIM_NODE_SUBTRACT 651
+#define SIM_NODE_MULTIPLY 652
+#define SIM_NODE_DIVIDE 653
#define SIM_NODE_SINE 654
#define SIM_NODE_COSINE 655
#define SIM_NODE_TANGENT 656
Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c 2010-10-10 16:41:21 UTC (rev 32396)
@@ -2326,10 +2326,10 @@
nodeRegisterType(ntypelist, &sim_node_while);
nodeRegisterType(ntypelist, &sim_node_filter);
- nodeRegisterType(ntypelist, &sim_node_scalar_add);
- nodeRegisterType(ntypelist, &sim_node_scalar_subtract);
- nodeRegisterType(ntypelist, &sim_node_scalar_multiply);
- nodeRegisterType(ntypelist, &sim_node_scalar_divide);
+ nodeRegisterType(ntypelist, &sim_node_add);
+ nodeRegisterType(ntypelist, &sim_node_subtract);
+ nodeRegisterType(ntypelist, &sim_node_multiply);
+ nodeRegisterType(ntypelist, &sim_node_divide);
nodeRegisterType(ntypelist, &sim_node_sine);
nodeRegisterType(ntypelist, &sim_node_cosine);
nodeRegisterType(ntypelist, &sim_node_tangent);
Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h 2010-10-10 16:41:21 UTC (rev 32396)
@@ -140,10 +140,10 @@
DefNode( SimulationNode, SIM_NODE_FOR, 0, "FOR", For, "For", "" )
DefNode( SimulationNode, SIM_NODE_WHILE, def_sim_while, "WHILE", While, "While", "" )
DefNode( SimulationNode, SIM_NODE_FILTER, 0, "FILTER", Filter, "Filter", "" )
-DefNode( SimulationNode, SIM_NODE_SCALAR_ADD, 0, "SCALAR_ADD", ScalarAdd, "Add", "" )
-DefNode( SimulationNode, SIM_NODE_SCALAR_SUBTRACT, 0, "SCALAR_SUBTRACT", ScalarSubtract, "Subtract", "" )
-DefNode( SimulationNode, SIM_NODE_SCALAR_MULTIPLY, 0, "SCALAR_MULTIPLY", ScalarMultiply, "Multiply", "" )
-DefNode( SimulationNode, SIM_NODE_SCALAR_DIVIDE, 0, "SCALAR_DIVIDE", ScalarDivide, "Divide", "" )
+DefNode( SimulationNode, SIM_NODE_ADD, 0, "ADD", Add, "Add", "" )
+DefNode( SimulationNode, SIM_NODE_SUBTRACT, 0, "SUBTRACT", Subtract, "Subtract", "" )
+DefNode( SimulationNode, SIM_NODE_MULTIPLY, 0, "MULTIPLY", Multiply, "Multiply", "" )
+DefNode( SimulationNode, SIM_NODE_DIVIDE, 0, "DIVIDE", Divide, "Divide", "" )
DefNode( SimulationNode, SIM_NODE_SINE, 0, "SINE", Sine, "Sine", "" )
DefNode( SimulationNode, SIM_NODE_COSINE, 0, "COSINE", Cosine, "Cosine", "" )
DefNode( SimulationNode, SIM_NODE_TANGENT, 0, "TANGENT", Tangent, "Tangent", "" )
Modified: branches/particles-2010/source/blender/nodes/SIM_node.h
===================================================================
--- branches/particles-2010/source/blender/nodes/SIM_node.h 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/nodes/SIM_node.h 2010-10-10 16:41:21 UTC (rev 32396)
@@ -47,10 +47,10 @@
extern bNodeType sim_node_while;
extern bNodeType sim_node_filter;
-extern bNodeType sim_node_scalar_add;
-extern bNodeType sim_node_scalar_subtract;
-extern bNodeType sim_node_scalar_multiply;
-extern bNodeType sim_node_scalar_divide;
+extern bNodeType sim_node_add;
+extern bNodeType sim_node_subtract;
+extern bNodeType sim_node_multiply;
+extern bNodeType sim_node_divide;
extern bNodeType sim_node_sine;
extern bNodeType sim_node_cosine;
extern bNodeType sim_node_tangent;
Modified: branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.c 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.c 2010-10-10 16:41:21 UTC (rev 32396)
@@ -45,6 +45,60 @@
#include "RNA_access.h"
+void sim_init_socket_buffer(SimExecData *execdata, SimSocketStack *sock)
+{
+#ifdef WITH_OPENCL
+ if (BKE_opencl_is_active()) {
+ cl_int res;
+ size_t datasize = sim_get_data_size(sock->type);
+ if (datasize > 0 && sock->context.size > 0) {
+ sock->data_cl = clCreateBuffer(execdata->opencl_context, CL_MEM_READ_WRITE, sock->context.size * datasize, NULL, &res);
+ if (res != CL_SUCCESS) {
+ execdata->error = 1;
+ sprintf(execdata->error_string, "Error creating OpenCL buffer: %s", BKE_opencl_message(res));
+ }
+ }
+ }
+ else
+#endif
+ {
+ size_t datasize = sim_get_data_size(sock->type);
+ if (datasize > 0 && sock->context.size > 0) {
+ sock->data = MEM_callocN(datasize * sock->context.size, "socket data");
+ }
+ else {
+ sock->data = NULL;
+ }
+ }
+}
+
+void sim_free_socket_buffer(SimExecData *execdata, SimSocketStack *sock)
+{
+ if (execdata->error)
+ return;
+
+#ifdef WITH_OPENCL
+ if (BKE_opencl_is_active()) {
+ cl_int res;
+ cl_uint refcount;
+ res = clGetMemObjectInfo(sock->data_cl, CL_MEM_REFERENCE_COUNT, sizeof(cl_uint), &refcount, NULL);
+ if (res == CL_SUCCESS && refcount > 0) {
+ clReleaseMemObject(sock->data_cl);
+ if (res != CL_SUCCESS) {
+ execdata->error = 1;
+ sprintf(execdata->error_string, "Error releasing OpenCL buffer: %s", BKE_opencl_message(res));
+ }
+ }
+ }
+ else
+#endif
+ {
+ if (sock->data) {
+ MEM_freeN(sock->data);
+ }
+ }
+}
+
void sim_event_init(SimEvent *event)
{
event->impl = MEM_callocN(sizeof(SimJobEvent), "SimJobEvent");
Modified: branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.h
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.h 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_internal.h 2010-10-10 16:41:21 UTC (rev 32396)
@@ -97,6 +97,9 @@
int num;
} SimWorkerThread;
+void sim_init_socket_buffer(struct SimExecData *execdata, struct SimSocketStack *sock);
+void sim_free_socket_buffer(struct SimExecData *execdata, struct SimSocketStack *sock);
+
void sim_event_init(struct SimEvent *event);
void sim_event_free(struct SimEvent *event);
int sim_event_compare(struct SimEvent *a, struct SimEvent *b);
Modified: branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c 2010-10-10 09:24:24 UTC (rev 32395)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/SIM_util.c 2010-10-10 16:41:21 UTC (rev 32396)
@@ -421,98 +421,6 @@
#endif
-static void init_socket_buffer(SimExecData *execdata, SimSocketStack *sock)
-{
-#ifdef WITH_OPENCL
- if (BKE_opencl_is_active()) {
- cl_int res;
- size_t datasize = sim_get_data_size(sock->type);
- if (datasize > 0 && sock->context.size > 0) {
- sock->data_cl = clCreateBuffer(execdata->opencl_context, CL_MEM_READ_WRITE, sock->context.size * datasize, NULL, &res);
- if (res != CL_SUCCESS) {
- execdata->error = 1;
- sprintf(execdata->error_string, "Error creating OpenCL buffer: %s", BKE_opencl_message(res));
- }
- }
- }
- else
-#endif
- {
- size_t datasize = sim_get_data_size(sock->type);
- if (datasize > 0 && sock->context.size > 0) {
- sock->data = MEM_callocN(datasize * sock->context.size, "socket data");
- }
- else {
- sock->data = NULL;
- }
- }
-}
-
-static void free_socket_buffer(SimExecData *execdata, SimSocketStack *sock)
-{
- if (execdata->error)
- return;
-
-#ifdef WITH_OPENCL
- if (BKE_opencl_is_active()) {
- cl_int res;
- cl_uint refcount;
- res = clGetMemObjectInfo(sock->data_cl, CL_MEM_REFERENCE_COUNT, sizeof(cl_uint), &refcount, NULL);
- if (res == CL_SUCCESS && refcount > 0) {
- clReleaseMemObject(sock->data_cl);
- if (res != CL_SUCCESS) {
- execdata->error = 1;
- sprintf(execdata->error_string, "Error releasing OpenCL buffer: %s", BKE_opencl_message(res));
- }
- }
- }
- else
-#endif
- {
- if (sock->data) {
- MEM_freeN(sock->data);
- }
- }
-}
-
-void sim_node_init_default_data(SimExecData *execdata, SimSocketStack *input, SimDataContext *ctx)
-{
- if (execdata->error)
- return;
-
- input->context = *ctx;
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list