Fix T57393: Cycles OSL bevel and AO not working after OSL upgrade.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Fri, 26 Oct 2018 17:26:06 +0000 (19:26 +0200)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Sat, 27 Oct 2018 13:00:37 +0000 (15:00 +0200)
intern/cycles/kernel/osl/osl_services.cpp
intern/cycles/kernel/osl/osl_services.h

index 7902381440bdb7035bae2b9d926e8e17845a8421..81348f5594dda8e73a48e98d1d3baf97d5e84f15 100644 (file)
@@ -884,6 +884,23 @@ bool OSLRenderServices::has_userdata(ustring name, TypeDesc type, OSL::ShaderGlo
        return false; /* never called by OSL */
 }
 
+TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(ustring filename)
+{
+       if (filename.length() && filename[0] == '@') {
+               /* Dummy, we don't use texture handles for builtin textures but need
+                * to tell the OSL runtime optimizer that this is a valid texture. */
+               return NULL;
+       }
+       else {
+               return texturesys()->get_texture_handle(filename);
+       }
+}
+
+bool OSLRenderServices::good(TextureSystem::TextureHandle *texture_handle)
+{
+       return texturesys()->good(texture_handle);
+}
+
 bool OSLRenderServices::texture(ustring filename,
                                 TextureHandle *texture_handle,
                                 TexturePerthread *texture_thread_info,
@@ -894,7 +911,8 @@ bool OSLRenderServices::texture(ustring filename,
                                 int nchannels,
                                 float *result,
                                 float *dresultds,
-                                float *dresultdt)
+                                float *dresultdt,
+                                ustring *errormessage)
 {
        OSL::TextureSystem *ts = osl_ts;
        ShaderData *sd = (ShaderData *)(sg->renderstate);
@@ -1156,7 +1174,13 @@ bool OSLRenderServices::get_texture_info(OSL::ShaderGlobals *sg, ustring filenam
                                          TypeDesc datatype, void *data)
 {
        OSL::TextureSystem *ts = osl_ts;
-       return ts->get_texture_info(filename, subimage, dataname, datatype, data);
+       if (filename.length() && filename[0] == '@') {
+               /* Special builtin textures. */
+               return false;
+       }
+       else {
+               return ts->get_texture_info(filename, subimage, dataname, datatype, data);
+       }
 }
 
 int OSLRenderServices::pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 &center,
index 50044746fd10dacddd530cd06b50657a5779024e..5dcaa4d74454af572175b699d72ef3f17012ae18 100644 (file)
@@ -93,6 +93,10 @@ public:
        bool getmessage(OSL::ShaderGlobals *sg, ustring source, ustring name,
                        TypeDesc type, void *val, bool derivatives);
 
+       TextureSystem::TextureHandle *get_texture_handle(ustring filename);
+
+       bool good(TextureSystem::TextureHandle *texture_handle);
+
        bool texture(ustring filename,
                     TextureSystem::TextureHandle *texture_handle,
                     TexturePerthread *texture_thread_info,
@@ -103,7 +107,8 @@ public:
                     int nchannels,
                     float *result,
                     float *dresultds,
-                    float *dresultdt);
+                    float *dresultdt,
+                    ustring *errormessage);
 
        bool texture3d(ustring filename,
                       TextureHandle *texture_handle,