[Bf-blender-cvs] [6582215] master: Cycles: Updates for new OSL 1.5 API.

Thomas Dinges noreply at git.blender.org
Thu Jul 24 23:08:33 CEST 2014


Commit: 6582215f87015f3909f318a5b8c3b5d48c968424
Author: Thomas Dinges
Date:   Thu Jul 24 23:07:49 2014 +0200
Branches: master
https://developer.blender.org/rB6582215f87015f3909f318a5b8c3b5d48c968424

Cycles: Updates for new OSL 1.5 API.

Differential Revision: https://developer.blender.org/D662

Patch by Sergey and myself.

===================================================================

M	intern/cycles/kernel/osl/osl_services.cpp
M	intern/cycles/kernel/osl/osl_services.h
M	intern/cycles/render/osl.cpp

===================================================================

diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp
index 6a59a38..f541333 100644
--- a/intern/cycles/kernel/osl/osl_services.cpp
+++ b/intern/cycles/kernel/osl/osl_services.cpp
@@ -126,7 +126,7 @@ void OSLRenderServices::thread_init(KernelGlobals *kernel_globals_, OSL::Texture
 	osl_ts = osl_ts_;
 }
 
-bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time)
+bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time)
 {
 	/* this is only used for shader and object space, we don't really have
 	 * a concept of shader space, so we just use object space for both. */
@@ -156,7 +156,7 @@ bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr
 	return false;
 }
 
-bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time)
+bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform, float time)
 {
 	/* this is only used for shader and object space, we don't really have
 	 * a concept of shader space, so we just use object space for both. */
@@ -186,7 +186,7 @@ bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, OSL::Transform
 	return false;
 }
 
-bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, ustring from, float time)
+bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from, float time)
 {
 	KernelGlobals *kg = kernel_globals;
 
@@ -218,7 +218,7 @@ bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, ustring from, float ti
 	return false;
 }
 
-bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, ustring to, float time)
+bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to, float time)
 {
 	KernelGlobals *kg = kernel_globals;
 
@@ -250,7 +250,7 @@ bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, ustring to, fl
 	return false;
 }
 
-bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform)
+bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform)
 {
 	/* this is only used for shader and object space, we don't really have
 	 * a concept of shader space, so we just use object space for both. */
@@ -275,7 +275,7 @@ bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr
 	return false;
 }
 
-bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform)
+bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, OSL::TransformationPtr xform)
 {
 	/* this is only used for shader and object space, we don't really have
 	 * a concept of shader space, so we just use object space for both. */
@@ -300,7 +300,7 @@ bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, OSL::Transform
 	return false;
 }
 
-bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, ustring from)
+bool OSLRenderServices::get_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring from)
 {
 	KernelGlobals *kg = kernel_globals;
 
@@ -328,7 +328,7 @@ bool OSLRenderServices::get_matrix(OSL::Matrix44 &result, ustring from)
 	return false;
 }
 
-bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, ustring to)
+bool OSLRenderServices::get_inverse_matrix(OSL::ShaderGlobals *sg, OSL::Matrix44 &result, ustring to)
 {
 	KernelGlobals *kg = kernel_globals;
 	
@@ -356,7 +356,7 @@ bool OSLRenderServices::get_inverse_matrix(OSL::Matrix44 &result, ustring to)
 	return false;
 }
 
-bool OSLRenderServices::get_array_attribute(void *renderstate, bool derivatives, 
+bool OSLRenderServices::get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives, 
                                             ustring object, TypeDesc type, ustring name,
                                             int index, void *val)
 {
@@ -751,13 +751,13 @@ bool OSLRenderServices::get_background_attribute(KernelGlobals *kg, ShaderData *
 		return false;
 }
 
-bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustring object_name,
+bool OSLRenderServices::get_attribute(OSL::ShaderGlobals *sg, bool derivatives, ustring object_name,
                                       TypeDesc type, ustring name, void *val)
 {
-	if (renderstate == NULL)
+	if (sg->renderstate == NULL)
 		return false;
 
-	ShaderData *sd = (ShaderData *)renderstate;
+	ShaderData *sd = (ShaderData *)(sg->renderstate);
 	KernelGlobals *kg = sd->osl_globals;
 	bool is_curve;
 	int object;
@@ -815,12 +815,12 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
 }
 
 bool OSLRenderServices::get_userdata(bool derivatives, ustring name, TypeDesc type, 
-                                     void *renderstate, void *val)
+                                     OSL::ShaderGlobals *sg, void *val)
 {
 	return false; /* disabled by lockgeom */
 }
 
