From 690de795803c345dc4916148f016b661c2e634e7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 20 Dec 2011 17:36:56 +0000 Subject: [PATCH 01/12] Cycles: some tweaks for apple opencl with ATI cards, to get it working up to the level of ambient occlusion render, shaders still fail. Fixes found with much help from Jens and Dalai. --- intern/cycles/device/device.cpp | 31 +++++++++++++-- intern/cycles/device/device.h | 4 ++ intern/cycles/device/device_opencl.cpp | 43 ++++++++++++++------- intern/cycles/kernel/CMakeLists.txt | 2 +- intern/cycles/kernel/kernel_compat_opencl.h | 19 +++++++-- 5 files changed, 78 insertions(+), 21 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index f43ccffe461..6ebc359fdb3 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -24,6 +24,7 @@ #include "util_cuda.h" #include "util_debug.h" +#include "util_foreach.h" #include "util_math.h" #include "util_opencl.h" #include "util_opengl.h" @@ -41,7 +42,31 @@ DeviceTask::DeviceTask(Type type_) { } -void DeviceTask::split(ThreadQueue& tasks, int num) +void DeviceTask::split_max_size(list& tasks, int max_size) +{ + int num; + + if(type == DISPLACE) { + num = (displace_w + max_size - 1)/max_size; + } + else { + max_size = max(1, max_size/w); + num = (h + max_size - 1)/max_size; + } + + split(tasks, num); +} + +void DeviceTask::split(ThreadQueue& queue, int num) +{ + list tasks; + split(tasks, num); + + foreach(DeviceTask& task, tasks) + queue.push(task); +} + +void DeviceTask::split(list& tasks, int num) { if(type == DISPLACE) { num = min(displace_w, num); @@ -55,7 +80,7 @@ void DeviceTask::split(ThreadQueue& tasks, int num) task.displace_x = tx; task.displace_w = tw; - tasks.push(task); + tasks.push_back(task); } } else { @@ -70,7 +95,7 @@ void DeviceTask::split(ThreadQueue& tasks, int num) task.y = ty; task.h = th; - tasks.push(task); + tasks.push_back(task); } } } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index be6a3f144ed..a6a81e7b326 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -23,6 +23,7 @@ #include "device_memory.h" +#include "util_list.h" #include "util_string.h" #include "util_thread.h" #include "util_types.h" @@ -67,7 +68,10 @@ public: int displace_x, displace_w; DeviceTask(Type type = PATH_TRACE); + + void split(list& tasks, int num); void split(ThreadQueue& tasks, int num); + void split_max_size(list& tasks, int max_size); }; /* Device */ diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index 3a1d3032d6e..6014dd0fdb7 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -25,6 +25,7 @@ #include "device.h" #include "device_intern.h" +#include "util_foreach.h" #include "util_map.h" #include "util_math.h" #include "util_md5.h" @@ -52,6 +53,7 @@ public: map mem_map; device_ptr null_mem; bool device_initialized; + string platform_name; const char *opencl_error_string(cl_int err) { @@ -175,6 +177,10 @@ public: if(opencl_error(ciErr)) return; + char name[256]; + clGetPlatformInfo(cpPlatform, CL_PLATFORM_NAME, sizeof(name), &name, NULL); + platform_name = name; + cxContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, &ciErr); if(opencl_error(ciErr)) return; @@ -191,7 +197,7 @@ public: { char version[256]; - int major, minor, req_major = 1, req_minor = 0; + int major, minor, req_major = 1, req_minor = 1; clGetPlatformInfo(cpPlatform, CL_PLATFORM_VERSION, sizeof(version), &version, NULL); @@ -277,14 +283,11 @@ public: { string build_options = " -cl-fast-relaxed-math "; - /* Full Shading only on NVIDIA cards at the moment */ - char vendor[256]; - - clGetPlatformInfo(cpPlatform, CL_PLATFORM_NAME, sizeof(vendor), &vendor, NULL); - string name = vendor; - - if(name == "NVIDIA CUDA") - build_options += "-D__KERNEL_SHADING__ -D__MULTI_CLOSURE__ "; + /* full shading only on NVIDIA cards at the moment */ + if(platform_name == "NVIDIA CUDA") + build_options += "-D__KERNEL_SHADING__ -D__MULTI_CLOSURE__ -cl-nv-maxrregcount=24 -cl-nv-verbose "; + if(platform_name == "Apple") + build_options += " -D__CL_NO_FLOAT3__ "; return build_options; } @@ -657,12 +660,24 @@ public: opencl_assert(clFinish(cqCommandQueue)); } - void task_add(DeviceTask& task) + void task_add(DeviceTask& maintask) { - if(task.type == DeviceTask::TONEMAP) - tonemap(task); - else if(task.type == DeviceTask::PATH_TRACE) - path_trace(task); + list tasks; + + /* arbitrary limit to work around apple ATI opencl issue */ + if(platform_name == "Apple") + maintask.split_max_size(tasks, 76800); + else + tasks.push_back(maintask); + + DeviceTask task; + + foreach(DeviceTask& task, tasks) { + if(task.type == DeviceTask::TONEMAP) + tonemap(task); + else if(task.type == DeviceTask::PATH_TRACE) + path_trace(task); + } } void task_wait() diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index e17544bf7af..939a74660a1 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -143,7 +143,7 @@ endif() #set(KERNEL_PREPROCESSED ${CMAKE_CURRENT_BINARY_DIR}/kernel_preprocessed.cl) #add_custom_command( # OUTPUT ${KERNEL_PREPROCESSED} -# COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DWITH_OPENCL -o ${KERNEL_PREPROCESSED} +# COMMAND gcc -x c++ -E ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cl -I ${CMAKE_CURRENT_SOURCE_DIR}/../util/ -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -o ${KERNEL_PREPROCESSED} # DEPENDS ${SRC_KERNEL} ${SRC_UTIL_HEADERS}) #add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED}) #delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel) diff --git a/intern/cycles/kernel/kernel_compat_opencl.h b/intern/cycles/kernel/kernel_compat_opencl.h index 5515966807b..9fbd8566ecd 100644 --- a/intern/cycles/kernel/kernel_compat_opencl.h +++ b/intern/cycles/kernel/kernel_compat_opencl.h @@ -25,12 +25,21 @@ /* no namespaces in opencl */ #define CCL_NAMESPACE_BEGIN #define CCL_NAMESPACE_END -#define WITH_OPENCL + +#ifdef __CL_NO_FLOAT3__ +#define float3 float4 +#endif + +#ifdef __CL_NOINLINE__ +#define __noinline __attribute__((noinline)) +#else +#define __noinline +#endif /* in opencl all functions are device functions, so leave this empty */ #define __device -#define __device_inline -#define __device_noinline +#define __device_inline __device +#define __device_noinline __device __noinline /* no assert in opencl */ #define kernel_assert(cond) @@ -68,7 +77,11 @@ __device float kernel_tex_interp_(__global float *data, int width, float x) #endif #define make_float2(x, y) ((float2)(x, y)) +#ifdef __CL_NO_FLOAT3__ +#define make_float3(x, y, z) ((float4)(x, y, z, 0.0)) +#else #define make_float3(x, y, z) ((float3)(x, y, z)) +#endif #define make_float4(x, y, z, w) ((float4)(x, y, z, w)) #define make_int2(x, y) ((int2)(x, y)) #define make_int3(x, y, z) ((int3)(x, y, z)) From 2d1de2e78d619ffd999876768a9466d083984a9f Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Tue, 20 Dec 2011 18:59:10 +0000 Subject: [PATCH 02/12] Cycles/CUDA: * Rename shader model to compute capability in error messages. --- intern/cycles/device/device_cuda.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index dfa2fcb2322..2a49d4fae4c 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -221,7 +221,7 @@ public: cuDeviceComputeCapability(&major, &minor, cuDevId); if(major <= 1 && minor <= 2) { - cuda_error(string_printf("CUDA device supported only with shader model 1.3 or up, found %d.%d.", major, minor)); + cuda_error(string_printf("CUDA device supported only with compute capability 1.3 or up, found %d.%d.", major, minor)); return false; } } @@ -253,9 +253,9 @@ public: #if defined(WITH_CUDA_BINARIES) && defined(_WIN32) if(major <= 1 && minor <= 2) - cuda_error(string_printf("CUDA device supported only with shader model 1.3 or up, found %d.%d.", major, minor)); + cuda_error(string_printf("CUDA device supported only compute capability 1.3 or up, found %d.%d.", major, minor)); else - cuda_error(string_printf("CUDA binary kernel for this graphics card shader model (%d.%d) not found.", major, minor)); + cuda_error(string_printf("CUDA binary kernel for this graphics card compute capability (%d.%d) not found.", major, minor)); return ""; #else /* if not, find CUDA compiler */ From 0e4f1ad43d74d5ed277b65b96cd6c5f51c51739c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Dec 2011 23:14:29 +0000 Subject: [PATCH 03/12] topo mirror and sync with minor edits made to bmesh, no functional changes --- source/blender/editors/include/ED_mesh.h | 3 +- source/blender/editors/mesh/editface.c | 154 ++++++++++++----------- source/blender/editors/mesh/meshtools.c | 2 +- 3 files changed, 86 insertions(+), 73 deletions(-) diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 3a69db013c0..6b374274205 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -253,7 +253,8 @@ typedef struct MirrTopoStore_t { } MirrTopoStore_t; int ED_mesh_mirrtopo_recalc_check(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store); -void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store); +void ED_mesh_mirrtopo_init(struct Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store, + const short skip_em_vert_array_init); void ED_mesh_mirrtopo_free(MirrTopoStore_t *mesh_topo_store); #ifdef __cplusplus diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index 95c71488d26..42a1b7e88f0 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -823,22 +823,22 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) typedef int MirrTopoHash_t; -typedef struct MirrTopoPair_t { +typedef struct MirrTopoVert_t { MirrTopoHash_t hash; int v_index; -} MirrTopoPair_t; +} MirrTopoVert_t; -static int MirrTopo_long_sort(const void *l1, const void *l2) +static int mirrtopo_hash_sort(const void *l1, const void *l2) { if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2 ) return 1; else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2 ) return -1; return 0; } -static int MirrTopo_item_sort(const void *v1, const void *v2) +static int mirrtopo_vert_sort(const void *v1, const void *v2) { - if (((MirrTopoPair_t *)v1)->hash > ((MirrTopoPair_t *)v2)->hash ) return 1; - else if (((MirrTopoPair_t *)v1)->hash < ((MirrTopoPair_t *)v2)->hash ) return -1; + if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash ) return 1; + else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash ) return -1; return 0; } @@ -848,12 +848,12 @@ int ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t * int totedge; if (me->edit_mesh) { - totvert= me->edit_mesh->totvert; - totedge= me->edit_mesh->totedge; + totvert = me->edit_mesh->totvert; + totedge = me->edit_mesh->totedge; } else { - totvert= me->totvert; - totedge= me->totedge; + totvert = me->totvert; + totedge = me->totedge; } if( (mesh_topo_store->index_lookup==NULL) || @@ -869,33 +869,36 @@ int ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t * } -void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store) +void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_topo_store, + const short skip_em_vert_array_init) { MEdge *medge; - EditMesh *em= me->edit_mesh; - void **eve_tmp_back= NULL; /* some of the callers are using eve->tmp so restore after */ + EditMesh *em = me->edit_mesh; + void **eve_tmp_back = NULL; /* some of the callers are using eve->tmp so restore after */ /* editmode*/ EditEdge *eed; int a, last; int totvert, totedge; - int totUnique= -1, totUniqueOld= -1; + int tot_unique = -1, tot_unique_prev = -1; - MirrTopoHash_t *MirrTopoHash = NULL; - MirrTopoHash_t *MirrTopoHash_Prev = NULL; - MirrTopoPair_t *MirrTopoPairs; + MirrTopoHash_t *topo_hash = NULL; + MirrTopoHash_t *topo_hash_prev = NULL; + MirrTopoVert_t *topo_pairs; + + intptr_t *index_lookup; /* direct access to mesh_topo_store->index_lookup */ /* reallocate if needed */ ED_mesh_mirrtopo_free(mesh_topo_store); - mesh_topo_store->prev_ob_mode= ob_mode; + mesh_topo_store->prev_ob_mode = ob_mode; if(em) { EditVert *eve; - totvert= 0; - eve_tmp_back= MEM_callocN( em->totvert * sizeof(void *), "TopoMirr" ); - for(eve= em->verts.first; eve; eve= eve->next) { + totvert = 0; + eve_tmp_back = MEM_mallocN(em->totvert * sizeof(void *), "TopoMirr"); + for(eve = em->verts.first; eve; eve = eve->next) { eve_tmp_back[totvert]= eve->tmp.p; eve->tmp.l = totvert++; } @@ -904,130 +907,139 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to totvert = me->totvert; } - MirrTopoHash = MEM_callocN( totvert * sizeof(MirrTopoHash_t), "TopoMirr" ); + topo_hash = MEM_callocN(totvert * sizeof(MirrTopoHash_t), "TopoMirr"); /* Initialize the vert-edge-user counts used to detect unique topology */ if(em) { - totedge= 0; + totedge = 0; - for(eed=em->edges.first; eed; eed= eed->next, totedge++) { - MirrTopoHash[eed->v1->tmp.l]++; - MirrTopoHash[eed->v2->tmp.l]++; + for(eed=em->edges.first; eed; eed = eed->next, totedge++) { + topo_hash[eed->v1->tmp.l]++; + topo_hash[eed->v2->tmp.l]++; } - } else { - totedge= me->totedge; + } + else { + totedge = me->totedge; for(a=0, medge=me->medge; a < me->totedge; a++, medge++) { - MirrTopoHash[medge->v1]++; - MirrTopoHash[medge->v2]++; + topo_hash[medge->v1]++; + topo_hash[medge->v2]++; } } - MirrTopoHash_Prev = MEM_dupallocN( MirrTopoHash ); + topo_hash_prev = MEM_dupallocN(topo_hash); - totUniqueOld = -1; + tot_unique_prev = -1; while(1) { /* use the number of edges per vert to give verts unique topology IDs */ if(em) { - for(eed=em->edges.first; eed; eed= eed->next) { - MirrTopoHash[eed->v1->tmp.l] += MirrTopoHash_Prev[eed->v2->tmp.l]; - MirrTopoHash[eed->v2->tmp.l] += MirrTopoHash_Prev[eed->v1->tmp.l]; + for(eed=em->edges.first; eed; eed = eed->next) { + topo_hash[eed->v1->tmp.l] += topo_hash_prev[eed->v2->tmp.l]; + topo_hash[eed->v2->tmp.l] += topo_hash_prev[eed->v1->tmp.l]; } - } else { + } + else { for(a=0, medge=me->medge; atotedge; a++, medge++) { /* This can make really big numbers, wrapping around here is fine */ - MirrTopoHash[medge->v1] += MirrTopoHash_Prev[medge->v2]; - MirrTopoHash[medge->v2] += MirrTopoHash_Prev[medge->v1]; + topo_hash[medge->v1] += topo_hash_prev[medge->v2]; + topo_hash[medge->v2] += topo_hash_prev[medge->v1]; } } - memcpy(MirrTopoHash_Prev, MirrTopoHash, sizeof(MirrTopoHash_t) * totvert); + memcpy(topo_hash_prev, topo_hash, sizeof(MirrTopoHash_t) * totvert); /* sort so we can count unique values */ - qsort(MirrTopoHash_Prev, totvert, sizeof(MirrTopoHash_t), MirrTopo_long_sort); + qsort(topo_hash_prev, totvert, sizeof(MirrTopoHash_t), mirrtopo_hash_sort); - totUnique = 1; /* account for skiping the first value */ + tot_unique = 1; /* account for skiping the first value */ for(a=1; atmp.* */ if(eve_tmp_back) { EditVert *eve; - totvert= 0; - for(eve= em->verts.first; eve; eve= eve->next) { - eve->tmp.p= eve_tmp_back[totvert++]; + totvert = 0; + for(eve = em->verts.first; eve; eve = eve->next) { + eve->tmp.p = eve_tmp_back[totvert++]; } MEM_freeN(eve_tmp_back); - eve_tmp_back= NULL; + eve_tmp_back = NULL; } /* Hash/Index pairs are needed for sorting to find index pairs */ - MirrTopoPairs= MEM_callocN( sizeof(MirrTopoPair_t) * totvert, "MirrTopoPairs"); + topo_pairs = MEM_callocN( sizeof(MirrTopoVert_t) * totvert, "MirrTopoPairs"); /* since we are looping through verts, initialize these values here too */ - mesh_topo_store->index_lookup = MEM_mallocN( totvert * sizeof(long), "mesh_topo_lookup" ); + index_lookup = MEM_mallocN(totvert * sizeof(*index_lookup), "mesh_topo_lookup"); if(em) { - EM_init_index_arrays(em,1,0,0); + if (skip_em_vert_array_init == FALSE) { + EM_init_index_arrays(em, 1, 0, 0); + } } for(a=0; aindex_lookup[a] = -1; + index_lookup[a] = -1; } - qsort(MirrTopoPairs, totvert, sizeof(MirrTopoPair_t), MirrTopo_item_sort); + qsort(topo_pairs, totvert, sizeof(MirrTopoVert_t), mirrtopo_vert_sort); /* Since the loop starts at 2, we must define the last index where the hash's differ */ - last = ((totvert >= 2) && (MirrTopoPairs[0].hash == MirrTopoPairs[1].hash)) ? 0 : 1; + last = ((totvert >= 2) && (topo_pairs[0].hash == topo_pairs[1].hash)) ? 0 : 1; /* Get the pairs out of the sorted hashes, note, totvert+1 means we can use the previous 2, * but you cant ever access the last 'a' index of MirrTopoPairs */ for(a=2; a <= totvert; a++) { /* printf("I %d %ld %d\n", (a-last), MirrTopoPairs[a ].hash, MirrTopoPairs[a ].vIndex ); */ - if ((a==totvert) || (MirrTopoPairs[a-1].hash != MirrTopoPairs[a].hash)) { + if ((a==totvert) || (topo_pairs[a-1].hash != topo_pairs[a].hash)) { if (a-last==2) { if(em) { - mesh_topo_store->index_lookup[MirrTopoPairs[a-1].v_index] = (intptr_t)EM_get_vert_for_index(MirrTopoPairs[a-2].v_index); - mesh_topo_store->index_lookup[MirrTopoPairs[a-2].v_index] = (intptr_t)EM_get_vert_for_index(MirrTopoPairs[a-1].v_index); - } else { - mesh_topo_store->index_lookup[MirrTopoPairs[a-1].v_index] = MirrTopoPairs[a-2].v_index; - mesh_topo_store->index_lookup[MirrTopoPairs[a-2].v_index] = MirrTopoPairs[a-1].v_index; + index_lookup[topo_pairs[a-1].v_index] = (intptr_t)EM_get_vert_for_index(topo_pairs[a-2].v_index); + index_lookup[topo_pairs[a-2].v_index] = (intptr_t)EM_get_vert_for_index(topo_pairs[a-1].v_index); + } + else { + index_lookup[topo_pairs[a-1].v_index] = topo_pairs[a-2].v_index; + index_lookup[topo_pairs[a-2].v_index] = topo_pairs[a-1].v_index; } } - last= a; + last = a; } } if(em) { - EM_free_index_arrays(); + if (skip_em_vert_array_init == FALSE) { + EM_free_index_arrays(); + } } - MEM_freeN( MirrTopoPairs ); - MirrTopoPairs = NULL; + MEM_freeN(topo_pairs); + topo_pairs = NULL; - MEM_freeN( MirrTopoHash ); - MEM_freeN( MirrTopoHash_Prev ); + MEM_freeN(topo_hash); + MEM_freeN(topo_hash_prev); + mesh_topo_store->index_lookup = index_lookup; mesh_topo_store->prev_vert_tot = totvert; mesh_topo_store->prev_edge_tot = totedge; } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 77daf21affa..f3722e81246 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -861,7 +861,7 @@ int mesh_mirrtopo_table(Object *ob, char mode) } } else if(mode=='s') { /* start table */ - ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store); + ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store, FALSE); } else if(mode=='e') { /* end table */ ED_mesh_mirrtopo_free(&mesh_topo_store); From 056c49e9ec53849f75aa091f9a98638e77eb82f5 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Wed, 21 Dec 2011 02:41:27 +0000 Subject: [PATCH 04/12] Patch [#29654] New menu option under Object > Game with "Copy All Physics Attributes" by Daniel Macedo "This is a patch that adds an option under the menu Object > Game to copy all the physics attributes from Game Engine." --- release/scripts/startup/bl_ui/space_view3d.py | 1 + source/blender/editors/object/object_edit.c | 48 +++++++++++++++++++ source/blender/editors/object/object_intern.h | 1 + source/blender/editors/object/object_ops.c | 1 + 4 files changed, 51 insertions(+) diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 5444ad327a9..57bde4eb0dd 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -993,6 +993,7 @@ class VIEW3D_MT_object_game(Menu): layout = self.layout layout.operator("object.logic_bricks_copy", text="Copy Logic Bricks") + layout.operator("object.game_physics_copy", text="Copy Physics Properties") layout.separator() diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 07ab80f6d15..fa308624454 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2178,3 +2178,51 @@ void OBJECT_OT_logic_bricks_copy(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } + +static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob=ED_object_active_context(C); + + CTX_DATA_BEGIN(C, Object*, ob_iter, selected_editable_objects) { + if(ob != ob_iter) { + ob_iter->gameflag = ob->gameflag; + ob_iter->gameflag2 = ob->gameflag2; + ob_iter->inertia = ob->inertia; + ob_iter->formfactor = ob->formfactor;; + ob_iter->damping = ob->damping; + ob_iter->rdamping = ob->rdamping; + ob_iter->min_vel = ob->min_vel; + ob_iter->max_vel = ob->max_vel; + ob_iter->obstacleRad = ob->obstacleRad; + ob_iter->mass = ob->mass; + ob_iter->anisotropicFriction[0] = ob->anisotropicFriction[0]; + ob_iter->anisotropicFriction[1] = ob->anisotropicFriction[1]; + ob_iter->anisotropicFriction[2] = ob->anisotropicFriction[2]; + ob_iter->collision_boundtype = ob->collision_boundtype; + ob_iter->margin = ob->margin; + ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft); + if(ob->restrictflag & OB_RESTRICT_RENDER) + ob_iter->restrictflag |= OB_RESTRICT_RENDER; + else + ob_iter->restrictflag &= ~OB_RESTRICT_RENDER; + } + } + CTX_DATA_END; + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Copy Game Physics Properties to Selected"; + ot->description = "Copy game physics properties to other selected objects"; + ot->idname= "OBJECT_OT_game_physics_copy"; + + /* api callbacks */ + ot->exec= game_physics_copy_exec; + ot->poll= ED_operator_object_active_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index 185d8d43765..35e802e3e11 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -92,6 +92,7 @@ void OBJECT_OT_game_property_remove(struct wmOperatorType *ot); void OBJECT_OT_game_property_copy(struct wmOperatorType *ot); void OBJECT_OT_game_property_clear(struct wmOperatorType *ot); void OBJECT_OT_logic_bricks_copy(struct wmOperatorType *ot); +void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot); /* object_select.c */ void OBJECT_OT_select_all(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 3b4a5ed976e..a899d60c2ab 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -189,6 +189,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_game_property_copy); WM_operatortype_append(OBJECT_OT_game_property_clear); WM_operatortype_append(OBJECT_OT_logic_bricks_copy); + WM_operatortype_append(OBJECT_OT_game_physics_copy); WM_operatortype_append(OBJECT_OT_shape_key_add); WM_operatortype_append(OBJECT_OT_shape_key_remove); From 8fbff6100d9dc2430b98b61f4681a3afff24acae Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 21 Dec 2011 11:01:08 +0000 Subject: [PATCH 05/12] Added Record run no gaps timecode for movie clips. Also get rid of hardcoded constants in readfile and use constants from ImBuf headers. --- source/blender/blenkernel/intern/movieclip.c | 5 ++++- source/blender/blenloader/CMakeLists.txt | 1 + source/blender/blenloader/SConscript | 2 +- source/blender/blenloader/intern/readfile.c | 16 +++++++++++++--- source/blender/makesrna/intern/rna_movieclip.c | 1 + 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 75d8ec584e8..736c889f66c 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -372,7 +372,10 @@ static MovieClip *movieclip_alloc(const char *name) BKE_tracking_init_settings(&clip->tracking); clip->proxy.build_size_flag= IMB_PROXY_25; - clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN|IMB_TC_FREE_RUN|IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN; + clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN | + IMB_TC_FREE_RUN | + IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN | + IMB_TC_RECORD_RUN_NO_GAPS; clip->proxy.quality= 90; return clip; diff --git a/source/blender/blenloader/CMakeLists.txt b/source/blender/blenloader/CMakeLists.txt index 9cf721738a7..35271f7b873 100644 --- a/source/blender/blenloader/CMakeLists.txt +++ b/source/blender/blenloader/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../nodes ../render/extern/include ../../../intern/guardedalloc + ../imbuf ) set(INC_SYS diff --git a/source/blender/blenloader/SConscript b/source/blender/blenloader/SConscript index d5d2df3ea35..0333eab7e1f 100644 --- a/source/blender/blenloader/SConscript +++ b/source/blender/blenloader/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c') incs = '. #/intern/guardedalloc ../blenlib ../blenkernel' incs += ' ../makesdna ../editors/include' -incs += ' ../render/extern/include ../makesrna ../nodes' +incs += ' ../render/extern/include ../makesrna ../nodes ../imbuf' incs += ' ' + env['BF_ZLIB_INC'] diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 593b526d38b..bf40a3e73b3 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -139,6 +139,8 @@ #include "BKE_utildefines.h" // SWITCH_INT DATA ENDB DNA1 O_BINARY GLOB USER TEST REND #include "BKE_sound.h" +#include "IMB_imbuf.h" // for proxy / timecode versioning stuff + #include "NOD_socket.h" //XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes @@ -12588,10 +12590,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) clip->aspy= 1.0f; } - /* XXX: a bit hacky, probably include imbuf and use real constants are nicer */ - clip->proxy.build_tc_flag= 7; + clip->proxy.build_tc_flag= IMB_TC_RECORD_RUN | + IMB_TC_FREE_RUN | + IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN; + if(clip->proxy.build_size_flag==0) - clip->proxy.build_size_flag= 1; + clip->proxy.build_size_flag= IMB_PROXY_25; if(clip->proxy.quality==0) clip->proxy.quality= 90; @@ -12731,6 +12735,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main) scene->gm.exitkey = 218; // Blender key code for ESC } } + { + MovieClip *clip; + for(clip= main->movieclip.first; clip; clip= clip->id.next) { + clip->proxy.build_tc_flag|= IMB_TC_RECORD_RUN_NO_GAPS; + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/makesrna/intern/rna_movieclip.c b/source/blender/makesrna/intern/rna_movieclip.c index 3b1ac8f22c3..fbc6a0155f2 100644 --- a/source/blender/makesrna/intern/rna_movieclip.c +++ b/source/blender/makesrna/intern/rna_movieclip.c @@ -78,6 +78,7 @@ static void rna_def_movieclip_proxy(BlenderRNA *brna) {IMB_TC_RECORD_RUN, "RECORD_RUN", 0, "Record Run", "Use images in the order they are recorded"}, {IMB_TC_FREE_RUN, "FREE_RUN", 0, "Free Run", "Use global timestamp written by recording device"}, {IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN, "FREE_RUN_REC_DATE", 0, "Free Run (rec date)", "Interpolate a global timestamp using the record date and time written by recording device"}, + {IMB_TC_RECORD_RUN_NO_GAPS, "FREE_RUN_NO_GAPS", 0, "Free Run No Gaps", "Record run, but ignore timecode, changes in framerate or dropouts"}, {0, NULL, 0, NULL, NULL}}; srna = RNA_def_struct(brna, "MovieClipProxy", NULL); From 01de7c2979dd95aa87652a6fb54bcf7fae3a9d13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 21 Dec 2011 11:36:28 +0000 Subject: [PATCH 06/12] fix for mathutils mat*vec for non sqyare matrices by Andrew Hale --- source/blender/python/mathutils/mathutils_Vector.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index bd121b6177f..4e6fce59b7e 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1576,7 +1576,7 @@ static PyObject *Vector_mul(PyObject *v1, PyObject *v2) return NULL; } - return Vector_CreatePyObject(tvec, vec1->size, Py_NEW, Py_TYPE(vec1)); + return Vector_CreatePyObject(tvec, ((MatrixObject *)v2)->num_col, Py_NEW, Py_TYPE(vec1)); } else if (QuaternionObject_Check(v2)) { /* VEC * QUAT */ @@ -2603,7 +2603,7 @@ if len(unique) != len(items): */ /* ROW VECTOR Multiplication - Vector X Matrix - * [x][y][z] * [1][4][7] + * [x][y][z] * [1][4][7] * [2][5][8] * [3][6][9] * vector/matrix multiplication IS NOT COMMUTATIVE!!!! */ @@ -2611,7 +2611,7 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v { float vec_cpy[MAX_DIMENSIONS]; double dot = 0.0f; - int x, y, z= 0, vec_size= vec->size; + int row, col, z= 0, vec_size= vec->size; if (mat->num_row != vec_size) { if (mat->num_row == 4 && vec_size != 3) { @@ -2632,9 +2632,9 @@ static int row_vector_multiplication(float rvec[MAX_DIMENSIONS], VectorObject *v rvec[3] = 1.0f; //muliplication - for (x = 0; x < mat->num_col; x++) { - for (y = 0; y < mat->num_row; y++) { - dot += MATRIX_ITEM(mat, y, x) * vec_cpy[y]; + for (col = 0; col < mat->num_col; col++) { + for (row = 0; row < mat->num_row; row++) { + dot += MATRIX_ITEM(mat, row, col) * vec_cpy[row]; } rvec[z++] = (float)dot; dot = 0.0f; From 04077f46802b6561cb2e4f7942903ba5c9666f2f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 21 Dec 2011 11:56:42 +0000 Subject: [PATCH 07/12] =?UTF-8?q?Small=20i18n=20edits:=20*=20Added=20serbi?= =?UTF-8?q?an=5Flatin=20locale=20(sr@latin).=20*=20Changed=20serbian=20UI?= =?UTF-8?q?=20to=20=20"Serbian=20(=D0=A1=D1=80=D0=BF=D1=81=D0=BA=D0=B8)"?= =?UTF-8?q?=20(as=20requested=20by=20Nikola=20Radovanovic,=20serbian=20tra?= =?UTF-8?q?nslator).=20*=20Reordered=20languages=20in=20menu=20in=20alphab?= =?UTF-8?q?etical=20order!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/blenfont/intern/blf_lang.c | 5 ++- source/blender/makesrna/intern/rna_userdef.c | 47 +++++++++++--------- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 2ba23e501b4..77f9542883c 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -86,7 +86,7 @@ static const char *locales[] = { "Chinese (Traditional)_China.1252", "zh_TW", "russian", "ru_RU", "croatian", "hr_HR", - "serbian", "sr_RS", + "serbian", "sr", "ukrainian", "uk_UA", "polish", "pl_PL", "romanian", "ro_RO", @@ -96,7 +96,8 @@ static const char *locales[] = { "korean", "ko_KR", "nepali", "ne_NP", "persian", "fa_PE", - "indonesian", "id_ID" + "indonesian", "id_ID", + "serbian (latin)", "sr@latin", }; void BLF_lang_init(void) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index f9b20d3ac78..c0a644f5758 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2607,40 +2607,43 @@ static void rna_def_userdef_system(BlenderRNA *brna) /* hardcoded here, could become dynamic somehow */ /* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */ /* if you edit here, please also edit the source/blender/blenfont/intern/blf_lang.c 's locales */ + /* Note: As this list is in alphabetical order, and not defined order, + * here is the highest define currently in use: 28 (serbian latin). */ static EnumPropertyItem language_items[] = { - {0, "", 0, "Nearly done", ""}, - {0, "DEFAULT", 0, "Default (Default)", ""}, - {1, "ENGLISH", 0, "English (English)", "en_US"}, - {8, "FRENCH", 0, "French (Français)", "fr_FR"}, - {4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"}, + { 0, "", 0, "Nearly done", ""}, + { 0, "DEFAULT", 0, "Default (Default)", ""}, + { 1, "ENGLISH", 0, "English (English)", "en_US"}, + { 8, "FRENCH", 0, "French (Français)", "fr_FR"}, + { 4, "ITALIAN", 0, "Italian (Italiano)", "it_IT"}, {15, "RUSSIAN", 0, "Russian (Русский)", "ru_RU"}, {13, "SIMPLIFIED_CHINESE", 0, "Simplified Chinese (简体中文)", "zh_CN"}, - {9, "SPANISH", 0, "Spanish (Español)", "es"}, + { 9, "SPANISH", 0, "Spanish (Español)", "es"}, {14, "TRADITIONAL_CHINESE", 0, "Traditional Chinese (繁體中文)", "zh_TW"}, - {0, "", 0, "In progress", ""}, - {2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"}, - {3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, - {5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, - {6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, - {7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, - {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, - {11, "CZECH", 0, "Czech (Český)", "cs_CZ"}, - {12, "BRAZILIAN_PORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"}, - {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, - {17, "SERBIAN", 0, "Serbian (Српском језику)", "sr_RS"}, - {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, - {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, - {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, + { 0, "", 0, "In progress", ""}, /* using the utf8 flipped form of Arabic (العربية) */ {21, "ARABIC", 0, "Arabic (ﺔﻴﺑﺮﻌﻟﺍ)", "ar_EG"}, + {12, "BRAZILIAN_PORTUGUESE", 0, "Brazilian Portuguese (Português do Brasil)", "pt_BR"}, {22, "BULGARIAN", 0, "Bulgarian (Български)", "bg_BG"}, + {10, "CATALAN", 0, "Catalan (Català)", "ca_AD"}, + {16, "CROATIAN", 0, "Croatian (Hrvatski)", "hr_HR"}, + {11, "CZECH", 0, "Czech (Český)", "cs_CZ"}, + { 3, "DUTCH", 0, "Dutch (Nederlandse taal)", "nl_NL"}, + { 6, "FINNISH", 0, "Finnish (Suomi)", "fi_FI"}, + { 5, "GERMAN", 0, "German (Deutsch)", "de_DE"}, {23, "GREEK", 0, "Greek (Ελληνικά)", "el_GR"}, + {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, + { 2, "JAPANESE", 0, "Japanese (日本語)", "ja_JP"}, {24, "KOREAN", 0, "Korean (한국 언어)", "ko_KR"}, {25, "NEPALI", 0, "Nepali (नेपाली)", "ne_NP"}, /* using the utf8 flipped form of Persian (فارسی) */ {26, "PERSIAN", 0, "Persian (ﯽﺳﺭﺎﻓ)", "fa_PE"}, - {27, "INDONESIAN", 0, "Indonesian (Bahasa indonesia)", "id_ID"}, - {0, NULL, 0, NULL, NULL}}; + {19, "POLISH", 0, "Polish (Polski)", "pl_PL"}, + {20, "ROMANIAN", 0, "Romanian (Român)", "ro_RO"}, + {17, "SERBIAN", 0, "Serbian (Српски)", "sr"}, + {28, "SERBIAN_LATIN", 0, "Serbian latin (Srpski latinica)", "sr@latin"}, + { 7, "SWEDISH", 0, "Swedish (Svenska)", "sv_SE"}, + {18, "UKRAINIAN", 0, "Ukrainian (Український)", "uk_UA"}, + { 0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesSystem", NULL); RNA_def_struct_sdna(srna, "UserDef"); From 045a91a37860dd40a2604f8208325b8d11c9e3a9 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 21 Dec 2011 13:31:28 +0000 Subject: [PATCH 08/12] Do not show "Modify" modifiers group for curve objects This commit prevents adding empty groups to Add Modifier menu making this menu small and nice for objects which don't support all modifiers from some group (like Curves don't support Modify modifiers). --- source/blender/editors/object/object_modifier.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 913e5893a77..9a592bc9324 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -643,7 +643,7 @@ static int modifier_add_exec(bContext *C, wmOperator *op) static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Object *ob= ED_object_active_context(C); - EnumPropertyItem *item= NULL, *md_item; + EnumPropertyItem *item= NULL, *md_item, *group_item= NULL; ModifierTypeInfo *mti; int totitem= 0, a; @@ -663,6 +663,17 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) continue; } + else { + group_item= md_item; + md_item= NULL; + + continue; + } + + if(group_item) { + RNA_enum_item_add(&item, &totitem, group_item); + group_item= NULL; + } RNA_enum_item_add(&item, &totitem, md_item); } From 34909c64e57149c997ebb7e3d794c6ceff0541b0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 13:48:35 +0000 Subject: [PATCH 09/12] Cycles: some small code refactoring related to buffer parameters. --- intern/cycles/render/buffers.h | 6 ++++++ intern/cycles/render/session.cpp | 24 ++++++++++-------------- intern/cycles/render/tile.cpp | 16 ++++++++-------- intern/cycles/render/tile.h | 6 ++---- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index 66bd03c8893..f4a9b37c09b 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -56,6 +56,12 @@ public: full_height = 0; } + void get_offset_stride(int& offset, int& stride) + { + offset = -(full_x + full_y*width); + stride = width; + } + bool modified(const BufferParams& params) { return !(full_x == params.full_x diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 26c4dbfbb7a..be2e493dc7f 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -515,10 +515,8 @@ void Session::update_scene() knows nothing about progressive or cropped rendering, it just gets the image dimensions passed in */ Camera *cam = scene->camera; - float progressive_x = tile_manager.state.width/(float)tile_manager.params.width; - float progressive_y = tile_manager.state.height/(float)tile_manager.params.height; - int width = tile_manager.params.full_width*progressive_x; - int height = tile_manager.params.full_height*progressive_y; + int width = tile_manager.state.buffer.full_width; + int height = tile_manager.state.buffer.full_height; if(width != cam->width || height != cam->height) { cam->width = width; @@ -574,16 +572,15 @@ void Session::path_trace(Tile& tile) /* add path trace task */ DeviceTask task(DeviceTask::PATH_TRACE); - task.x = tile_manager.state.full_x + tile.x; - task.y = tile_manager.state.full_y + tile.y; + task.x = tile_manager.state.buffer.full_x + tile.x; + task.y = tile_manager.state.buffer.full_y + tile.y; task.w = tile.w; task.h = tile.h; task.buffer = buffers->buffer.device_pointer; task.rng_state = buffers->rng_state.device_pointer; task.sample = tile_manager.state.sample; task.resolution = tile_manager.state.resolution; - task.offset = -(tile_manager.state.full_x + tile_manager.state.full_y*tile_manager.state.width); - task.stride = tile_manager.state.width; + tile_manager.state.buffer.get_offset_stride(task.offset, task.stride); device->task_add(task); } @@ -593,16 +590,15 @@ void Session::tonemap() /* add tonemap task */ DeviceTask task(DeviceTask::TONEMAP); - task.x = tile_manager.state.full_x; - task.y = tile_manager.state.full_y; - task.w = tile_manager.state.width; - task.h = tile_manager.state.height; + task.x = tile_manager.state.buffer.full_x; + task.y = tile_manager.state.buffer.full_y; + task.w = tile_manager.state.buffer.width; + task.h = tile_manager.state.buffer.height; task.rgba = display->rgba.device_pointer; task.buffer = buffers->buffer.device_pointer; task.sample = tile_manager.state.sample; task.resolution = tile_manager.state.resolution; - task.offset = -(tile_manager.state.full_x + tile_manager.state.full_y*tile_manager.state.width); - task.stride = tile_manager.state.width; + tile_manager.state.buffer.get_offset_stride(task.offset, task.stride); if(task.w > 0 && task.h > 0) { device->task_add(task); diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp index b118a7ba478..40833e5b08b 100644 --- a/intern/cycles/render/tile.cpp +++ b/intern/cycles/render/tile.cpp @@ -55,10 +55,7 @@ void TileManager::reset(BufferParams& params_, int samples_) samples = samples_; - state.full_x = 0; - state.full_y = 0; - state.width = 0; - state.height = 0; + state.buffer = BufferParams(); state.sample = -1; state.resolution = start_resolution; state.tiles.clear(); @@ -92,10 +89,13 @@ void TileManager::set_tiles() } } - state.full_x = params.full_x/resolution; - state.full_y = params.full_y/resolution; - state.width = image_w; - state.height = image_h; + state.buffer.width = image_w; + state.buffer.height = image_h; + + state.buffer.full_x = params.full_x/resolution; + state.buffer.full_y = params.full_y/resolution; + state.buffer.full_width = max(1, params.full_width/resolution); + state.buffer.full_height = max(1, params.full_height/resolution); } bool TileManager::done() diff --git a/intern/cycles/render/tile.h b/intern/cycles/render/tile.h index 76863d23498..b6e610c8d90 100644 --- a/intern/cycles/render/tile.h +++ b/intern/cycles/render/tile.h @@ -41,11 +41,9 @@ public: class TileManager { public: BufferParams params; + struct State { - int full_x; - int full_y; - int width; - int height; + BufferParams buffer; int sample; int resolution; list tiles; From 1dd72692cd69fed019f8be0701c9d776cd45c721 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 13:48:51 +0000 Subject: [PATCH 10/12] Code refactoring: move MD5 out of imbuf into blenlib. --- source/blender/blenlib/BLI_md5.h | 45 +++++++ source/blender/blenlib/CMakeLists.txt | 2 + .../blender/{imbuf => blenlib}/intern/md5.c | 102 +++++++++++---- source/blender/imbuf/CMakeLists.txt | 2 - source/blender/imbuf/intern/md5.h | 119 ------------------ source/blender/imbuf/intern/thumbs.c | 9 +- 6 files changed, 130 insertions(+), 149 deletions(-) create mode 100644 source/blender/blenlib/BLI_md5.h rename source/blender/{imbuf => blenlib}/intern/md5.c (80%) delete mode 100644 source/blender/imbuf/intern/md5.h diff --git a/source/blender/blenlib/BLI_md5.h b/source/blender/blenlib/BLI_md5.h new file mode 100644 index 00000000000..afcc3cdfa3e --- /dev/null +++ b/source/blender/blenlib/BLI_md5.h @@ -0,0 +1,45 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef BLI_MD5_H +#define BLI_MD5_H + +/** \file BLI_md5.h + * \ingroup bli + */ + +#include +#include + +/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The + result is always in little endian byte order, so that a byte-wise + output yields to the wanted ASCII representation of the message + digest. */ + +void *md5_buffer(const char *buffer, size_t len, void *resblock); + +/* Compute MD5 message digest for bytes read from STREAM. The + resulting message digest number will be written into the 16 bytes + beginning at RESBLOCK. */ + +int md5_stream(FILE *stream, void *resblock); + +#endif + diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index 5d54ffbeb36..fb9b8021b8e 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -71,6 +71,7 @@ set(SRC intern/math_rotation.c intern/math_vector.c intern/math_vector_inline.c + intern/md5.c intern/noise.c intern/path_util.c intern/pbvh.c @@ -117,6 +118,7 @@ set(SRC BLI_math_matrix.h BLI_math_rotation.h BLI_math_vector.h + BLI_md5.h BLI_memarena.h BLI_mempool.h BLI_noise.h diff --git a/source/blender/imbuf/intern/md5.c b/source/blender/blenlib/intern/md5.c similarity index 80% rename from source/blender/imbuf/intern/md5.c rename to source/blender/blenlib/intern/md5.c index 2192fa32f19..25582a5f750 100644 --- a/source/blender/imbuf/intern/md5.c +++ b/source/blender/blenlib/intern/md5.c @@ -21,12 +21,82 @@ /* Written by Ulrich Drepper . */ +#include +#include +#include #include -# include -# include +#if defined HAVE_LIMITS_H || defined _LIBC +# include +#endif + +/* The following contortions are an attempt to use the C preprocessor + to determine an unsigned integral type that is 32 bits wide. An + alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but + doing that would require that the configure script compile and *run* + the resulting executable. Locally running cross-compiled executables + is usually not possible. */ + +#if defined __STDC__ && __STDC__ +# define UINT_MAX_32_BITS 4294967295U +#else +# define UINT_MAX_32_BITS 0xFFFFFFFF +#endif + +/* If UINT_MAX isn't defined, assume it's a 32-bit type. + This should be valid for all systems GNU cares about because + that doesn't include 16-bit systems, and only modern systems + (that certainly have ) have 64+-bit integral types. */ + +#ifndef UINT_MAX +# define UINT_MAX UINT_MAX_32_BITS +#endif + +#if UINT_MAX == UINT_MAX_32_BITS + typedef unsigned int md5_uint32; +#else +# if USHRT_MAX == UINT_MAX_32_BITS + typedef unsigned short md5_uint32; +# else +# if ULONG_MAX == UINT_MAX_32_BITS + typedef unsigned long md5_uint32; +# else + /* The following line is intended to evoke an error. + Using #error is not portable enough. */ + "Cannot determine unsigned 32-bit data type." +# endif +# endif +#endif + +/* Structure to save state of computation between the single steps. */ +struct md5_ctx +{ + md5_uint32 A; + md5_uint32 B; + md5_uint32 C; + md5_uint32 D; +}; + +/* + * The following three functions are build up the low level used in + * the functions `md5_stream' and `md5_buffer'. + */ + +/* Initialize structure containing state of computation. + (RFC 1321, 3.3: Step 3) */ +static void md5_init_ctx(struct md5_ctx *ctx); + +/* Starting with the result of former calls of this function (or the + initialzation function update the context for the next LEN bytes + starting at BUFFER. + It is necessary that LEN is a multiple of 64!!! */ +static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx); + +/* Put result from CTX in first 16 bytes following RESBUF. The result is + always in little endian byte order, so that a byte-wise output yields + to the wanted ASCII representation of the message digest. */ +static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf); -#include "md5.h" #ifdef __BIG_ENDIAN__ # define SWAP(n) \ @@ -43,9 +113,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ -void -md5_init_ctx (ctx) - struct md5_ctx *ctx; +static void md5_init_ctx(struct md5_ctx *ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; @@ -55,10 +123,7 @@ md5_init_ctx (ctx) /* Put result from CTX in first 16 bytes following RESBUF. The result must be in little endian byte order. */ -void * -md5_read_ctx (ctx, resbuf) - const struct md5_ctx *ctx; - void *resbuf; +static void *md5_read_ctx(const struct md5_ctx *ctx, void *resbuf) { ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); @@ -71,10 +136,7 @@ md5_read_ctx (ctx, resbuf) /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ -int -md5_stream (stream, resblock) - FILE *stream; - void *resblock; +int md5_stream(FILE *stream, void *resblock) { /* Important: BLOCKSIZE must be a multiple of 64. */ #define BLOCKSIZE 4096 @@ -154,11 +216,7 @@ md5_stream (stream, resblock) result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -void * -md5_buffer (buffer, len, resblock) - const char *buffer; - size_t len; - void *resblock; +void *md5_buffer(const char *buffer, size_t len, void *resblock) { struct md5_ctx ctx; char restbuf[64 + 72]; @@ -207,11 +265,7 @@ md5_buffer (buffer, len, resblock) /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. */ -void -md5_process_block (buffer, len, ctx) - const void *buffer; - size_t len; - struct md5_ctx *ctx; +void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) { md5_uint32 correct_words[16]; const md5_uint32 *words = buffer; diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index a03d6ce280d..4c8a79e6372 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -53,7 +53,6 @@ set(SRC intern/indexer_dv.c intern/iris.c intern/jpeg.c - intern/md5.c intern/metadata.c intern/module.c intern/moviecache.c @@ -96,7 +95,6 @@ set(SRC intern/dds/Stream.h intern/dds/dds_api.h intern/imbuf.h - intern/md5.h intern/openexr/openexr_api.h intern/openexr/openexr_multi.h diff --git a/source/blender/imbuf/intern/md5.h b/source/blender/imbuf/intern/md5.h deleted file mode 100644 index 79c480d8152..00000000000 --- a/source/blender/imbuf/intern/md5.h +++ /dev/null @@ -1,119 +0,0 @@ -/** \file blender/imbuf/intern/md5.h - * \ingroup imbuf - */ -/* md5.h - Declaration of functions and data types used for MD5 sum - computing library functions. - Copyright (C) 1995 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2, or (at your option) -any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _MD5_H -#define _MD5_H - -#include - -#if defined HAVE_LIMITS_H || defined _LIBC -# include -#endif - -/* The following contortions are an attempt to use the C preprocessor - to determine an unsigned integral type that is 32 bits wide. An - alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but - doing that would require that the configure script compile and *run* - the resulting executable. Locally running cross-compiled executables - is usually not possible. */ - -#if defined __STDC__ && __STDC__ -# define UINT_MAX_32_BITS 4294967295U -#else -# define UINT_MAX_32_BITS 0xFFFFFFFF -#endif - -/* If UINT_MAX isn't defined, assume it's a 32-bit type. - This should be valid for all systems GNU cares about because - that doesn't include 16-bit systems, and only modern systems - (that certainly have ) have 64+-bit integral types. */ - -#ifndef UINT_MAX -# define UINT_MAX UINT_MAX_32_BITS -#endif - -#if UINT_MAX == UINT_MAX_32_BITS - typedef unsigned int md5_uint32; -#else -# if USHRT_MAX == UINT_MAX_32_BITS - typedef unsigned short md5_uint32; -# else -# if ULONG_MAX == UINT_MAX_32_BITS - typedef unsigned long md5_uint32; -# else - /* The following line is intended to evoke an error. - Using #error is not portable enough. */ - "Cannot determine unsigned 32-bit data type." -# endif -# endif -#endif - -#undef __P -#if defined (__STDC__) && __STDC__ -#define __P(x) x -#else -#define __P(x) () -#endif - -/* Structure to save state of computation between the single steps. */ -struct md5_ctx -{ - md5_uint32 A; - md5_uint32 B; - md5_uint32 C; - md5_uint32 D; -}; - -/* - * The following three functions are build up the low level used in - * the functions `md5_stream' and `md5_buffer'. - */ - -/* Initialize structure containing state of computation. - (RFC 1321, 3.3: Step 3) */ -void md5_init_ctx __P ((struct md5_ctx *ctx)); - -/* Starting with the result of former calls of this function (or the - initialzation function update the context for the next LEN bytes - starting at BUFFER. - It is necessary that LEN is a multiple of 64!!! */ -void md5_process_block __P ((const void *buffer, size_t len, - struct md5_ctx *ctx)); - -/* Put result from CTX in first 16 bytes following RESBUF. The result is - always in little endian byte order, so that a byte-wise output yields - to the wanted ASCII representation of the message digest. */ -void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); - - -/* Compute MD5 message digest for bytes read from STREAM. The - resulting message digest number will be written into the 16 bytes - beginning at RESBLOCK. */ -int md5_stream __P ((FILE *stream, void *resblock)); - -/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The - result is always in little endian byte order, so that a byte-wise - output yields to the wanted ASCII representation of the message - digest. */ -void *md5_buffer __P ((const char *buffer, size_t len, void *resblock)); - -#endif - diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 19eb917469d..808bcbed751 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -32,17 +32,18 @@ #include -#include "BKE_utildefines.h" -#include "BLI_blenlib.h" #include "MEM_guardedalloc.h" +#include "BLI_blenlib.h" +#include "BLI_md5.h" + +#include "BKE_utildefines.h" + #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" #include "IMB_thumbs.h" #include "IMB_metadata.h" -#include "md5.h" - #include #include #include From 99e6e6cc08a9e246cf00724574e99a78f3293f5c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 13:49:22 +0000 Subject: [PATCH 11/12] Fix #29670: color picker draw issues with RGB values out of soft range. --- source/blender/editors/interface/interface.c | 2 +- source/blender/editors/interface/interface_handlers.c | 2 +- source/blender/editors/interface/interface_widgets.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 1bad61be324..63e41082449 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1901,7 +1901,7 @@ void ui_set_but_soft_range(uiBut *but, double value) if(softmin < (double)but->hardmin) softmin= (double)but->hardmin; } - else if(value_max-1e-10 > softmax) { + if(value_max-1e-10 > softmax) { if(value_max < 0.0) softmax= -soft_range_round_down(-value_max, -softmax); else diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 6ebfddff5c1..900cbbd5cbf 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5247,7 +5247,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s highlight when not in a popup menu, we remove because data used in button below popup might have been removed by action of popup. Needs a more reliable solution... */ - if(state != BUTTON_STATE_HIGHLIGHT || but->block->handle) + if(state != BUTTON_STATE_HIGHLIGHT || (but->block->flag & UI_BLOCK_LOOP)) ui_check_but(but); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 0da4d3895e0..d8a34262e81 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1795,7 +1795,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) { /* gouraud triangle fan */ float radstep, ang= 0.0f; - float centx, centy, radius; + float centx, centy, radius, cursor_radius; float rgb[3], hsvo[3], hsv[3], col[3], colcent[3]; int a, tot= 32; int color_profile = but->block->color_profile; @@ -1864,12 +1864,12 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, rcti *rect) ang= 2.0f*(float)M_PI*hsvo[0] + 0.5f*(float)M_PI; if(but->flag & UI_BUT_COLOR_CUBIC) - radius= (1.0f - powf(1.0f - hsvo[1], 3.0f)) *radius; + cursor_radius = (1.0f - powf(1.0f - hsvo[1], 3.0f)); else - radius= hsvo[1] * radius; + cursor_radius = hsvo[1]; + radius= CLAMPIS(cursor_radius, 0.0f, 1.0f) * radius; ui_hsv_cursor(centx + cosf(-ang)*radius, centy + sinf(-ang)*radius); - } /* ************ custom buttons, old stuff ************** */ From 2777ba097f5404a736333239bb6d61ab4b561e13 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Dec 2011 14:35:48 +0000 Subject: [PATCH 12/12] Fix linux linking issue with md5 commit. --- source/creator/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 6851b783463..48c7dca0b4d 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -775,11 +775,11 @@ endif() bf_nodes bf_gpu bf_blenloader + bf_imbuf bf_blenlib bf_intern_ghost bf_intern_string bf_blenpluginapi - bf_imbuf bf_avi bf_imbuf_cineon bf_imbuf_openexr