20# include <OSL/llvm_util.h>
21# include <OSL/oslcomp.h>
22# include <OSL/oslexec.h>
23# include <OSL/oslquery.h>
45 OSLShaderInfo() =
default;
48 bool has_surface_emission =
false;
49 bool has_surface_transparent =
false;
50 bool has_surface_bssrdf =
false;
68 const bool reload_kernels);
73 static bool osl_compile(
const string &inputfile,
const string &outputfile);
74 static bool osl_query(OSL::OSLQuery &query,
const string &filepath);
77 const char *shader_test_loaded(
const string &
hash);
78 const char *shader_load_bytecode(
const string &
hash,
const string &bytecode);
79 const char *shader_load_filepath(
string filepath);
80 OSLShaderInfo *shader_loaded_info(
const string &
hash);
82 OSL::ShadingSystem *get_shading_system(
Device *sub_device);
83 OSL::TextureSystem *get_texture_system();
84 static void foreach_osl_device(
Device *device,
85 const std::function<
void(
Device *, OSLGlobals *)> &callback);
93 void texture_system_init();
94 void texture_system_free();
96 void shading_system_init();
97 void shading_system_free();
99 void foreach_shading_system(
const std::function<
void(OSL::ShadingSystem *)> &callback);
100 void foreach_render_services(
const std::function<
void(
OSLRenderServices *)> &callback);
103 map<string, OSLShaderInfo> loaded_shaders;
105 std::shared_ptr<OSL::TextureSystem> ts;
106 map<DeviceType, std::shared_ptr<OSL::ShadingSystem>> ss_map;
118 OSLShaderManager() =
default;
119 ~OSLShaderManager()
override =
default;
133 void device_free(Device *device, DeviceScene *dscene,
Scene *scene)
override;
136 static OSLNode *osl_node(ShaderGraph *graph,
138 const std::string &filepath,
139 const std::string &bytecode_hash =
"",
140 const std::string &bytecode =
"");
143 static void osl_image_slots(Device *device, ImageManager *image_manager, set<int> &image_slots);
157 void add(
ShaderNode *node,
const char *name,
bool isfilepath =
false);
161 void parameter(
const char *name,
const float f);
166 void parameter(
const char *name,
const int f);
167 void parameter(
const char *name,
const char *s);
200 OSL::ShadingSystem *ss;
201 OSL::ShaderGroupRef current_group;
207 static std::atomic<int> texture_shared_unique_id;
unsigned long long int uint64_t
void reset()
clear internal cached data and reset random seed
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)
virtual void device_free(Device *device, DeviceScene *dscene, Scene *scene)=0
virtual uint64_t get_attribute_id(ustring name)
virtual void device_update_specific(Device *device, DeviceScene *dscene, Scene *scene, Progress &progress)=0
#define CCL_NAMESPACE_END
set< ShaderNode *, ShaderNodeIDComparator > ShaderNodeSet