-bool OSLRenderServices::has_userdata(ustring name, TypeDesc type, void *renderstate)
+bool OSLRenderServices::has_userdata(ustring name, TypeDesc type, OSL::ShaderGlobals *sg)
 {
 	return false; /* never called by OSL */
 }
@@ -1100,7 +1100,7 @@ bool OSLRenderServices::getmessage(OSL::ShaderGlobals *sg, ustring source, ustri
 					return set_attribute_float(f, type, derivatives, val);
 				}
 
-				return get_attribute(sd, derivatives, u_empty, type, name, val);
+				return get_attribute(sg, derivatives, u_empty, type, name, val);
 			}
 		}
 	}
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
index 069722d..2100a33 100644
--- a/intern/cycles/kernel/osl/osl_services.h
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -49,27 +49,27 @@ public:
 	
 	void thread_init(KernelGlobals *kernel_globals, OSL::TextureSystem *ts);
 
-	bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
-	bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
+	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::Matrix44 &result, ustring from, float time);
-	bool get_inverse_matrix(OSL::Matrix44 &result, ustring to, float time);
+	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::Matrix44 &result, OSL::TransformationPtr xform);
-	bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform);
+	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::Matrix44 &result, ustring from);
-	bool get_inverse_matrix(OSL::Matrix44 &result, ustring from);
+	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_array_attribute(void *renderstate, bool derivatives,
+	bool get_array_attribute(OSL::ShaderGlobals *sg, bool derivatives,
 	                         ustring object, TypeDesc type, ustring name,
 	                         int index, void *val);
-	bool get_attribute(void *renderstate, bool derivatives, ustring object,
+	bool get_attribute(OSL::ShaderGlobals *sg, bool derivatives, ustring object,
 	                   TypeDesc type, ustring name, void *val);
 
 	bool get_userdata(bool derivatives, ustring name, TypeDesc type,
-	                  void *renderstate, void *val);
-	bool has_userdata(ustring name, TypeDesc type, void *renderstate);
+	                  OSL::ShaderGlobals *sg, void *val);
+	bool has_userdata(ustring name, TypeDesc type, OSL::ShaderGlobals *sg);
 
 	int pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 &center,
 	                      float radius, int max_points, bool sort, size_t *out_indices,
@@ -157,6 +157,65 @@ public:
 	static ustring u_v;
 	static ustring u_empty;
 
+#if OSL_LIBRARY_VERSION_CODE < 10500
+	bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) {
+		return get_matrix(NULL, result, xform, time);
+	}
+
+	bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time) {
+		return get_inverse_matrix(NULL, result, xform, time);
+	}
+
+	bool get_matrix(OSL::Matrix44 &result, ustring from, float time) {
+		return get_matrix(NULL, result, from, time);
+	}
+
+	bool get_inverse_matrix(OSL::Matrix44 &result, ustring to, float time) {
+		return get_inverse_matrix(NULL, result, to, time);
+	}
+
+	bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform) {
+		return get_matrix(NULL, result, xform);
+	}
+
+	bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform) {
+		return get_inverse_matrix(NULL, result, xform);
+	}
+
+	bool get_matrix(OSL::Matrix44 &result, ustring from) {
+		return get_matrix(NULL, result, from);
+	}
+
+	bool get_inverse_matrix(OSL::Matrix44 &result, ustring to) {
+		return get_inverse_matrix(NULL, result, to);
+	}
+
+	bool get_array_attribute(void *renderstate, bool derivatives,
+	                         ustring object, TypeDesc type, ustring name,
+	                         int index, void *val) {
+		OSL::ShaderGlobals sg;
+		sg.renderstate = renderstate;
+		return get_array_attribute(&sg, derivatives,
+		                           object, type, name,
+		                           index, val);
+	}
+
+	bool get_attribute(void *renderstate, bool derivatives, ustring object_name,
+	                   TypeDesc type, ustring name, void *val) {
+		OSL::ShaderGlobals sg;
+		sg.renderstate = renderstate;
+		return get_attribute(&sg, derivatives, object_name, type, name, val);
+	}
+
+	bool has_userdata(ustring name, TypeDesc type, void *renderstate) {
+		return has_userdata(

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list