diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-02 21:58:26 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-02 21:58:26 +0300 |
commit | 017573495e36e3a2277a1da1ab8febc7f9c2d973 (patch) | |
tree | 266ab0dc4fd70c9983ac577e332e8b9166be843d /intern/cycles | |
parent | 8063d72b08d2e219ebb2087e6188a8f2186f398d (diff) | |
parent | f7e9642da9c9a56a435c2a7f1e506245700a72b0 (diff) |
Merge branch 'blender2.7'
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.cpp | 50 | ||||
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.h | 72 |
2 files changed, 75 insertions, 47 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index 97f97a4887e..5b4bddbb6de 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -879,11 +879,6 @@ bool OSLRenderServices::get_userdata(bool derivatives, ustring name, TypeDesc ty return false; /* disabled by lockgeom */ } -bool OSLRenderServices::has_userdata(ustring name, TypeDesc type, OSL::ShaderGlobals *sg) -{ - return false; /* never called by OSL */ -} - TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(ustring filename) { if(filename.length() && filename[0] == '@') { @@ -1072,7 +1067,8 @@ bool OSLRenderServices::texture3d(ustring filename, float *result, float *dresultds, float *dresultdt, - float *dresultdr) + float *dresultdr, + ustring *errormessage) { OSL::TextureSystem *ts = osl_ts; ShaderData *sd = (ShaderData *)(sg->renderstate); @@ -1138,22 +1134,36 @@ bool OSLRenderServices::texture3d(ustring filename, return status; } -bool OSLRenderServices::environment(ustring filename, TextureOpt &options, - OSL::ShaderGlobals *sg, const OSL::Vec3 &R, - const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, - int nchannels, float *result) +bool OSLRenderServices::environment(ustring filename, + TextureHandle *th, + TexturePerthread *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) { OSL::TextureSystem *ts = osl_ts; - ShaderData *sd = (ShaderData *)(sg->renderstate); - KernelGlobals *kg = sd->osl_globals; - OSLThreadData *tdata = kg->osl_tdata; - OIIO::TextureSystem::Perthread *thread_info = tdata->oiio_thread_info; - OIIO::TextureSystem::TextureHandle *th = ts->get_texture_handle(filename, thread_info); + if (thread_info == NULL) { + ShaderData *sd = (ShaderData *)(sg->renderstate); + KernelGlobals *kg = sd->osl_globals; + OSLThreadData *tdata = kg->osl_tdata; + thread_info = tdata->oiio_thread_info; + } + + if (th == NULL) { + th = ts->get_texture_handle(filename, thread_info); + } bool status = ts->environment(th, thread_info, options, R, dRdx, dRdy, - nchannels, result); + nchannels, result, dresultds, dresultdt); if(!status) { if(nchannels == 3 || nchannels == 4) { @@ -1169,9 +1179,13 @@ bool OSLRenderServices::environment(ustring filename, TextureOpt &options, return status; } -bool OSLRenderServices::get_texture_info(OSL::ShaderGlobals *sg, ustring filename, int subimage, +bool OSLRenderServices::get_texture_info(OSL::ShaderGlobals *sg, + ustring filename, + TextureHandle *th, + int subimage, ustring dataname, - TypeDesc datatype, void *data) + TypeDesc datatype, + void *data) { OSL::TextureSystem *ts = osl_ts; if(filename.length() && filename[0] == '@') { diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h index 712b06b41b8..3990a22aefd 100644 --- a/intern/cycles/kernel/osl/osl_services.h +++ b/intern/cycles/kernel/osl/osl_services.h @@ -48,54 +48,53 @@ public: void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts); - bool get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time); - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time); + 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); - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to, float time); + 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); - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform); + 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); - bool get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from); + 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); + int index, void *val) override; bool get_attribute(OSL::ShaderGlobals *sg, bool derivatives, ustring object, - TypeDesc type, ustring name, void *val); + 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); - bool has_userdata(ustring name, TypeDesc type, OSL::ShaderGlobals *sg); + 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); + 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); + 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); + 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); + const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy) override; bool getmessage(OSL::ShaderGlobals *sg, ustring source, ustring name, - TypeDesc type, void *val, bool derivatives); + TypeDesc type, void *val, bool derivatives) override; - TextureSystem::TextureHandle *get_texture_handle(ustring filename); + TextureSystem::TextureHandle *get_texture_handle(ustring filename) override; - bool good(TextureSystem::TextureHandle *texture_handle); + bool good(TextureSystem::TextureHandle *texture_handle) override; bool texture(ustring filename, TextureSystem::TextureHandle *texture_handle, @@ -108,7 +107,7 @@ public: float *result, float *dresultds, float *dresultdt, - ustring *errormessage); + ustring *errormessage) override; bool texture3d(ustring filename, TextureHandle *texture_handle, @@ -123,15 +122,30 @@ public: float *result, float *dresultds, float *dresultdt, - float *dresultdr); - - bool environment(ustring filename, TextureOpt &options, - OSL::ShaderGlobals *sg, const OSL::Vec3 &R, - const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, - int nchannels, float *result); - - bool get_texture_info(OSL::ShaderGlobals *sg, ustring filename, int subimage, - ustring dataname, TypeDesc datatype, void *data); + 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); |