diff options
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/osl.cpp | 18 | ||||
-rw-r--r-- | intern/cycles/render/osl.h | 7 |
4 files changed, 21 insertions, 12 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index 2540786a014..11db5b1a07d 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -292,7 +292,7 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, xml_node filepath = path_join(state.base, filepath); } - snode = ((OSLShaderManager *)manager)->osl_node(filepath); + snode = OSLShaderManager::osl_node(manager, filepath); if (!snode) { fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str()); diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 732c4b0da96..25e1d60f84d 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -619,16 +619,16 @@ static ShaderNode *add_node(Scene *scene, /* create script node */ BL::ShaderNodeScript b_script_node(b_node); - OSLShaderManager *manager = (OSLShaderManager *)scene->shader_manager; + ShaderManager *manager = scene->shader_manager; string bytecode_hash = b_script_node.bytecode_hash(); if (!bytecode_hash.empty()) { - node = manager->osl_node("", bytecode_hash, b_script_node.bytecode()); + node = OSLShaderManager::osl_node(manager, "", bytecode_hash, b_script_node.bytecode()); } else { string absolute_filepath = blender_absolute_path( b_data, b_ntree, b_script_node.filepath()); - node = manager->osl_node(absolute_filepath, ""); + node = OSLShaderManager::osl_node(manager, absolute_filepath, ""); } } #else diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index b3916a67f0c..d5d649e2207 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -440,27 +440,35 @@ const char *OSLShaderManager::shader_load_bytecode(const string &hash, const str return loaded_shaders.find(hash)->first.c_str(); } -OSLNode *OSLShaderManager::osl_node(const std::string &filepath, +/* This is a static function to avoid RTTI link errors with only this + * file being compiled without RTTI to match OSL and LLVM libraries. */ +OSLNode *OSLShaderManager::osl_node(ShaderManager *manager, + const std::string &filepath, const std::string &bytecode_hash, const std::string &bytecode) { + if (!manager->use_osl()) { + return NULL; + } + /* create query */ + OSLShaderManager *osl_manager = static_cast<OSLShaderManager *>(manager); const char *hash; if (!filepath.empty()) { - hash = shader_load_filepath(filepath); + hash = osl_manager->shader_load_filepath(filepath); } else { - hash = shader_test_loaded(bytecode_hash); + hash = osl_manager->shader_test_loaded(bytecode_hash); if (!hash) - hash = shader_load_bytecode(bytecode_hash, bytecode); + hash = osl_manager->shader_load_bytecode(bytecode_hash, bytecode); } if (!hash) { return NULL; } - OSLShaderInfo *info = shader_loaded_info(hash); + OSLShaderInfo *info = osl_manager->shader_loaded_info(hash); /* count number of inputs */ size_t num_inputs = 0; diff --git a/intern/cycles/render/osl.h b/intern/cycles/render/osl.h index 62cbfebf7eb..4dd9f6630f2 100644 --- a/intern/cycles/render/osl.h +++ b/intern/cycles/render/osl.h @@ -93,9 +93,10 @@ class OSLShaderManager : public ShaderManager { OSLShaderInfo *shader_loaded_info(const string &hash); /* create OSL node using OSLQuery */ - OSLNode *osl_node(const std::string &filepath, - const std::string &bytecode_hash = "", - const std::string &bytecode = ""); + static OSLNode *osl_node(ShaderManager *manager, + const std::string &filepath, + const std::string &bytecode_hash = "", + const std::string &bytecode = ""); protected: void texture_system_init(); |