Fix #29528: crash adding subsurf modifier in a particular scene with viewport render.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 8 Dec 2011 21:55:35 +0000 (21:55 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 8 Dec 2011 21:55:35 +0000 (21:55 +0000)
intern/cycles/blender/blender_sync.cpp
intern/cycles/render/mesh.cpp
intern/cycles/render/sobol.cpp
intern/cycles/render/sobol.h

index b89b7ebb9be8ffa50344acbe799631d47399a270..b66004bee58d43ac67a5e7fbf9990cc7a19b574d 100644 (file)
@@ -269,7 +269,7 @@ SessionParams BlenderSync::get_session_params(BL::Scene b_scene, bool background
                if(!experimental || RNA_enum_get(&cscene, "gpu_type") == 0)
                        dtype = DEVICE_CUDA;
                else
-                       dtype = DEVICE_CUDA;
+                       dtype = DEVICE_OPENCL;
 
                if(device_type_available(types, dtype))
                        params.device_type = dtype;
index fc2dd49205a712e3c19f9440d3af479f8234ddc8..5d65ce69a00cf32ccce64702eb4bf3279b542673 100644 (file)
@@ -270,15 +270,19 @@ void Mesh::compute_bvh(SceneParams *params, Progress& progress)
 void Mesh::tag_update(Scene *scene, bool rebuild)
 {
        need_update = true;
-       if(rebuild)
+
+       if(rebuild) {
                need_update_rebuild = true;
+               scene->light_manager->need_update = true;
+       }
+       else {
+               foreach(uint sindex, used_shaders)
+                       if(scene->shaders[sindex]->has_surface_emission)
+                               scene->light_manager->need_update = true;
+       }
 
        scene->mesh_manager->need_update = true;
        scene->object_manager->need_update = true;
-
-       foreach(uint sindex, used_shaders)
-               if(scene->shaders[sindex]->has_surface_emission)
-                       scene->light_manager->need_update = true;
 }
 
 /* Mesh Manager */
@@ -685,9 +689,9 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen
                        if(!mesh->transform_applied) {
                                string msg = "Updating Mesh BVH ";
                                if(mesh->name == "")
-                                       msg += string_printf("%lu/%lu", (unsigned long)(i+1), (unsigned long)num_instance_bvh);
+                                       msg += string_printf("%u/%u", (uint)(i+1), (uint)num_instance_bvh);
                                else
-                                       msg += string_printf("%s %lu/%lu", mesh->name.c_str(), (unsigned long)(i+1), (unsigned long)num_instance_bvh);
+                                       msg += string_printf("%s %u/%u", mesh->name.c_str(), (uint)(i+1), (uint)num_instance_bvh);
                                progress.set_status(msg, "Building BVH");
 
                                mesh->compute_bvh(&scene->params, progress);
index be8939174b42d99f16ea5bffd38971effbfebed8..e3c2e802067359d41cd83525b2231d68c6fd37fc 100644 (file)
@@ -47,6 +47,7 @@
  */
 
 #include "util_debug.h"
+#include "util_types.h"
 
 #include "sobol.h"
 
@@ -55,8 +56,8 @@ CCL_NAMESPACE_BEGIN
 #define SOBOL_MAX_NUMBER 32
 
 typedef struct SobolDirectionNumbers {
-       unsigned int d, s, a;
-       unsigned int m[SOBOL_MAX_NUMBER];
+       uint d, s, a;
+       uint m[SOBOL_MAX_NUMBER];
 } SobolDirectionNumbers;
 
 static SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS-1] = {
@@ -21262,38 +21263,38 @@ static SobolDirectionNumbers SOBOL_NUMBERS[SOBOL_MAX_DIMENSIONS-1] = {
 {21201, 18, 131059, {1, 1, 7, 11, 15, 7, 37, 239, 337, 245, 1557, 3681, 7357, 9639, 27367, 26869, 114603, 86317}}
 };
 
-void sobol_generate_direction_vectors(unsigned int vectors[][SOBOL_BITS], int dimensions)
+void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions)
 {
        assert(dimensions <= SOBOL_MAX_DIMENSIONS);
 
-       const unsigned int L = SOBOL_BITS;
+       const uint L = SOBOL_BITS;
 
        /* first dimension is exception */
-       unsigned int *v = vectors[0];
+       uint *v = vectors[0];
 
-       for(unsigned int i = 0; i < L; i++)
+       for(uint i = 0; i < L; i++)
                v[i] = 1 << (31-i); // all m's = 1
 
        for(int dim = 1; dim < dimensions; dim++) {
                SobolDirectionNumbers *numbers = &SOBOL_NUMBERS[dim-1];
-               unsigned int s = numbers->s;
-               unsigned int a = numbers->a;
-               unsigned int *m = numbers->m;
+               uint s = numbers->s;
+               uint a = numbers->a;
+               uint *m = numbers->m;
 
                v = vectors[dim];
 
                if(L <= s) {
-                       for(unsigned int i = 0; i < L; i++)
+                       for(uint i = 0; i < L; i++)
                                v[i] = m[i] << (31-i); 
                }
                else {
-                       for(unsigned int i = 0; i < s; i++)
+                       for(uint i = 0; i < s; i++)
                                v[i] = m[i] << (31-i); 
 
-                       for(unsigned int i = s; i < L; i++) {
+                       for(uint i = s; i < L; i++) {
                                v[i] = v[i-s] ^ (v[i-s] >> s); 
 
-                               for(unsigned int k = 1; k < s; k++) 
+                               for(uint k = 1; k < s; k++) 
                                        v[i] ^= (((a >> (s-1-k)) & 1) * v[i-k]); 
                        }
                }
index bfc2f5512aabeb6e3642508d709f36b5b1c81012..0f52a5fee68c0baa5229b091588c9762682d5feb 100644 (file)
 #ifndef __SOBOL_H__
 #define __SOBOL_H__
 
+#include "util_types.h"
+
 CCL_NAMESPACE_BEGIN
 
 #define SOBOL_BITS 32
 #define SOBOL_MAX_DIMENSIONS 21201
 
-void sobol_generate_direction_vectors(unsigned int vectors[][SOBOL_BITS], int dimensions);
+void sobol_generate_direction_vectors(uint vectors[][SOBOL_BITS], int dimensions);
 
 CCL_NAMESPACE_END