[Bf-blender-cvs] SVN commit: /data/svn/repos/bf-blender [61617] trunk/lib/ darwin-9.x.universal/osl: Bump OSL to 1.7.1

Martijn Berger martijn.berger at gmail.com
Sat Feb 6 08:12:45 CET 2016


Revision: 61617
          https://developer.blender.org/rBL61617
Author:   juicyfruit
Date:     2016-02-06 07:12:44 +0000 (Sat, 06 Feb 2016)
Log Message:
-----------
Bump OSL to 1.7.1

Modified Paths:
--------------
    trunk/lib/darwin-9.x.universal/osl/include/OSL/genclosure.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/llvm_util.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/oslclosure.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/oslcomp.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/oslconfig.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/oslexec.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/oslquery.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/oslversion.h
    trunk/lib/darwin-9.x.universal/osl/include/OSL/rendererservices.h
    trunk/lib/darwin-9.x.universal/osl/lib/liboslcomp.a
    trunk/lib/darwin-9.x.universal/osl/lib/liboslexec.a
    trunk/lib/darwin-9.x.universal/osl/lib/liboslquery.a

Modified: trunk/lib/darwin-9.x.universal/osl/include/OSL/genclosure.h
===================================================================
--- trunk/lib/darwin-9.x.universal/osl/include/OSL/genclosure.h	2016-02-02 22:34:15 UTC (rev 61616)
+++ trunk/lib/darwin-9.x.universal/osl/include/OSL/genclosure.h	2016-02-06 07:12:44 UTC (rev 61617)
@@ -70,16 +70,16 @@
     { TypeDesc(TypeDesc::STRING, TypeDesc::SCALAR, TypeDesc::NOXFORM, n),(int)reckless_offsetof(st, fld), NULL, fieldsize(st, fld) }
 
 // NOTE: this keyword args have to be always at the end of the list
