15#include <OSL/oslclosure.h>
16#include <OSL/oslexec.h>
17#include <OSL/rendererservices.h>
19#include <OpenImageIO/unordered_map_concurrent.h>
81 OIIO::unordered_map_concurrent<OSLTextureKey, OSLTextureHandle, OSLTextureKeyHash>;
95 int supports(string_view feature)
const override;
98 OSL::Matrix44 &result,
99 OSL::TransformationPtr xform,
100 float time)
override;
102 OSL::Matrix44 &result,
103 OSL::TransformationPtr xform,
104 float time)
override;
107 OSL::Matrix44 &result,
109 float time)
override;
111 OSL::Matrix44 &result,
113 float time)
override;
116 OSL::Matrix44 &result,
117 OSL::TransformationPtr xform)
override;
119 OSL::Matrix44 &result,
120 OSL::TransformationPtr xform)
override;
124 OSL::Matrix44 &result,
144 OSL::ShaderGlobals *sg,
149 const OSL::Vec3 ¢er,
151 const int max_points,
153#
if OSL_LIBRARY_VERSION_CODE >= 11400
158 float *out_distances,
159 int derivs_offset)
override;
163#
if OSL_LIBRARY_VERSION_CODE >= 11400
171 const TypeDesc attr_type,
172 void *out_data)
override;
176 const OSL::Vec3 &pos,
179 const TypeDesc *types,
180 const void **data)
override;
183 OSL::ShaderGlobals *sg,
185 const OSL::Vec3 &
dPdx,
186 const OSL::Vec3 &
dPdy,
188 const OSL::Vec3 &dRdx,
189 const OSL::Vec3 &dRdy)
override;
196 bool derivatives)
override;
199 OSL::ShadingContext *context,
200 const OSL::TextureOpt *
options)
override;
202 OSL::ShadingContext *context,
203 const OSL::TextureOpt *
options)
override;
205 bool good(OSL::TextureSystem::TextureHandle *texture_handle)
override;
206 bool is_udim(OSL::TextureSystem::TextureHandle *texture_handle)
override;
209 OSL::TextureSystem::TextureHandle *texture_handle,
210 TexturePerthread *texture_thread_info,
212 OSL::ShaderGlobals *sg,
226 TextureHandle *texture_handle,
227 TexturePerthread *texture_thread_info,
229 OSL::ShaderGlobals *sg,
231 const OSL::Vec3 &
dPdx,
232 const OSL::Vec3 &
dPdy,
233 const OSL::Vec3 &dPdz,
242 TextureHandle *texture_handle,
243 TexturePerthread *texture_thread_info,
245 OSL::ShaderGlobals *sg,
247 const OSL::Vec3 &dRdx,
248 const OSL::Vec3 &dRdy,
256 TextureHandle *texture_handle,
257 TexturePerthread *texture_thread_info,
258 OSL::ShaderGlobals *sg,
261 const TypeDesc datatype,
266 TextureHandle *texture_handle,
269 TexturePerthread *texture_thread_info,
270 OSL::ShaderGlobals *sg,
273 const TypeDesc datatype,
313 ImageManager *image_manager_find(
const OSL::ShadingContext *context);
315 unordered_map<const OSL::ShadingContext *, ImageManager *> image_managers_;
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
static bool get_background_attribute(ShaderGlobals *globals, ShaderData *sd, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
bool get_texture_info(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::ShaderGlobals *sg, const int subimage, OSLUStringHash dataname, const TypeDesc datatype, void *data, OSLUStringHash *errormessage) override
bool is_udim(OSL::TextureSystem::TextureHandle *texture_handle) override
bool texture(OSLUStringHash filename, OSL::TextureSystem::TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::TextureOpt &options, OSL::ShaderGlobals *sg, const float s, const float t, const float dsdx, const float dtdx, const float dsdy, const float dtdy, const int nchannels, float *result, float *dresultds, float *dresultdt, OSLUStringHash *errormessage) override
bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) override
int pointcloud_search(OSL::ShaderGlobals *sg, OSLUStringHash filename, const OSL::Vec3 ¢er, const float radius, const int max_points, bool sort, size_t *out_indices, float *out_distances, int derivs_offset) override
~OSLRenderServices() override
int supports(string_view feature) const override
static bool get_object_standard_attribute(ShaderGlobals *globals, ShaderData *sd, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
static bool get_camera_attribute(ShaderGlobals *globals, OSLUStringHash name, TypeDesc type, bool derivatives, void *val)
bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) override
OSLRenderServices(const int device_type)
int pointcloud_get(OSL::ShaderGlobals *sg, OSLUStringHash filename, size_t *indices, const int count, OSLUStringHash attr_name, const TypeDesc attr_type, void *out_data) override
OSLTextureHandleMap textures
static void register_closures(OSL::ShadingSystem *ss)
bool pointcloud_write(OSL::ShaderGlobals *sg, OSLUStringHash filename, const OSL::Vec3 &pos, const int nattribs, const OSLUStringRep *names, const TypeDesc *types, const void **data) override
bool environment(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::TextureOpt &options, OSL::ShaderGlobals *sg, const OSL::Vec3 &R, const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, const int nchannels, float *result, float *dresultds, float *dresultdt, OSLUStringHash *errormessage) override
bool get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, OSLUStringHash object, const TypeDesc type, OSLUStringHash name, const int index, void *val) override
bool get_attribute(OSL::ShaderGlobals *sg, bool derivatives, OSLUStringHash object, const TypeDesc type, OSLUStringHash name, void *val) override
bool get_userdata(bool derivatives, OSLUStringHash name, const TypeDesc type, OSL::ShaderGlobals *sg, void *val) 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 texture3d(OSLUStringHash filename, TextureHandle *texture_handle, TexturePerthread *texture_thread_info, OSL::TextureOpt &options, OSL::ShaderGlobals *sg, const OSL::Vec3 &P, const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy, const OSL::Vec3 &dPdz, const int nchannels, float *result, float *dresultds, float *dresultdt, float *dresultdr, OSLUStringHash *errormessage) override
void image_manager_remove(const OSL::ShadingContext *context)
bool getmessage(OSL::ShaderGlobals *sg, OSLUStringHash source, OSLUStringHash name, const TypeDesc type, void *val, bool derivatives) override
void image_manager_add(const OSL::ShadingContext *context, ImageManager *image_manager)
OSL::TextureSystem::TextureHandle * get_texture_handle(OSL::ustring filename, OSL::ShadingContext *context, const OSL::TextureOpt *options) override
bool good(OSL::TextureSystem::TextureHandle *texture_handle) override
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
CCL_NAMESPACE_BEGIN struct Options options
#define CCL_NAMESPACE_END
OSL::ustringhash OSLUStringHash
OSL::ustringrep OSLUStringRep
concurrent_set< OSLUStringHash > OSLTextureFilenameMap
OIIO::unordered_map_concurrent< OSLTextureKey, OSLTextureHandle, OSLTextureKeyHash > OSLTextureHandleMap
OSLTextureHandle(const ImageHandle &handle)
OSLTextureHandleType type
OSLTextureHandle(const OSLTextureHandleType type, const int id=-1)
size_t operator()(const OSLTextureKey &key) const
const ImageManager * image_manager
bool operator==(const OSLTextureKey &other) const =default