diff options
Diffstat (limited to 'intern/cycles/kernel/osl/osl_services.h')
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.h | 388 |
1 files changed, 220 insertions, 168 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h index 3990a22aefd..2fad5833fc9 100644 --- a/intern/cycles/kernel/osl/osl_services.h +++ b/intern/cycles/kernel/osl/osl_services.h @@ -40,177 +40,229 @@ class Shader; struct ShaderData; struct float3; struct KernelGlobals; -class OSLRenderServices : public OSL::RendererServices -{ -public: - OSLRenderServices(); - ~OSLRenderServices(); - - void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts); - - bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) override; - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) override; - - bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from, float time) override; - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to, float time) override; - - bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform) override; - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform) override; - - bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from) override; - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from) override; - - bool get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, - ustring object, TypeDesc type, ustring name, - int index, void *val) override; - bool get_attribute(OSL::ShaderGlobals *sg, bool derivatives, ustring object, - TypeDesc type, ustring name, void *val) override; - bool get_attribute(ShaderData *sd, bool derivatives, ustring object_name, - TypeDesc type, ustring name, void *val); - - bool get_userdata(bool derivatives, ustring name, TypeDesc type, - OSL::ShaderGlobals *sg, void *val) override; - - int pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 ¢er, - float radius, int max_points, bool sort, size_t *out_indices, - float *out_distances, int derivs_offset) override; - - int pointcloud_get(OSL::ShaderGlobals *sg, ustring filename, size_t *indices, int count, - ustring attr_name, TypeDesc attr_type, void *out_data) override; - - bool pointcloud_write(OSL::ShaderGlobals *sg, - ustring filename, const OSL::Vec3 &pos, - int nattribs, const ustring *names, - const TypeDesc *types, - const void **data) override; - - bool trace(TraceOpt &options, OSL::ShaderGlobals *sg, - const OSL::Vec3 &P, const OSL::Vec3 &dPdx, - const OSL::Vec3 &dPdy, const OSL::Vec3 &R, - const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy) override; - - bool getmessage(OSL::ShaderGlobals *sg, ustring source, ustring name, - TypeDesc type, void *val, bool derivatives) override; - - TextureSystem::TextureHandle *get_texture_handle(ustring filename) override; - - bool good(TextureSystem::TextureHandle *texture_handle) override; - - bool texture(ustring filename, - TextureSystem::TextureHandle *texture_handle, - TexturePerthread *texture_thread_info, - TextureOpt &options, - OSL::ShaderGlobals *sg, - float s, float t, - float dsdx, float dtdx, float dsdy, float dtdy, - int nchannels, - float *result, - float *dresultds, - float *dresultdt, - ustring *errormessage) override; - - bool texture3d(ustring filename, - TextureHandle *texture_handle, - TexturePerthread *texture_thread_info, - TextureOpt &options, - OSL::ShaderGlobals *sg, - const OSL::Vec3 &P, - const OSL::Vec3 &dPdx, - const OSL::Vec3 &dPdy, - const OSL::Vec3 &dPdz, - int nchannels, - float *result, - float *dresultds, - float *dresultdt, - float *dresultdr, - ustring *errormessage) override; - - bool environment(ustring filename, - TextureHandle *texture_handle, - TexturePerthread *texture_thread_info, - TextureOpt &options, - OSL::ShaderGlobals *sg, - const OSL::Vec3 &R, - const OSL::Vec3 &dRdx, - const OSL::Vec3 &dRdy, - int nchannels, - float *result, - float *dresultds, - float *dresultdt, - ustring *errormessage) override; - - bool get_texture_info(OSL::ShaderGlobals *sg, - ustring filename, - TextureHandle *texture_handle, - int subimage, - ustring dataname, - TypeDesc datatype, - void *data) override; - - static bool get_background_attribute(KernelGlobals *kg, ShaderData *sd, ustring name, - TypeDesc type, bool derivatives, void *val); - static bool get_object_standard_attribute(KernelGlobals *kg, ShaderData *sd, ustring name, - TypeDesc type, bool derivatives, void *val); - - static ustring u_distance; - static ustring u_index; - static ustring u_world; - static ustring u_camera; - static ustring u_screen; - static ustring u_raster; - static ustring u_ndc; - static ustring u_object_location; - static ustring u_object_index; - static ustring u_geom_dupli_generated; - static ustring u_geom_dupli_uv; - static ustring u_material_index; - static ustring u_object_random; - static ustring u_particle_index; - static ustring u_particle_random; - static ustring u_particle_age; - static ustring u_particle_lifetime; - static ustring u_particle_location; - static ustring u_particle_rotation; - static ustring u_particle_size; - static ustring u_particle_velocity; - static ustring u_particle_angular_velocity; - static ustring u_geom_numpolyvertices; - static ustring u_geom_trianglevertices; - static ustring u_geom_polyvertices; - static ustring u_geom_name; - static ustring u_geom_undisplaced; - static ustring u_is_smooth; - static ustring u_is_curve; - static ustring u_curve_thickness; - static ustring u_curve_tangent_normal; - static ustring u_curve_random; - static ustring u_path_ray_length; - static ustring u_path_ray_depth; - static ustring u_path_diffuse_depth; - static ustring u_path_glossy_depth; - static ustring u_path_transparent_depth; - static ustring u_path_transmission_depth; - static ustring u_trace; - static ustring u_hit; - static ustring u_hitdist; - static ustring u_N; - static ustring u_Ng; - static ustring u_P; - static ustring u_I; - static ustring u_u; - static ustring u_v; - static ustring u_empty; - static ustring u_at_bevel; - static ustring u_at_ao; - -private: - KernelGlobals *kernel_globals; - OSL::TextureSystem *osl_ts; +class OSLRenderServices : public OSL::RendererServices { + public: + OSLRenderServices(); + ~OSLRenderServices(); + + void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts); + + bool get_matrix(OSL::ShaderGlobals *sg, + OSL::Matrix44 &result, + OSL::TransformationPtr xform, + float time) override; + bool get_inverse_matrix(OSL::ShaderGlobals *sg, + OSL::Matrix44 &result, + OSL::TransformationPtr xform, + float time) override; + + bool get_matrix(OSL::ShaderGlobals *sg, + OSL::Matrix44 &result, + ustring from, + float time) override; + bool get_inverse_matrix(OSL::ShaderGlobals *sg, + OSL::Matrix44 &result, + ustring to, + float time) override; + + bool get_matrix(OSL::ShaderGlobals *sg, + OSL::Matrix44 &result, + OSL::TransformationPtr xform) override; + bool get_inverse_matrix(OSL::ShaderGlobals *sg, + OSL::Matrix44 &result, + OSL::TransformationPtr xform) override; + + bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from) override; + bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from) override; + + bool get_array_attribute(OSL::ShaderGlobals *sg, + bool derivatives, + ustring object, + TypeDesc type, + ustring name, + int index, + void *val) override; + bool get_attribute(OSL::ShaderGlobals *sg, + bool derivatives, + ustring object, + TypeDesc type, + ustring name, + void *val) override; + bool get_attribute(ShaderData *sd, + bool derivatives, + ustring object_name, + TypeDesc type, + ustring name, + void *val); + + bool get_userdata( + bool derivatives, ustring name, TypeDesc type, OSL::ShaderGlobals *sg, void *val) override; + + int pointcloud_search(OSL::ShaderGlobals *sg, + ustring filename, + const OSL::Vec3 ¢er, + float radius, + int max_points, + bool sort, + size_t *out_indices, + float *out_distances, + int derivs_offset) override; + + int pointcloud_get(OSL::ShaderGlobals *sg, + ustring filename, + size_t *indices, + int count, + ustring attr_name, + TypeDesc attr_type, + void *out_data) override; + + bool pointcloud_write(OSL::ShaderGlobals *sg, + ustring filename, + const OSL::Vec3 &pos, + int nattribs, + const ustring *names, + const TypeDesc *types, + const void **data) override; + + bool trace(TraceOpt &options, + OSL::ShaderGlobals *sg, + const OSL::Vec3 &P, + const OSL::Vec3 &dPdx, + const OSL::Vec3 &dPdy, + const OSL::Vec3 &R, + const OSL::Vec3 &dRdx, + const OSL::Vec3 &dRdy) override; + + bool getmessage(OSL::ShaderGlobals *sg, + ustring source, + ustring name, + TypeDesc type, + void *val, + bool derivatives) override; + + TextureSystem::TextureHandle *get_texture_handle(ustring filename) override; + + bool good(TextureSystem::TextureHandle *texture_handle) override; + + bool texture(ustring filename, + TextureSystem::TextureHandle *texture_handle, + TexturePerthread *texture_thread_info, + TextureOpt &options, + OSL::ShaderGlobals *sg, + float s, + float t, + float dsdx, + float dtdx, + float dsdy, + float dtdy, + int nchannels, + float *result, + float *dresultds, + float *dresultdt, + ustring *errormessage) override; + + bool texture3d(ustring filename, + TextureHandle *texture_handle, + TexturePerthread *texture_thread_info, + TextureOpt &options, + OSL::ShaderGlobals *sg, + const OSL::Vec3 &P, + const OSL::Vec3 &dPdx, + const OSL::Vec3 &dPdy, + const OSL::Vec3 &dPdz, + int nchannels, + float *result, + float *dresultds, + float *dresultdt, + float *dresultdr, + ustring *errormessage) override; + + bool environment(ustring filename, + TextureHandle *texture_handle, + TexturePerthread *texture_thread_info, + TextureOpt &options, + OSL::ShaderGlobals *sg, + const OSL::Vec3 &R, + const OSL::Vec3 &dRdx, + const OSL::Vec3 &dRdy, + int nchannels, + float *result, + float *dresultds, + float *dresultdt, + ustring *errormessage) override; + + bool get_texture_info(OSL::ShaderGlobals *sg, + ustring filename, + TextureHandle *texture_handle, + int subimage, + ustring dataname, + TypeDesc datatype, + void *data) override; + + static bool get_background_attribute( + KernelGlobals *kg, ShaderData *sd, ustring name, TypeDesc type, bool derivatives, void *val); + static bool get_object_standard_attribute( + KernelGlobals *kg, ShaderData *sd, ustring name, TypeDesc type, bool derivatives, void *val); + + static ustring u_distance; + static ustring u_index; + static ustring u_world; + static ustring u_camera; + static ustring u_screen; + static ustring u_raster; + static ustring u_ndc; + static ustring u_object_location; + static ustring u_object_index; + static ustring u_geom_dupli_generated; + static ustring u_geom_dupli_uv; + static ustring u_material_index; + static ustring u_object_random; + static ustring u_particle_index; + static ustring u_particle_random; + static ustring u_particle_age; + static ustring u_particle_lifetime; + static ustring u_particle_location; + static ustring u_particle_rotation; + static ustring u_particle_size; + static ustring u_particle_velocity; + static ustring u_particle_angular_velocity; + static ustring u_geom_numpolyvertices; + static ustring u_geom_trianglevertices; + static ustring u_geom_polyvertices; + static ustring u_geom_name; + static ustring u_geom_undisplaced; + static ustring u_is_smooth; + static ustring u_is_curve; + static ustring u_curve_thickness; + static ustring u_curve_tangent_normal; + static ustring u_curve_random; + static ustring u_path_ray_length; + static ustring u_path_ray_depth; + static ustring u_path_diffuse_depth; + static ustring u_path_glossy_depth; + static ustring u_path_transparent_depth; + static ustring u_path_transmission_depth; + static ustring u_trace; + static ustring u_hit; + static ustring u_hitdist; + static ustring u_N; + static ustring u_Ng; + static ustring u_P; + static ustring u_I; + static ustring u_u; + static ustring u_v; + static ustring u_empty; + static ustring u_at_bevel; + static ustring u_at_ao; + + private: + KernelGlobals *kernel_globals; + OSL::TextureSystem *osl_ts; #ifdef WITH_PTEX - PtexCache *ptex_cache; + PtexCache *ptex_cache; #endif }; CCL_NAMESPACE_END -#endif /* __OSL_SERVICES_H__ */ +#endif /* __OSL_SERVICES_H__ */ |