-#define CLOSURE_INT_KEYPARAM(key) \
-    { TypeDesc::TypeInt, 0, key, 0 }
-#define CLOSURE_FLOAT_KEYPARAM(key) \
-    { TypeDesc::TypeFloat, 0, key, 0 }
-#define CLOSURE_COLOR_KEYPARAM(key) \
-    { TypeDesc::TypeColor, 0, key, 0 }
-#define CLOSURE_VECTOR_KEYPARAM(key) \
-    { TypeDesc::TypeVector, 0, key, 0 }
-#define CLOSURE_STRING_KEYPARAM(key) \
-    { TypeDesc::TypeString, 0, key, 0 }
+#define CLOSURE_INT_KEYPARAM(st, fld, key) \
+    { TypeDesc::TypeInt, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
+#define CLOSURE_FLOAT_KEYPARAM(st, fld, key) \
+    { TypeDesc::TypeFloat, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
+#define CLOSURE_COLOR_KEYPARAM(st, fld, key) \
+    { TypeDesc::TypeColor, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
+#define CLOSURE_VECTOR_KEYPARAM(st, fld, key) \
+    { TypeDesc::TypeVector, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
+#define CLOSURE_STRING_KEYPARAM(st, fld, key) \
+    { TypeDesc::TypeString, (int)reckless_offsetof(st, fld), key, fieldsize(st, fld) }
 
 #define CLOSURE_FINISH_PARAM(st) { TypeDesc(), sizeof(st), NULL, 0 }
 

Modified: trunk/lib/darwin-9.x.universal/osl/include/OSL/llvm_util.h
===================================================================
--- trunk/lib/darwin-9.x.universal/osl/include/OSL/llvm_util.h	2016-02-02 22:34:15 UTC (rev 61616)
+++ trunk/lib/darwin-9.x.universal/osl/include/OSL/llvm_util.h	2016-02-06 07:12:44 UTC (rev 61617)
@@ -317,6 +317,9 @@
     llvm::Value *constant (const char *s) {
         return constant(OIIO::ustring(s));
     }
+    llvm::Value *constant (const std::string &s) {
+        return constant(OIIO::ustring(s));
+    }
 
     /// Return an llvm::Value for a long long that is a packed
     /// representation of a TypeDesc.
@@ -373,6 +376,10 @@
     /// the function, if any.
     llvm::Value *call_function (const char *name,
                                 llvm::Value **args, int nargs);
+    template<size_t N>
+    llvm::Value* call_function (const char *name, llvm::Value* (&args)[N]) {
+        return call_function (name, &args[0], int(N));
+    }
 
     llvm::Value *call_function (const char *name, llvm::Value *arg0) {
         return call_function (name, &arg0, 1);
@@ -456,21 +463,13 @@
     llvm::Value *op_sub (llvm::Value *a, llvm::Value *b);
     llvm::Value *op_neg (llvm::Value *a);
     llvm::Value *op_mul (llvm::Value *a, llvm::Value *b);
+    llvm::Value *op_div (llvm::Value *a, llvm::Value *b);
+    llvm::Value *op_mod (llvm::Value *a, llvm::Value *b);
     llvm::Value *op_float_to_int (llvm::Value *a);
     llvm::Value *op_int_to_float (llvm::Value *a);
     llvm::Value *op_bool_to_int (llvm::Value *a);
     llvm::Value *op_float_to_double (llvm::Value *a);
 
-    /// Generate IR code for simple a/b, but considering OSL's semantics
-    /// that x/0 = 0, not inf.
-    llvm::Value *op_make_safe_div (OIIO::TypeDesc type,
-                                   llvm::Value *a, llvm::Value *b);
-
-    /// Generate IR code for simple a mod b, but considering OSL's
-    /// semantics that x mod 0 = 0, not inf.
-    llvm::Value *op_make_safe_mod (OIIO::TypeDesc type,
-                                   llvm::Value *a, llvm::Value *b);
-
     llvm::Value *op_and (llvm::Value *a, llvm::Value *b);
     llvm::Value *op_or (llvm::Value *a, llvm::Value *b);
     llvm::Value *op_xor (llvm::Value *a, llvm::Value *b);

Modified: trunk/lib/darwin-9.x.universal/osl/include/OSL/oslclosure.h
===================================================================
--- trunk/lib/darwin-9.x.universal/osl/include/OSL/oslclosure.h	2016-02-02 22:34:15 UTC (rev 61616)
+++ trunk/lib/darwin-9.x.universal/osl/include/OSL/oslclosure.h	2016-02-06 07:12:44 UTC (rev 61617)
@@ -64,6 +64,11 @@
 
 };
 
+// Forward declarations
+struct ClosureComponent;
+struct ClosureMul;
+struct ClosureAdd;
+
 /// ClosureColor is the base class for a lightweight tree representation
 /// of OSL closures for the sake of the executing OSL shader.
 ///
@@ -85,9 +90,24 @@
 /// definitely one of the three kinds of subclasses: ClosureComponent,
 /// ClosureMul, ClosureAdd.
 struct OSLEXECPUBLIC ClosureColor {
-    enum ClosureType { COMPONENT, MUL, ADD };
+    enum ClosureID { COMPONENT_BASE_ID = 0, MUL = -1, ADD = -2 };
 
-    ClosureType type;
+    int id;
+
+    const ClosureComponent* as_comp() const {
+        DASSERT(id >= COMPONENT_BASE_ID);
+        return reinterpret_cast<const ClosureComponent*>(this);
+    }
+
+    const ClosureMul* as_mul() const {
+        DASSERT(id == MUL);
+        return reinterpret_cast<const ClosureMul*>(this);
+    }
+
+    const ClosureAdd* as_add() const {
+        DASSERT(id == ADD);
+        return reinterpret_cast<const ClosureAdd*>(this);
+    }
 };
 
 
@@ -100,36 +120,6 @@
 /// whatever type of custom primitive component it actually is.
 struct OSLEXECPUBLIC ClosureComponent : public ClosureColor
 {
-    struct Attr
-    {
-        ustring   key;
-        union {
-            int     integer;
-            float   flt;
-            float   triple[3];  // This will fake Color3 and Vec3 which C++ doesn't allow in unions
-            void   *str;        // And this fakes a ustring (not allowed in unions either)
-        }         value;
-
-        // This members are just to avoid having to typecast all the time
-        int           & integer()       { return value.integer; }
-        const int     & integer() const { return value.integer; }
-        float         & flt()           { return value.flt; }
-        const float   & flt()     const { return value.flt; }
-        Color3        & color()         { return *(Color3*)       raw_data(); }
-        const Color3  & color()   const { return *(const Color3*) raw_data(); }
-        Vec3          & vector()        { return *(Vec3*)         raw_data(); }
-        const Vec3    & vector()  const { return *(const Vec3*)   raw_data(); }
-        ustring       & str()           { return *(ustring*)      raw_data(); }
-        const ustring & str()     const { return *(const ustring*)raw_data(); }
-
-    private:
-        char*       raw_data()       { return reinterpret_cast<char*>(&value); }
-        const char* raw_data() const { return reinterpret_cast<const char*>(&value); }
-    };
-
-    int    id;       ///< Id of the component
-    int    size;     ///< Memory used by the primitive
-    int    nattrs;   ///< Number of keyword attributes
     Vec3   w;        ///< Weight of this component
     char   mem[4];   ///< Memory for the primitive
                      ///  4 is the minimum, allocation
@@ -140,9 +130,13 @@
     ///
     void *data () { return &mem; }
     const void *data () const { return &mem; }
-    /// Attributes are always allocated at the end of the data block
-    Attr *attrs() { return (Attr *)((char *)data() + size); }
-    const Attr *attrs() const { return (Attr *)((char *)data() + size); }
+
+    /// Handy methods for extracting the underlying parameters as a struct
+    template <typename T>
+    const T* as() const { return reinterpret_cast<const T*>(mem); }
+
+    template <typename T>
+    T* as() { return reinterpret_cast<const T*>(mem); }
 };
 
 

Modified: trunk/lib/darwin-9.x.universal/osl/include/OSL/oslcomp.h
===================================================================
--- trunk/lib/darwin-9.x.universal/osl/include/OSL/oslcomp.h	2016-02-02 22:34:15 UTC (rev 61616)
+++ trunk/lib/darwin-9.x.universal/osl/include/OSL/oslcomp.h	2016-02-06 07:12:44 UTC (rev 61617)
@@ -41,7 +41,7 @@
 
 class OSLCOMPPUBLIC OSLCompiler {
 public:
-    /// DEPRECATED -- it's ok to directly construct an OSLCompiler now.
+    OSL_DEPRECATED("Directly construct or new an OSLCompiler")
     static OSLCompiler *create ();
 
     OSLCompiler (ErrorHandler *errhandler=NULL);

Modified: trunk/lib/darwin-9.x.universal/osl/include/OSL/oslconfig.h
===================================================================
--- trunk/lib/darwin-9.x.universal/osl/include/OSL/oslconfig.h	2016-02-02 22:34:15 UTC (rev 61616)
+++ trunk/lib/darwin-9.x.universal/osl/include/OSL/oslconfig.h	2016-02-06 07:12:44 UTC (rev 61617)
@@ -38,15 +38,18 @@
 // Detect if we're C++11.
 //
 // Note: oslversion.h defined OSL_BUILD_CPP11 to be 1 if OSL was built
-// using C++11. In contrast, OSL_USING_CPP11 defined below will be 1 if
-// we're compiling C++11 RIGHT NOW. These two things may be the same when
-// compiling OSL, but they may not be the same if another packages is
-// compiling against OSL and using these headers (OSL may be C++11 but the
-// client package may be older, or vice versa -- use these two symbols to
-// differentiate these cases, when important).
-#if (__cplusplus >= 201103L)
-#define OSL_USING_CPP11 1
-#define OSL_USING_CPLUSPLUS11 1 /* DEPRECATED */
+// using C++11. In contrast, OSL_CPLUSPLUS_VERSION defined below will be set
+// to the right number for the C++ standard being compiled RIGHT NOW. These
+// two things may be the same when compiling OSL, but they may not be the
+// same if another packages is compiling against OSL and using these headers
+// (OSL may be C++11 but the client package may be older, or vice versa --
+// use these two symbols to differentiate these cases, when important).
+#if (__cplusplus >= 201402L)
+#  define OSL_CPLUSPLUS_VERSION  14
+#elif (__cplusplus >= 201103L)
+#  define OSL_CPLUSPLUS_VERSION  11
+#else
+#  define OSL_CPLUSPLUS_VERSION  3 /* presume C++03 */
 #endif
 
 // Symbol export defines
@@ -63,11 +66,12 @@
 #include <OpenImageIO/texture.h>
 #include <OpenImageIO/typedesc.h>
 #include <OpenImageIO/ustring.h>
+#include <OpenImageIO/platform.h>
 
 // Sort out smart pointers
-#ifdef OSL_USING_CPP11
+#if OSL_CPLUSPLUS_VERSION >= 11
 # include <memory>
-#else
+#else /* FIXME(C++11): remove this after making C++11 the baseline */
 # include <boost/shared_ptr.hpp>
 #endif
 
@@ -118,13 +122,28 @@

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list