Fix Cycles link error with debug + asan after RTTI changes

This commit is contained in:
Brecht Van Lommel 2020-03-11 16:51:42 +01:00
parent 9ef7759bf0
commit 9910803574
4 changed files with 21 additions and 12 deletions

@ -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());

@ -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

@ -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;

@ -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();