View | Details | Raw Unified | Return to bug 196278
Collapse All | Expand All

(-)openshadinglanguage/Makefile (-2 / +2 lines)
Lines 2-8 Link Here
2
# $FreeBSD$
2
# $FreeBSD$
3
3
4
PORTNAME=	openshadinglanguage
4
PORTNAME=	openshadinglanguage
5
PORTVERSION=	1.5.11
5
PORTVERSION=	1.5.12
6
CATEGORIES=	graphics devel
6
CATEGORIES=	graphics devel
7
7
8
MAINTAINER=	FreeBSD@Shaneware.biz
8
MAINTAINER=	FreeBSD@Shaneware.biz
Lines 21-27 Link Here
21
GH_ACCOUNT=	imageworks
21
GH_ACCOUNT=	imageworks
22
GH_PROJECT=	OpenShadingLanguage
22
GH_PROJECT=	OpenShadingLanguage
23
GH_TAGNAME=	Release-${PORTVERSION}
23
GH_TAGNAME=	Release-${PORTVERSION}
24
GH_COMMIT=	9c3ba5b
24
GH_COMMIT=	f03977a
25
25
26
CMAKE_ARGS=	-DLLVM_CONFIG:STRING="${LOCALBASE}/bin/llvm-config34"
26
CMAKE_ARGS=	-DLLVM_CONFIG:STRING="${LOCALBASE}/bin/llvm-config34"
27
USE_LDCONFIG=	yes
27
USE_LDCONFIG=	yes
(-)openshadinglanguage/distinfo (-2 / +2 lines)
Lines 1-2 Link Here
1
SHA256 (openshadinglanguage-1.5.11.tar.gz) = 756712f3a28ab0b0c304d0732703486b0f9daf023dd9f751bbad53f65efb8ec4
1
SHA256 (openshadinglanguage-1.5.12.tar.gz) = 2eeff220999503ae1f2bed6ad9979cb32550858bd694487e4d4b27e49d58e67a
2
SIZE (openshadinglanguage-1.5.11.tar.gz) = 11560150
2
SIZE (openshadinglanguage-1.5.12.tar.gz) = 11560513
(-)openshadinglanguage/files/patch-CMakeLists.txt (-31 / +7 lines)
Lines 1-6 Link Here
1
--- ./CMakeLists.txt.orig	2013-11-26 05:11:29.000000000 +1030
1
--- CMakeLists.txt.orig	2014-09-23 05:01:22 UTC
2
+++ ./CMakeLists.txt	2013-11-28 23:52:39.202491493 +1030
2
+++ CMakeLists.txt
3
@@ -10,10 +10,8 @@
3
@@ -10,10 +10,8 @@ set (OSL_LIBRARY_VERSION_RELEASE_TYPE ""
4
 set (OSO_FILE_VERSION_MAJOR 1)
4
 set (OSO_FILE_VERSION_MAJOR 1)
5
 set (OSO_FILE_VERSION_MINOR 0)
5
 set (OSO_FILE_VERSION_MINOR 0)
6
 
6
 
Lines 13-19 Link Here
13
 set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
13
 set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
14
 message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
14
 message (STATUS "Project source dir = ${PROJECT_SOURCE_DIR}")
15
 message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
15
 message (STATUS "Project build dir = ${CMAKE_BINARY_DIR}")
16
@@ -22,6 +20,8 @@
16
@@ -22,6 +20,8 @@ if ("${PROJECT_SOURCE_DIR}" STREQUAL "${
17
     message (FATAL_ERROR "Not allowed to run in-source build!")
17
     message (FATAL_ERROR "Not allowed to run in-source build!")
18
 endif ()
18
 endif ()
19
 
19
 
Lines 22-28 Link Here
22
 if (NOT CMAKE_BUILD_TYPE)
22
 if (NOT CMAKE_BUILD_TYPE)
23
     set (CMAKE_BUILD_TYPE "Release")
23
     set (CMAKE_BUILD_TYPE "Release")
24
 endif ()
24
 endif ()
25
@@ -124,12 +124,11 @@
25
@@ -139,12 +139,11 @@ if (CMAKE_COMPILER_IS_CLANG OR CMAKE_COM
26
     endif ()
26
     endif ()
27
 endif ()
27
 endif ()
28
 
28
 
Lines 40-46 Link Here
40
 
40
 
41
 set (VERBOSE OFF CACHE BOOL "Print lots of messages while compiling")
41
 set (VERBOSE OFF CACHE BOOL "Print lots of messages while compiling")
42
 set (BUILDSTATIC OFF CACHE BOOL "Build static library instead of shared")
42
 set (BUILDSTATIC OFF CACHE BOOL "Build static library instead of shared")
43
@@ -167,7 +166,6 @@
43
@@ -187,7 +186,6 @@ endif ()
44
 
44
 
45
 if (CMAKE_COMPILER_IS_CLANG AND OSL_USE_LIBCPP)
45
 if (CMAKE_COMPILER_IS_CLANG AND OSL_USE_LIBCPP)
46
     message (STATUS "Using libc++")
46
     message (STATUS "Using libc++")
Lines 48-75 Link Here
48
 endif ()
48
 endif ()
49
 
49
 
50
 set (CMAKE_MODULE_PATH
50
 set (CMAKE_MODULE_PATH
51
@@ -202,6 +200,10 @@
51
52
 
53
 message (STATUS "CMAKE_INSTALL_RPATH = ${CMAKE_INSTALL_RPATH}")
54
 
55
+# Try to detect libc++, in which case we should force use of Boost
56
+# Wave (because that avoids a nonstandard g++ extension in the other
57
+# code path).
58
+check_cxx_symbol_exists(_LIBCPP_VERSION string OSL_SYSTEM_HAS_LIBCPP)
59
 
60
 ###########################################################################
61
 if (MSVC)
62
@@ -232,6 +234,13 @@
63
 add_subdirectory (src/include)
64
 add_subdirectory (src/doc)
65
 
66
+if (USE_BOOST_WAVE)
67
+    add_definitions ("-DUSE_BOOST_WAVE")
68
+endif ()
69
+
70
+if (CMAKE_COMPILER_IS_CLANG AND OSL_SYSTEM_HAS_LIBCPP)
71
+    message (STATUS "Using libc++")
72
+endif ()
73
 
74
 
75
 #########################################################################
(-)openshadinglanguage/files/patch-src__testshade__testshade.cpp (-11 lines)
Lines 1-11 Link Here
1
--- src/testshade/testshade.cpp.orig	2014-09-23 05:01:22 UTC
2
+++ src/testshade/testshade.cpp
3
@@ -733,7 +733,7 @@ test_shade (int argc, const char *argv[]
4
         int num_layers = 0;
5
         shadingsys->getattribute (shadergroup.get(), "num_layers", num_layers);
6
         if (num_layers > 0) {
7
-            std::vector<const char *> layers (num_layers, NULL);
8
+            std::vector<const char *> layers (size_t(num_layers), NULL);
9
             shadingsys->getattribute (shadergroup.get(), "layer_names",
10
                                       TypeDesc(TypeDesc::STRING, num_layers),
11
                                       &layers[0]);
(-)openshadinglanguage/files/patch-src_include_OSL_oslexec.h (+12 lines)
Line 0 Link Here
1
--- src/include/OSL/oslexec.h.orig	2014-12-04 11:59:48 UTC
2
+++ src/include/OSL/oslexec.h
3
@@ -418,7 +418,8 @@ public:
4
     std::string getstats (int level=1) const;
5
 
6
     void register_closure (string_view name, int id, const ClosureParam *params,
7
-                           PrepareClosureFunc prepare, SetupClosureFunc setup);
8
+                           PrepareClosureFunc prepare, SetupClosureFunc setup,
9
+                           int alignment = 1);
10
     /// Query either by name or id an existing closure. If name is non
11
     /// NULL it will use it for the search, otherwise id would be used
12
     /// and the name will be placed in name if successful. Also return
(-)openshadinglanguage/files/patch-src_liboslexec_oslexec__pvt.h (+115 lines)
Line 0 Link Here
1
--- src/liboslexec/oslexec_pvt.h.orig	2014-12-04 12:01:54 UTC
2
+++ src/liboslexec/oslexec_pvt.h
3
@@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4
 #include <OpenImageIO/paramlist.h>
5
 #include <OpenImageIO/refcnt.h>
6
 
7
+#include "OSL/genclosure.h"
8
 #include "OSL/oslexec.h"
9
 #include "OSL/oslclosure.h"
10
 #include "osl_pvt.h"
11
@@ -627,13 +628,16 @@ public:
12
         std::vector<ClosureParam> params;
13
         // the needed size for the structure
14
         int                       struct_size;
15
+        // the needed alignment of the structure
16
+        int                       alignment;
17
         // Creation callbacks
18
         PrepareClosureFunc        prepare;
19
         SetupClosureFunc          setup;
20
     };
21
 
22
     void register_closure (string_view name, int id, const ClosureParam *params,
23
-                           PrepareClosureFunc prepare, SetupClosureFunc setup);
24
+                           PrepareClosureFunc prepare, SetupClosureFunc setup,
25
+                           int alignment = 1);
26
 
27
     const ClosureEntry *get_entry (ustring name) const;
28
     const ClosureEntry *get_entry (int id) const {
29
@@ -789,7 +793,8 @@ public:
30
     ustring *alloc_string_constants (size_t n) { return m_string_pool.alloc (n); }
31
 
32
     void register_closure (string_view name, int id, const ClosureParam *params,
33
-                           PrepareClosureFunc prepare, SetupClosureFunc setup);
34
+                           PrepareClosureFunc prepare, SetupClosureFunc setup,
35
+                           int alignment = 1);
36
     bool query_closure (const char **name, int *id,
37
                         const ClosureParam **params);
38
     const ClosureRegistry::ClosureEntry *find_closure(ustring name) const {
39
@@ -1049,19 +1054,24 @@ public:
40
     char * alloc(size_t size, size_t alignment=1) {
41
         // Alignment must be power of two
42
         DASSERT ((alignment & (alignment - 1)) == 0);
43
-        // Fail if beyond allocation limits or senseless alignment
44
-        if (size > BlockSize || (size & (alignment - 1)) != 0)
45
+        // Fail if beyond allocation limits (we make sure there's enough space
46
+        // for alignment padding here as well).
47
+        if (size + alignment - 1 > BlockSize)
48
             return NULL;
49
-        m_block_offset -= (m_block_offset & (alignment - 1)); // Fix up alignment
50
-        if (size <= m_block_offset) {
51
+        // Fix up alignment
52
+        size_t alignment_offset = alignment_offset_calc(alignment);
53
+        if (size + alignment_offset <= m_block_offset) {
54
             // Enough space in current block
55
-            m_block_offset -= size;
56
+            m_block_offset -= size + alignment_offset;
57
         } else {
58
             // Need to allocate a new block
59
             m_current_block++;
60
             m_block_offset = BlockSize - size;
61
             if (m_blocks.size() == m_current_block)
62
                 m_blocks.push_back(new char[BlockSize]);
63
+            alignment_offset = alignment_offset_calc(alignment);
64
+            DASSERT (m_block_offset >= alignment_offset);
65
+            m_block_offset -= alignment_offset;
66
         }
67
         return m_blocks[m_current_block] + m_block_offset;
68
     }
69
@@ -1069,6 +1079,10 @@ public:
70
     void clear () { m_current_block = 0; m_block_offset = BlockSize; }
71
 
72
 private:
73
+    inline size_t alignment_offset_calc(size_t alignment) {
74
+        return (((uintptr_t)m_blocks[m_current_block] + m_block_offset) & (alignment - 1));
75
+    }
76
+    
77
     std::vector<char *> m_blocks;
78
     size_t              m_current_block;
79
     size_t              m_block_offset;
80
@@ -1243,7 +1257,9 @@ public:
81
     ClosureComponent * closure_component_allot(int id, size_t prim_size, int nattrs) {
82
         size_t needed = sizeof(ClosureComponent) + (prim_size >= 4 ? prim_size - 4 : 0)
83
                                                  + sizeof(ClosureComponent::Attr) * nattrs;
84
-        ClosureComponent *comp = (ClosureComponent *) m_closure_pool.alloc(needed);
85
+        int alignment = m_shadingsys.find_closure(id)->alignment;
86
+        size_t alignment_offset = closure_alignment_offset_calc(alignment);
87
+        ClosureComponent *comp = (ClosureComponent *) (m_closure_pool.alloc(needed + alignment_offset, alignment) + alignment_offset);
88
         comp->type = ClosureColor::COMPONENT;
89
         comp->id = id;
90
         comp->size = prim_size;
91
@@ -1258,7 +1274,9 @@ public:
92
         // Allocate the component and the mul back to back
93
         size_t needed = sizeof(ClosureComponent) + (prim_size >= 4 ? prim_size - 4 : 0)
94
                                                  + sizeof(ClosureComponent::Attr) * nattrs;
95
-        ClosureComponent *comp = (ClosureComponent *) m_closure_pool.alloc(needed);
96
+        int alignment = m_shadingsys.find_closure(id)->alignment;
97
+        size_t alignment_offset = closure_alignment_offset_calc(alignment);
98
+        ClosureComponent *comp = (ClosureComponent *) (m_closure_pool.alloc(needed + alignment_offset, alignment) + alignment_offset);
99
         comp->type = ClosureColor::COMPONENT;
100
         comp->id = id;
101
         comp->size = prim_size;
102
@@ -1409,6 +1427,13 @@ private:
103
     // Buffering of error messages and printfs
104
     typedef std::pair<ErrorHandler::ErrCode, std::string> ErrorItem;
105
     mutable std::vector<ErrorItem> m_buffered_errors;
106
+    
107
+    // Calculate offset needed to align ClosureComponent's mem to a given alignment.
108
+    inline size_t closure_alignment_offset_calc(size_t alignment) {
109
+        return alignment == 1 ? 0 : 
110
+        alignment - (reckless_offsetof(ClosureComponent, mem) & (alignment - 1));
111
+    }
112
+    
113
 };
114
 
115
 
(-)openshadinglanguage/files/patch-src_liboslexec_shadingsys.cpp (+52 lines)
Line 0 Link Here
1
--- src/liboslexec/shadingsys.cpp.orig	2014-12-04 12:15:18 UTC
2
+++ src/liboslexec/shadingsys.cpp
3
@@ -284,9 +284,10 @@ void
4
 ShadingSystem::register_closure (string_view name, int id,
5
                                  const ClosureParam *params,
6
                                  PrepareClosureFunc prepare,
7
-                                 SetupClosureFunc setup)
8
+                                 SetupClosureFunc setup,
9
+                                 int alignment)
10
 {
11
-    return m_impl->register_closure (name, id, params, prepare, setup);
12
+    return m_impl->register_closure (name, id, params, prepare, setup, alignment);
13
 }
14
 
15
 
16
@@ -795,7 +796,8 @@ void
17
 ShadingSystemImpl::register_closure (string_view name, int id,
18
                                      const ClosureParam *params,
19
                                      PrepareClosureFunc prepare,
20
-                                     SetupClosureFunc setup)
21
+                                     SetupClosureFunc setup,
22
+                                     int alignment)
23
 {
24
     for (int i = 0; params && params[i].type != TypeDesc(); ++i) {
25
         if (params[i].key == NULL && params[i].type.size() != (size_t)params[i].field_size) {
26
@@ -803,7 +805,7 @@ ShadingSystemImpl::register_closure (str
27
             return;
28
         }
29
     }
30
-    m_closure_registry.register_closure(name, id, params, prepare, setup);
31
+    m_closure_registry.register_closure(name, id, params, prepare, setup, alignment);
32
 }
33
 
34
 
35
@@ -2474,7 +2476,8 @@ void
36
 ClosureRegistry::register_closure (string_view name, int id,
37
                                    const ClosureParam *params,
38
                                    PrepareClosureFunc prepare,
39
-                                   SetupClosureFunc setup)
40
+                                   SetupClosureFunc setup,
41
+                                   int alignment)
42
 {
43
     if (m_closure_table.size() <= (size_t)id)
44
         m_closure_table.resize(id + 1);
45
@@ -2498,6 +2501,7 @@ ClosureRegistry::register_closure (strin
46
     }
47
     entry.prepare = prepare;
48
     entry.setup = setup;
49
+    entry.alignment = alignment;
50
     m_closure_name_to_id[ustring(name)] = id;
51
 }
52
 

Return to bug 196278