Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/osl.cpp
| Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | void OSLShaderManager::device_update_specific(Device *device, | ||||
| VLOG(1) << "Total " << scene->shaders.size() << " shaders."; | VLOG(1) << "Total " << scene->shaders.size() << " shaders."; | ||||
| device_free(device, dscene, scene); | device_free(device, dscene, scene); | ||||
| /* set texture system */ | /* set texture system */ | ||||
| scene->image_manager->set_osl_texture_system((void *)ts); | scene->image_manager->set_osl_texture_system((void *)ts); | ||||
| /* create shaders */ | /* create shaders */ | ||||
| OSLGlobals *og = (OSLGlobals *)device->osl_memory(); | OSLGlobals *og = (OSLGlobals *)device->get_cpu_osl_memory(); | ||||
| Shader *background_shader = scene->background->get_shader(scene); | Shader *background_shader = scene->background->get_shader(scene); | ||||
| foreach (Shader *shader, scene->shaders) { | foreach (Shader *shader, scene->shaders) { | ||||
| assert(shader->graph); | assert(shader->graph); | ||||
| if (progress.get_cancel()) | if (progress.get_cancel()) | ||||
| return; | return; | ||||
| ▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | device_update_common(device, dscene, scene, progress); | ||||
| */ | */ | ||||
| thread_scoped_lock lock(ss_shared_mutex); | thread_scoped_lock lock(ss_shared_mutex); | ||||
| ss->optimize_all_groups(); | ss->optimize_all_groups(); | ||||
| } | } | ||||
| } | } | ||||
| void OSLShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *scene) | void OSLShaderManager::device_free(Device *device, DeviceScene *dscene, Scene *scene) | ||||
| { | { | ||||
| OSLGlobals *og = (OSLGlobals *)device->osl_memory(); | OSLGlobals *og = (OSLGlobals *)device->get_cpu_osl_memory(); | ||||
| device_free_common(device, dscene, scene); | device_free_common(device, dscene, scene); | ||||
| /* clear shader engine */ | /* clear shader engine */ | ||||
| og->use = false; | og->use = false; | ||||
| og->ss = NULL; | og->ss = NULL; | ||||
| og->ts = NULL; | og->ts = NULL; | ||||
| ▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | # endif | ||||
| ss_shared->attribute("commonspace", "world"); | ss_shared->attribute("commonspace", "world"); | ||||
| ss_shared->attribute("searchpath:shader", shader_path); | ss_shared->attribute("searchpath:shader", shader_path); | ||||
| ss_shared->attribute("greedyjit", 1); | ss_shared->attribute("greedyjit", 1); | ||||
| VLOG(1) << "Using shader search path: " << shader_path; | VLOG(1) << "Using shader search path: " << shader_path; | ||||
| /* our own ray types */ | /* our own ray types */ | ||||
| static const char *raytypes[] = { | static const char *raytypes[] = { | ||||
| "camera", /* PATH_RAY_CAMERA */ | "camera", /* PATH_RAY_CAMERA */ | ||||
| "reflection", /* PATH_RAY_REFLECT */ | "reflection", /* PATH_RAY_REFLECT */ | ||||
| "refraction", /* PATH_RAY_TRANSMIT */ | "refraction", /* PATH_RAY_TRANSMIT */ | ||||
| "diffuse", /* PATH_RAY_DIFFUSE */ | "diffuse", /* PATH_RAY_DIFFUSE */ | ||||
| "glossy", /* PATH_RAY_GLOSSY */ | "glossy", /* PATH_RAY_GLOSSY */ | ||||
| "singular", /* PATH_RAY_SINGULAR */ | "singular", /* PATH_RAY_SINGULAR */ | ||||
| "transparent", /* PATH_RAY_TRANSPARENT */ | "transparent", /* PATH_RAY_TRANSPARENT */ | ||||
| "volume_scatter", /* PATH_RAY_VOLUME_SCATTER */ | |||||
| "shadow", /* PATH_RAY_SHADOW_OPAQUE_NON_CATCHER */ | "shadow", /* PATH_RAY_SHADOW_OPAQUE */ | ||||
| "shadow", /* PATH_RAY_SHADOW_OPAQUE_CATCHER */ | "shadow", /* PATH_RAY_SHADOW_TRANSPARENT */ | ||||
| "shadow", /* PATH_RAY_SHADOW_TRANSPARENT_NON_CATCHER */ | |||||
| "shadow", /* PATH_RAY_SHADOW_TRANSPARENT_CATCHER */ | "__unused__", /* PATH_RAY_NODE_UNALIGNED */ | ||||
| "__unused__", /* PATH_RAY_MIS_SKIP */ | |||||
| "__unused__", "volume_scatter", /* PATH_RAY_VOLUME_SCATTER */ | |||||
| "__unused__", | "diffuse_ancestor", /* PATH_RAY_DIFFUSE_ANCESTOR */ | ||||
| "__unused__", "diffuse_ancestor", /* PATH_RAY_DIFFUSE_ANCESTOR */ | "__unused__", /* PATH_RAY_SINGLE_PASS_DONE */ | ||||
| "__unused__", "__unused__", "__unused__", "__unused__", | "__unused__", /* PATH_RAY_TRANSPARENT_BACKGROUND */ | ||||
| "__unused__", "__unused__", "__unused__", | "__unused__", /* PATH_RAY_TERMINATE_IMMEDIATE */ | ||||
| "__unused__", /* PATH_RAY_TERMINATE_AFTER_TRANSPARENT */ | |||||
| "__unused__", /* PATH_RAY_EMISSION */ | |||||
| "__unused__", /* PATH_RAY_SUBSURFACE */ | |||||
| "__unused__", /* PATH_RAY_DENOISING_FEATURES */ | |||||
| "__unused__", /* PATH_RAY_REFLECT_PASS */ | |||||
| "__unused__", /* PATH_RAY_TRANSMISSION_PASS */ | |||||
| "__unused__", /* PATH_RAY_VOLUME_PASS */ | |||||
| "__unused__", /* PATH_RAY_SHADOW_FOR_LIGHT */ | |||||
| "__unused__", /* PATH_RAY_SHADOW_CATCHER_HIT */ | |||||
| "__unused__", /* PATH_RAY_SHADOW_CATCHER_PASS */ | |||||
| }; | }; | ||||
| const int nraytypes = sizeof(raytypes) / sizeof(raytypes[0]); | const int nraytypes = sizeof(raytypes) / sizeof(raytypes[0]); | ||||
| ss_shared->attribute("raytypes", TypeDesc(TypeDesc::STRING, nraytypes), raytypes); | ss_shared->attribute("raytypes", TypeDesc(TypeDesc::STRING, nraytypes), raytypes); | ||||
| OSLShader::register_closures((OSLShadingSystem *)ss_shared); | OSLShader::register_closures((OSLShadingSystem *)ss_shared); | ||||
| loaded_shaders.clear(); | loaded_shaders.clear(); | ||||
| ▲ Show 20 Lines • Show All 466 Lines • ▼ Show 20 Lines | if (info) { | ||||
| if (info->has_surface_emission) | if (info->has_surface_emission) | ||||
| current_shader->has_surface_emission = true; | current_shader->has_surface_emission = true; | ||||
| if (info->has_surface_transparent) | if (info->has_surface_transparent) | ||||
| current_shader->has_surface_transparent = true; | current_shader->has_surface_transparent = true; | ||||
| if (info->has_surface_bssrdf) { | if (info->has_surface_bssrdf) { | ||||
| current_shader->has_surface_bssrdf = true; | current_shader->has_surface_bssrdf = true; | ||||
| current_shader->has_bssrdf_bump = true; /* can't detect yet */ | current_shader->has_bssrdf_bump = true; /* can't detect yet */ | ||||
| } | } | ||||
| current_shader->has_bump = true; /* can't detect yet */ | current_shader->has_bump = true; /* can't detect yet */ | ||||
| current_shader->has_surface_raytrace = true; /* can't detect yet */ | |||||
| } | } | ||||
| if (node->has_spatial_varying()) { | if (node->has_spatial_varying()) { | ||||
| current_shader->has_surface_spatial_varying = true; | current_shader->has_surface_spatial_varying = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (current_type == SHADER_TYPE_VOLUME) { | else if (current_type == SHADER_TYPE_VOLUME) { | ||||
| if (node->has_spatial_varying()) | if (node->has_spatial_varying()) | ||||
| ▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Lines | foreach (ShaderNode *node, nodes) { | ||||
| node->compile(*this); | node->compile(*this); | ||||
| done.insert(node); | done.insert(node); | ||||
| if (current_type == SHADER_TYPE_SURFACE) { | if (current_type == SHADER_TYPE_SURFACE) { | ||||
| if (node->has_surface_emission()) | if (node->has_surface_emission()) | ||||
| current_shader->has_surface_emission = true; | current_shader->has_surface_emission = true; | ||||
| if (node->has_surface_transparent()) | if (node->has_surface_transparent()) | ||||
| current_shader->has_surface_transparent = true; | current_shader->has_surface_transparent = true; | ||||
| if (node->get_feature() & KERNEL_FEATURE_NODE_RAYTRACE) | |||||
| current_shader->has_surface_raytrace = true; | |||||
| if (node->has_spatial_varying()) | if (node->has_spatial_varying()) | ||||
| current_shader->has_surface_spatial_varying = true; | current_shader->has_surface_spatial_varying = true; | ||||
| if (node->has_surface_bssrdf()) { | if (node->has_surface_bssrdf()) { | ||||
| current_shader->has_surface_bssrdf = true; | current_shader->has_surface_bssrdf = true; | ||||
| if (node->has_bssrdf_bump()) | if (node->has_bssrdf_bump()) | ||||
| current_shader->has_bssrdf_bump = true; | current_shader->has_bssrdf_bump = true; | ||||
| } | } | ||||
| if (node->has_bump()) { | if (node->has_bump()) { | ||||
| ▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines | |||||