diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-12-04 11:48:09 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-12-04 11:48:09 +0400 |
commit | a9d889cba412eaa4e02806e50b631ae621521e23 (patch) | |
tree | 4ce11445d1b30caa567f6c8fb6dd70fdffb2fc85 /intern/cycles | |
parent | c0078a987978348f200322764e06afbcc378b81f (diff) |
Fix #33405: preview render getting stuck in a particular .blend file, ObjectKey
operator< had wrong brackets, changed it now to be more clear.
Fix #33404: crash GPU rendering with OSL option still enabled. There was a check
to disable OSL in this case, but it shouldn't have modified scene->params because
this is used for comparison in scene->modified().
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 24 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_shader.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/osl.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/scene.cpp | 11 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/render/shader.h | 4 |
8 files changed, 35 insertions, 16 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index da06f1d0a38..c9380d8d58b 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -445,7 +445,7 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen } case BL::ShaderNode::type_SCRIPT: { #ifdef WITH_OSL - if(scene->params.shadingsystem != SceneParams::OSL) + if(!scene->shader_manager->use_osl()) break; /* create script node */ diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 4feb8b556d5..0a9f2dd06aa 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -367,12 +367,22 @@ struct ObjectKey { bool operator<(const ObjectKey& k) const { - return (parent < k.parent) || - (parent == k.parent && (memcmp(id, k.id, sizeof(id)) < 0)) || - (memcmp(id, k.id, sizeof(id)) == 0 && ob < k.ob); + if(ob < k.ob) { + return true; + } + else if(ob == k.ob) { + if(parent < k.parent) + return true; + else if(parent == k.parent) + return memcmp(id, k.id, sizeof(id)) < 0; + } + + return false; } }; +/* Particle System Key */ + struct ParticleSystemKey { void *ob; int id[OBJECT_PERSISTENT_ID_SIZE]; @@ -389,8 +399,12 @@ struct ParticleSystemKey { bool operator<(const ParticleSystemKey& k) const { /* first id is particle index, we don't compare that */ - return (ob < k.ob) || - (ob == k.ob && (memcmp(id+1, k.id+1, sizeof(int)*(OBJECT_PERSISTENT_ID_SIZE-1)) < 0)); + if(ob < k.ob) + return true; + else if(ob == k.ob) + return memcmp(id+1, k.id+1, sizeof(int)*(OBJECT_PERSISTENT_ID_SIZE-1)) < 0; + + return false; } }; diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 43ad4b1265a..98a7ec59d7b 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -698,7 +698,7 @@ __device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, #ifdef __SVM__ svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, randb, path_flag); #else - bsdf_diffuse_setup(sd, &sd->closure); + bsdf_diffuse_setup(&sd->closure); sd->closure.weight = make_float3(0.8f, 0.8f, 0.8f); #endif } diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 1958cfc10f7..bc782a78c60 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -547,7 +547,7 @@ void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, } /* create attribute lookup maps */ - if(scene->params.shadingsystem == SceneParams::OSL) + if(scene->shader_manager->use_osl()) update_osl_attributes(device, scene, mesh_attributes); else update_svm_attributes(device, dscene, scene, mesh_attributes); diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h index 08b5f8b89fb..9b58745bd46 100644 --- a/intern/cycles/render/osl.h +++ b/intern/cycles/render/osl.h @@ -52,6 +52,8 @@ public: OSLShaderManager(); ~OSLShaderManager(); + bool use_osl() { return true; } + void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); void device_free(Device *device, DeviceScene *dscene); diff --git a/intern/cycles/render/scene.cpp b/intern/cycles/render/scene.cpp index 7834aa701ea..8085cfdd3e6 100644 --- a/intern/cycles/render/scene.cpp +++ b/intern/cycles/render/scene.cpp @@ -44,10 +44,6 @@ Scene::Scene(const SceneParams& params_, const DeviceInfo& device_info_) device = NULL; memset(&dscene.data, 0, sizeof(dscene.data)); - /* OSL only works on the CPU */ - if(device_info_.type != DEVICE_CPU) - params.shadingsystem = SceneParams::SVM; - camera = new Camera(); filter = new Filter(); film = new Film(); @@ -57,9 +53,14 @@ Scene::Scene(const SceneParams& params_, const DeviceInfo& device_info_) object_manager = new ObjectManager(); integrator = new Integrator(); image_manager = new ImageManager(); - shader_manager = ShaderManager::create(this); particle_system_manager = new ParticleSystemManager(); + /* OSL only works on the CPU */ + if(device_info_.type == DEVICE_CPU) + shader_manager = ShaderManager::create(this, params.shadingsystem); + else + shader_manager = ShaderManager::create(this, SceneParams::SVM); + if (device_info_.type == DEVICE_CPU) image_manager->set_extended_image_limits(); } diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 17f7fbd43d6..b9b49bf2989 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -121,12 +121,12 @@ ShaderManager::~ShaderManager() { } -ShaderManager *ShaderManager::create(Scene *scene) +ShaderManager *ShaderManager::create(Scene *scene, int shadingsystem) { ShaderManager *manager; #ifdef WITH_OSL - if(scene->params.shadingsystem == SceneParams::OSL) + if(shadingsystem == SceneParams::OSL) manager = new OSLShaderManager(); else #endif diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 373b3356f51..d4421002ceb 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -107,9 +107,11 @@ class ShaderManager { public: bool need_update; - static ShaderManager *create(Scene *scene); + static ShaderManager *create(Scene *scene, int shadingsystem); virtual ~ShaderManager(); + virtual bool use_osl() { return false; } + /* device update */ virtual void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) = 0; virtual void device_free(Device *device, DeviceScene *dscene) = 0; |