39std::shared_ptr<OSL::TextureSystem> ts_shared;
42map<DeviceType, std::shared_ptr<OSL::ShadingSystem>> ss_shared;
44OSL::ErrorHandler errhandler;
46std::atomic<int> OSLCompiler::texture_shared_unique_id = 0;
54 shading_system_free();
55 texture_system_free();
60# ifdef OSL_HAS_BLENDER_CLEANUP_FIX
66 OSL::pvt::LLVM_Util::Cleanup();
72 shading_system_free();
76OSL::TextureSystem *OSLManager::get_texture_system()
79 texture_system_init();
84OSL::ShadingSystem *OSLManager::get_shading_system(
Device *sub_device)
86 return ss_map[sub_device->
info.
type].get();
89void OSLManager::foreach_shading_system(
const std::function<
void(OSL::ShadingSystem *)> &callback)
91 for (
const auto &[device_type, ss] : ss_map) {
96void OSLManager::foreach_render_services(
const std::function<
void(
OSLRenderServices *)> &callback)
98 for (
const auto &[device_type, ss] : ss_map) {
99 callback(
static_cast<OSLRenderServices *
>(ss->renderer()));
103void OSLManager::foreach_osl_device(
Device *device,
104 const std::function<
void(
Device *, OSLGlobals *)> &callback)
109 callback(sub_device, og);
127 shading_system_init();
137 foreach_render_services([](OSLRenderServices *services) {
144 scene->
image_manager->set_osl_texture_system((
void *)get_texture_system());
152 const bool reload_kernels)
159 foreach_osl_device(device, [
this, scene](Device *sub_device, OSLGlobals *og) {
160 OSL::ShadingSystem *ss = get_shading_system(sub_device);
162 OSL::ShaderGroupRef group = ss->ShaderGroupBegin(
"camera_group");
163 for (
const auto ¶m : scene->
camera->script_params) {
164 const ustring &name = param.first;
165 const vector<uint8_t> &
data = param.second.first;
166 const TypeDesc &type = param.second.second;
167 if (type.basetype == TypeDesc::STRING) {
168 const void *
string =
data.data();
169 ss->Parameter(*group, name, type, (
const void *)&
string);
172 ss->Parameter(*group, name, type, (
const void *)
data.data());
175 ss->Shader(*group,
"shader", scene->
camera->script_name,
"camera");
176 ss->ShaderGroupEnd(*group);
179 og->ts = get_texture_system();
180 og->services =
static_cast<OSLRenderServices *
>(ss->renderer());
182 og->camera_state = group;
183 og->use_camera =
true;
190 OSLShaderInfo *info = shader_loaded_info(scene->
camera->script_name);
191 const string deriv_args[] = {
"dPdx",
"dPdy",
"dDdx",
"dDdy"};
192 bool explicit_derivs =
false;
193 for (
const auto &arg : deriv_args) {
194 if (info->query.getparam(arg) !=
nullptr) {
195 explicit_derivs =
true;
199 auto add_param = [&](
const char *name, OIIO::TypeDesc type,
bool derivs,
int offset) {
200 ss->add_symlocs(group.get(),
204 OSL::SymArena::Outputs,
205 offset *
sizeof(
float)));
208 if (explicit_derivs) {
209 add_param(
"dPdx", OIIO::TypeVector,
false, 3);
210 add_param(
"dPdy", OIIO::TypeVector,
false, 6);
211 add_param(
"dDdx", OIIO::TypeVector,
false, 12);
212 add_param(
"dDdy", OIIO::TypeVector,
false, 15);
214 add_param(
"position", OIIO::TypePoint, !explicit_derivs, 0);
215 add_param(
"direction", OIIO::TypeVector, !explicit_derivs, 9);
216 add_param(
"throughput", OIIO::TypeColor,
false, 18);
220 foreach_osl_device(device, [](Device *, OSLGlobals *og) {
221 og->camera_state.reset();
222 og->use_camera =
false;
227 scoped_callback_timer
timer([scene](
double time) {
229 scene->
update_stats->osl.times.add_entry({
"jit", time});
253 foreach_shading_system([](OSL::ShadingSystem *ss) { ss->optimize_all_groups(); });
260 foreach_osl_device(device, [
this, &
progress](Device *sub_device, OSLGlobals *og) {
261 if (og->use_shading || og->use_camera) {
262 OSL::ShadingSystem *ss = get_shading_system(sub_device);
265 og->ts = get_texture_system();
266 og->services =
static_cast<OSLRenderServices *
>(ss->renderer());
276 need_update_ =
false;
282 foreach_osl_device(device, [](Device *, OSLGlobals *og) {
283 og->use_shading =
false;
284 og->use_camera =
false;
287 og->camera_state.reset();
292 foreach_render_services([scene](OSLRenderServices *services) {
293 for (
auto it = services->
textures.begin(); it != services->
textures.end();) {
294 if (it->second.handle.get_manager() == scene->
image_manager.get()) {
296 services->
textures.erase(it->first,
false);
308void OSLManager::texture_system_init()
314# if OIIO_VERSION_MAJOR >= 3
315 ts_shared = OSL::TextureSystem::create(
false);
317 ts_shared = std::shared_ptr<OSL::TextureSystem>(
318 OSL::TextureSystem::create(
false),
319 [](OSL::TextureSystem *ts) { OSL::TextureSystem::destroy(ts); });
322 ts_shared->attribute(
"automip", 1);
323 ts_shared->attribute(
"autotile", 64);
324 ts_shared->attribute(
"gray_to_rgb", 1);
327 ts_shared->attribute(
"max_memory_MB", 16384);
334void OSLManager::texture_system_free()
341 if (ts_shared.use_count() == 1) {
346void OSLManager::shading_system_init()
349 if (!ss_map.empty()) {
356 foreach_osl_device(device_, [
this](Device *sub_device, OSLGlobals *) {
359 if (!ss_shared[device_type]) {
371 const string shader_path = string_to_ansi(
path_get(
"shader"));
373 const string shader_path =
path_get(
"shader");
376 auto ss = std::shared_ptr<OSL::ShadingSystem>(
377 new OSL::ShadingSystem(services, get_texture_system(), &errhandler),
378 [](OSL::ShadingSystem *ss) {
382 ss->attribute(
"lockgeom", 1);
383 ss->attribute(
"commonspace",
"world");
384 ss->attribute(
"searchpath:shader", shader_path);
385 ss->attribute(
"greedyjit", 1);
387 const char *groupdata_alloc_str = getenv(
"CYCLES_OSL_GROUPDATA_ALLOC");
388 if (groupdata_alloc_str) {
389 ss->attribute(
"max_optix_groupdata_alloc", atoi(groupdata_alloc_str));
392 ss->attribute(
"max_optix_groupdata_alloc", 2048);
395 VLOG_INFO <<
"Using shader search path: " << shader_path;
398 static const char *raytypes[] = {
438 const int nraytypes =
sizeof(raytypes) /
sizeof(raytypes[0]);
439 ss->attribute(
"raytypes",
TypeDesc(TypeDesc::STRING, nraytypes), (
const void *)raytypes);
442 ss_shared[device_type] = std::move(ss);
444 ss_map[device_type] = ss_shared[device_type];
448void OSLManager::shading_system_free()
455 for (
auto &[device_type, ss] : ss_shared) {
456 if (ss.use_count() == 1) {
461 loaded_shaders.clear();
464bool OSLManager::osl_compile(
const string &inputfile,
const string &outputfile)
468 const string shader_path =
path_get(
"shader");
475 const string include_path_arg = string(
"-I") + shader_path;
476 options.push_back(include_path_arg);
478 stdosl_path =
path_join(shader_path,
"stdcycles.h");
486 OSL::OSLCompiler compiler = OSL::OSLCompiler(&OSL::ErrorHandler::default_handler());
487 const bool ok = compiler.compile(string_view(inputfile),
options, string_view(stdosl_path));
492bool OSLManager::osl_query(OSL::OSLQuery &query,
const string &filepath)
495 return query.open(filepath, searchpath);
498static string shader_filepath_hash(
const string &filepath,
const uint64_t modified_time)
502 md5.
append((
const uint8_t *)filepath.c_str(), filepath.size());
503 md5.
append((
const uint8_t *)&modified_time,
sizeof(modified_time));
508const char *OSLManager::shader_test_loaded(
const string &
hash)
510 const map<string, OSLShaderInfo>::iterator it = loaded_shaders.find(
hash);
511 return (it == loaded_shaders.end()) ?
nullptr : it->first.c_str();
514OSLShaderInfo *OSLManager::shader_loaded_info(
const string &
hash)
516 const map<string, OSLShaderInfo>::iterator it = loaded_shaders.find(
hash);
517 return (it == loaded_shaders.end()) ?
nullptr : &it->second;
520const char *OSLManager::shader_load_filepath(
string filepath)
522 const size_t len = filepath.size();
523 const string extension = filepath.substr(
len - 4);
526 if (extension ==
".osl") {
528 const string osopath = filepath.substr(0,
len - 4) +
".oso";
532 if (oso_modified_time != 0) {
533 const char *
hash = shader_test_loaded(shader_filepath_hash(osopath, oso_modified_time));
541 if (oso_modified_time == 0 || (oso_modified_time < modified_time)) {
542 OSLManager::osl_compile(filepath, osopath);
546 modified_time = oso_modified_time;
552 if (extension ==
".oso") {
565 const char *
hash = shader_test_loaded(shader_filepath_hash(filepath, modified_time));
573 const string bytecode_hash = shader_filepath_hash(filepath, modified_time);
577 fprintf(stderr,
"Cycles shader graph: failed to read file %s\n", filepath.c_str());
578 const OSLShaderInfo info;
579 loaded_shaders[bytecode_hash] = info;
583 return shader_load_bytecode(bytecode_hash, bytecode);
586const char *OSLManager::shader_load_bytecode(
const string &
hash,
const string &bytecode)
588 shading_system_init();
590 foreach_shading_system(
591 [
hash, bytecode](OSL::ShadingSystem *ss) { ss->LoadMemoryCompiledShader(
hash, bytecode); });
597 if (!info.query.open_bytecode(bytecode)) {
598 fprintf(stderr,
"OSL query error: %s\n", info.query.geterror().c_str());
602 info.has_surface_emission = (bytecode.find(
"\"emission\"") != string::npos);
603 info.has_surface_transparent = (bytecode.find(
"\"transparent\"") != string::npos);
604 info.has_surface_bssrdf = (bytecode.find(
"\"bssrdf\"") != string::npos);
606 loaded_shaders[
hash] = info;
608 return loaded_shaders.find(
hash)->first.c_str();
611uint64_t OSLShaderManager::get_attribute_id(ustring name)
620 return stdname.hash();
623void OSLShaderManager::device_update_specific(
Device *device,
628 if (!need_update()) {
634 scene->
update_stats->osl.times.add_entry({
"device_update", time});
641 OSLManager::foreach_osl_device(device, [scene](
Device *sub_device, OSLGlobals *og) {
642 OSL::ShadingSystem *ss = scene->
osl_manager->get_shading_system(sub_device);
647 og->use_shading =
true;
649 og->surface_state.clear();
650 og->volume_state.clear();
651 og->displacement_state.clear();
652 og->bump_state.clear();
653 og->background_state.reset();
664 auto compile = [scene, shader, background_shader](
Device *sub_device, OSLGlobals *) {
665 OSL::ShadingSystem *ss = scene->
osl_manager->get_shading_system(sub_device);
668 compiler.background = (shader == background_shader);
669 compiler.compile(shader);
672 task_pool.push([device, compile] { OSLManager::foreach_osl_device(device, compile); });
682 OSLManager::OSLManager::foreach_osl_device(
683 device, [shader, background_shader](
Device *, OSLGlobals *og) {
685 og->surface_state.push_back(shader->osl_surface_ref);
686 og->volume_state.push_back(shader->osl_volume_ref);
687 og->displacement_state.push_back(shader->osl_displacement_ref);
688 og->bump_state.push_back(shader->osl_surface_bump_ref);
690 if (shader == background_shader) {
691 og->background_state = shader->osl_surface_ref;
703 int background_id = scene->
shader_manager->get_shader_id(background_shader);
705 OSLManager::foreach_osl_device(device, [background_id](
Device *, OSLGlobals *og) {
706 og->background_state = og->surface_state[background_id &
SHADER_MASK];
713 update_flags = UPDATE_NONE;
715 device_update_common(device, dscene, scene,
progress);
720 device_free_common(device, dscene, scene);
723 OSLManager::foreach_osl_device(device, [](
Device *, OSLGlobals *og) {
724 og->use_shading =
false;
726 og->surface_state.clear();
727 og->volume_state.clear();
728 og->displacement_state.clear();
729 og->bump_state.clear();
730 og->background_state.reset();
738 const std::string &filepath,
739 const std::string &bytecode_hash,
740 const std::string &bytecode)
749 if (!filepath.empty()) {
755 hash = scene->
osl_manager->shader_load_bytecode(bytecode_hash, bytecode);
766 size_t num_inputs = 0;
768 for (
int i = 0;
i < info->query.nparams();
i++) {
769 const OSL::OSLQuery::Parameter *param = info->query.getparam(
i);
772 if (param->varlenarray || param->isstruct || param->type.arraylen > 1) {
776 if (!param->isoutput) {
785 const set<void *> used_sockets;
787 for (
int i = 0;
i < info->query.nparams();
i++) {
788 const OSL::OSLQuery::Parameter *param = info->query.getparam(
i);
791 if (param->varlenarray || param->isstruct || param->type.arraylen > 1) {
798 if (param->isclosure) {
801 else if (param->type.vecsemantics != TypeDesc::NOSEMANTICS) {
802 if (param->type.vecsemantics == TypeDesc::COLOR) {
805 else if (param->type.vecsemantics == TypeDesc::POINT) {
808 else if (param->type.vecsemantics == TypeDesc::VECTOR) {
811 else if (param->type.vecsemantics == TypeDesc::NORMAL) {
818 if (!param->isoutput && param->validdefault) {
820 default_value->
x = param->fdefault[0];
821 default_value->
y = param->fdefault[1];
822 default_value->
z = param->fdefault[2];
825 else if (param->type.aggregate == TypeDesc::SCALAR) {
826 if (param->type.basetype == TypeDesc::INT) {
829 if (!param->isoutput && param->validdefault) {
833 else if (param->type.basetype == TypeDesc::FLOAT) {
836 if (!param->isoutput && param->validdefault) {
840 else if (param->type.basetype == TypeDesc::STRING) {
843 if (!param->isoutput && param->validdefault) {
855 if (param->isoutput) {
861 int socket_flags = 0;
862 if (!param->validdefault) {
865 for (
const OSL::OSLQuery::Parameter &metadata : param->metadata) {
866 if (metadata.type == TypeDesc::STRING) {
867 if (metadata.name ==
"widget" && metadata.sdefault[0] ==
"null") {
870 else if (metadata.name ==
"defaultgeomprop") {
874 if (metadata.sdefault[0] ==
"Nobject") {
877 else if (metadata.sdefault[0] ==
"Nworld") {
880 else if (metadata.sdefault[0] ==
"Pobject") {
883 else if (metadata.sdefault[0] ==
"Pworld") {
886 else if (metadata.sdefault[0] ==
"Tworld") {
889 else if (metadata.sdefault[0] ==
"UV0") {
896 node->
add_input(param->name, socket_type, socket_flags);
901 if (!bytecode_hash.empty()) {
915void OSLShaderManager::osl_image_slots(
Device *device,
917 set<int> &image_slots)
919 set<OSLRenderServices *> services_shared;
922 services_shared.insert(og->services);
926 for (
auto it = services->
textures.begin(); it != services->
textures.end(); ++it) {
927 if (it->second.handle.get_manager() == image_manager) {
928 const int slot = it->second.handle.svm_slot();
929 image_slots.insert(slot);
937OSLCompiler::OSLCompiler(OSL::ShadingSystem *ss,
Scene *scene)
938 : scene(scene), services(static_cast<
OSLRenderServices *>(ss->renderer())), ss(ss)
941 current_shader =
nullptr;
948 std::stringstream stream;
952 stream.imbue(std::locale(
"C"));
954 stream <<
"node_" << node->
type->
name <<
"_" << node;
961 string sname(
input->name().string());
965 while ((
i = sname.find(
" ")) != string::npos) {
966 sname.replace(
i, 1,
"");
982 string sname(
output->name().string());
986 while ((
i = sname.find(
" ")) != string::npos) {
987 sname.replace(
i, 1,
"");
1025 if (
input->name() ==
"Height") {
1042 name =
scene->osl_manager->shader_load_filepath(name);
1044 if (name ==
nullptr) {
1053 if (node_skip_input(node,
input)) {
1060 const string param_name = compatible_name(node,
input);
1061 const SocketType &socket =
input->socket_type;
1062 switch (
input->type()) {
1095 ss->Shader(*current_group,
"surface", name,
id(node));
1098 ss->Shader(*current_group,
"surface", name,
id(node));
1101 ss->Shader(*current_group,
"displacement", name,
id(node));
1104 ss->Shader(*current_group,
"displacement", name,
id(node));
1113 if (node_skip_input(node,
input)) {
1118 const string id_from = id(
input->link->parent);
1119 const string id_to = id(node);
1120 const string param_from = compatible_name(
input->link->parent,
input->link);
1121 const string param_to = compatible_name(node,
input);
1123 ss->ConnectShaders(*current_group, id_from, param_from, id_to, param_to);
1128 OSLShaderInfo *info =
scene->osl_manager->shader_loaded_info(name);
1134 OSLNode *oslnode =
static_cast<OSLNode *
>(node);
1137 if (info->has_surface_transparent) {
1138 current_shader->has_surface_transparent =
true;
1140 if (info->has_surface_bssrdf) {
1141 current_shader->has_surface_bssrdf =
true;
1142 current_shader->has_bssrdf_bump =
true;
1144 current_shader->has_bump_from_surface =
true;
1145 current_shader->has_surface_raytrace =
true;
1149 current_shader->has_surface_spatial_varying =
true;
1154 current_shader->has_volume_spatial_varying =
true;
1157 current_shader->has_volume_attribute_dependency =
true;
1162static TypeDesc array_typedesc(
const TypeDesc typedesc,
const int arraylength)
1164 return TypeDesc((TypeDesc::BASETYPE)typedesc.basetype,
1165 (TypeDesc::AGGREGATE)typedesc.aggregate,
1166 (TypeDesc::VECSEMANTICS)typedesc.vecsemantics,
1172 const ustring uname = ustring(name);
1175 switch (socket.
type) {
1177 int value = node->
get_bool(socket);
1178 ss->Parameter(*current_group, name, TypeInt, &value);
1183 ss->Parameter(*current_group, uname, TypeFloat, &value);
1187 int value = node->
get_int(socket);
1188 ss->Parameter(*current_group, uname, TypeInt, &value);
1193 ss->Parameter(*current_group, uname, TypeColor, &value);
1198 ss->Parameter(*current_group, uname, TypeVector, &value);
1203 ss->Parameter(*current_group, uname, TypePoint, &value);
1208 ss->Parameter(*current_group, uname, TypeNormal, &value);
1213 ss->Parameter(*current_group,
1215 TypeDesc(TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::POINT),
1221 ss->Parameter(*current_group, uname, TypeString, &value);
1226 ss->Parameter(*current_group, uname, TypeString, &value);
1231 ProjectionTransform projection(value);
1233 ss->Parameter(*current_group, uname, TypeMatrix, &projection);
1239 array<int> intvalue(value.
size());
1240 for (
size_t i = 0;
i < value.
size();
i++) {
1241 intvalue[
i] = value[
i];
1243 ss->Parameter(*current_group, uname, array_typedesc(TypeInt, value.
size()), intvalue.data());
1248 ss->Parameter(*current_group, uname, array_typedesc(TypeFloat, value.
size()), value.
data());
1253 ss->Parameter(*current_group, uname, array_typedesc(TypeInt, value.
size()), value.
data());
1262 switch (socket.
type) {
1264 typedesc = TypeColor;
1267 typedesc = TypeVector;
1270 typedesc = TypePoint;
1273 typedesc = TypeNormal;
1282 array<float> fvalue(value.
size() * 3);
1283 for (
size_t i = 0, j = 0;
i < value.
size();
i++) {
1284 fvalue[j++] = value[
i].x;
1285 fvalue[j++] = value[
i].y;
1286 fvalue[j++] = value[
i].z;
1289 ss->Parameter(*current_group, uname, array_typedesc(typedesc, value.
size()), fvalue.data());
1297 array_typedesc(
TypeDesc(TypeDesc::FLOAT, TypeDesc::VEC2, TypeDesc::POINT), value.
size()),
1303 ss->Parameter(*current_group, uname, array_typedesc(TypeString, value.
size()), value.
data());
1308 array<ProjectionTransform> fvalue(value.
size());
1309 for (
size_t i = 0;
i < value.
size();
i++) {
1313 *current_group, uname, array_typedesc(TypeMatrix, fvalue.size()), fvalue.data());
1331 ss->Parameter(*current_group, name, TypeFloat, &f);
1336 ss->Parameter(*current_group, name, TypeColor, &f);
1341 ss->Parameter(*current_group, name, TypePoint, &f);
1346 ss->Parameter(*current_group, name, TypeNormal, &f);
1351 ss->Parameter(*current_group, name, TypeVector, &f);
1356 ss->Parameter(*current_group, name, TypeInt, &f);
1361 ss->Parameter(*current_group, name, TypeString, (
const void *)&s);
1366 const char *
str = s.c_str();
1367 ss->Parameter(*current_group, name, TypeString, (
const void *)&
str);
1372 ProjectionTransform projection(tfm);
1374 ss->Parameter(*current_group, name, TypeMatrix, (
float *)&projection);
1380 type.arraylen = arraylen;
1381 ss->Parameter(*current_group, name, type, f);
1387 array<float[3]> table(f.
size());
1389 for (
int i = 0;
i < f.
size(); ++
i) {
1390 table[
i][0] = f[
i].x;
1391 table[
i][1] = f[
i].y;
1392 table[
i][2] = f[
i].z;
1396 type.arraylen = table.size();
1397 ss->Parameter(*current_group, name, type, table.data());
1403 parameter(name, (
string(
"geom:") + s.c_str()).c_str());
1414 if (node !=
nullptr && dependencies.find(node) == dependencies.end()) {
1415 for (ShaderInput *
in : node->
inputs) {
1416 if (!node_skip_input(node,
in)) {
1417 find_dependencies(dependencies,
in);
1421 dependencies.insert(node);
1433 for (ShaderNode *node : nodes) {
1434 if (done.find(node) == done.end()) {
1435 bool inputs_done =
true;
1438 if (!node_skip_input(node,
input)) {
1439 if (
input->link && done.find(
input->link->parent) == done.end()) {
1440 inputs_done =
false;
1451 current_shader->has_surface_transparent =
true;
1454 current_shader->has_surface_raytrace =
true;
1457 current_shader->has_surface_spatial_varying =
true;
1460 current_shader->has_surface_bssrdf =
true;
1462 current_shader->has_bssrdf_bump =
true;
1466 current_shader->has_bump_from_surface =
true;
1471 current_shader->has_volume_spatial_varying =
true;
1480 }
while (!nodes_done);
1485 current_type = type;
1488 std::stringstream name;
1489 name.imbue(std::locale(
"C"));
1490 name <<
"shader_" << shader->
name.hash();
1492 current_group = ss->ShaderGroupBegin(name.str());
1499 find_dependencies(dependencies,
output->input(
"Surface"));
1500 generate_nodes(dependencies);
1505 find_dependencies(dependencies,
output->input(
"Normal"));
1506 generate_nodes(dependencies);
1511 find_dependencies(dependencies,
output->input(
"Volume"));
1512 generate_nodes(dependencies);
1517 find_dependencies(dependencies,
output->input(
"Displacement"));
1518 generate_nodes(dependencies);
1525 ss->ShaderGroupEnd(*current_group);
1527 return std::move(current_group);
1533 ShaderGraph *graph = shader->
graph.get();
1534 ShaderNode *
output = (graph) ? graph->
output() :
nullptr;
1536 current_shader = shader;
1557 shader->osl_surface_bump_ref = OSL::ShaderGroupRef();
1563 shader->osl_surface_ref = OSL::ShaderGroupRef();
1564 shader->osl_surface_bump_ref = OSL::ShaderGroupRef();
1573 shader->osl_volume_ref = OSL::ShaderGroupRef();
1578 shader->osl_displacement_ref = compile_type(
1583 shader->osl_displacement_ref = OSL::ShaderGroupRef();
1607 const ustring filename(
string_printf(
"@svm%d", texture_shared_unique_id++).c_str());
1616 const ustring filename(
string_printf(
"@svm%d", texture_shared_unique_id++).c_str());
BMesh const char void * data
unsigned long long int uint64_t
Shader * get_shader(const Scene *scene)
static ColorSpaceProcessor * get_processor(ustring colorspace)
virtual const string & error_message()
virtual bool load_osl_kernels()
virtual void foreach_device(const std::function< void(Device *)> &callback)
virtual OSLGlobals * get_cpu_osl_memory()
vector< int4 > get_svm_slots() const
void append(const uint8_t *data, const int nbytes)
void parameter_array(const char *name, const float f[], int arraylen)
void add(ShaderNode *node, const char *name, bool isfilepath=false)
void parameter_texture(const char *name, ustring filename, ustring colorspace)
void parameter(ShaderNode *node, const char *name)
void compile(Shader *shader)
void parameter_color_array(const char *name, const array< float3 > &f)
void parameter_texture_ies(const char *name, const int svm_slot)
void parameter_point(const char *name, const float3 f)
void parameter_vector(const char *name, const float3 f)
void parameter_attribute(const char *name, ustring s)
void parameter_color(const char *name, const float3 f)
void parameter_normal(const char *name, const float3 f)
void device_free(Device *device, DeviceScene *dscene, Scene *scene)
void device_update_pre(Device *device, Scene *scene)
static void free_memory()
void device_update_post(Device *device, Scene *scene, Progress &progress, const bool reload_kernels)
OSLManager(Device *device)
void add_input(ustring name, SocketType::Type type, const int flags=0)
static OSLNode * create(ShaderGraph *graph, const size_t num_inputs, const OSLNode *from=nullptr)
void add_output(ustring name, SocketType::Type type)
char * input_default_value()
static ImageManager * image_manager
OSLTextureHandleMap textures
static void register_closures(OSL::ShadingSystem *ss)
virtual bool has_surface_transparent()
ShaderNodeSpecialType special_type
virtual bool has_bssrdf_bump()
virtual bool has_spatial_varying()
virtual int get_feature()
virtual bool has_attribute_dependency()
void create_inputs_outputs(const NodeType *type)
unique_ptr_vector< ShaderInput > inputs
virtual bool has_surface_bssrdf()
virtual void compile(SVMCompiler &compiler)=0
unique_ptr_vector< ShaderOutput > outputs
bool has_surface_spatial_varying
bool has_bump_from_surface
bool has_volume_attribute_dependency
bool has_bump_from_displacement
EmissionSampling emission_sampling
bool has_surface_raytrace
bool has_surface_transparent
NODE_DECLARE unique_ptr< ShaderGraph > graph
bool has_volume_spatial_varying
T * util_aligned_new(Args... args)
void util_aligned_delete(T *t)
ccl_device_inline ProjectionTransform projection_transpose(const ProjectionTransform a)
CCL_NAMESPACE_BEGIN struct Options options
#define KERNEL_FEATURE_NODE_RAYTRACE
#define CCL_NAMESPACE_END
VecBase< float, 2 > float2
#define assert(assertion)
VecBase< float, 3 > float3
@ SHADER_TYPE_DISPLACEMENT
OSL::ustringhash OSLUStringHash
string path_user_get(const string &sub)
string path_dirname(const string &path)
string path_get(const string &sub)
uint64_t path_modified_time(const string &path)
string path_join(const string &dir, const string &file)
bool path_read_text(const string &path, string &text)
@ SHADER_SPECIAL_TYPE_BUMP
@ SHADER_SPECIAL_TYPE_OUTPUT
@ SHADER_SPECIAL_TYPE_OSL
set< ShaderNode *, ShaderNodeIDComparator > ShaderNodeSet
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
static AttributeStandard name_standard(const char *name)
static const char * standard_name(AttributeStandard std)
const SocketType * find_input(ustring name) const
const array< float3 > & get_float3_array(const SocketType &input) const
const array< float > & get_float_array(const SocketType &input) const
const array< int > & get_int_array(const SocketType &input) const
float get_float(const SocketType &input) const
Transform get_transform(const SocketType &input) const
float3 get_float3(const SocketType &input) const
const array< bool > & get_bool_array(const SocketType &input) const
bool get_bool(const SocketType &input) const
int reference_count() const
float2 get_float2(const SocketType &input) const
const array< ustring > & get_string_array(const SocketType &input) const
const array< float2 > & get_float2_array(const SocketType &input) const
ustring get_string(const SocketType &input) const
int get_int(const SocketType &input) const
const array< Transform > & get_transform_array(const SocketType &input) const
unique_ptr< LightManager > light_manager
unique_ptr< SceneUpdateStats > update_stats
unique_ptr_vector< Shader > shaders
unique_ptr< ShaderManager > shader_manager
unique_ptr< OSLManager > osl_manager
unique_ptr< ImageManager > image_manager
std::unique_lock< std::mutex > thread_scoped_lock