Subject: Re: bug#36977: Add OpenSubdiv library, and add as Blender dependency

From: Carlo Zancanaro <[email-masked]>
Date: Sun, 11 Aug 2019 21:32:13 +1000

On Fri, Aug 09 2019, Christopher Lemmer Webber wrote:
> I was surprised to open Blender 2.80 and find that subdivision 
> surfaces (necessary for organic modeling) were doing nothing.  I 
> couldn't figure out why this was, until I found out that Blender 
> now uses OpenSubdiv for subdivision surfaces.

I gave this a go, but it didn't go as smoothly as I had hoped. I 
packaged opensubdiv, which I have attached, but adding it to the 
Blender inputs didn't cause the subdivision modifier to work. I'm 
not really able to take this any further, but this is at least 
something to start with!

>From 959496bd6461474a30ce0e28ee0f6765a7523671 Mon Sep 17 00:00:00 2001
From: Carlo Zancanaro <[email-masked]>
Date: Sun, 11 Aug 2019 21:25:14 +1000
Subject: [PATCH] gnu: Add opensubdiv.

* gnu/packages/graphics.scm (opensubdiv): New variable.
---
 gnu/packages/graphics.scm | 43 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index bc3a418e99..11ea550039 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2018 Alex Kost <[email-masked]>
 ;;; Copyright © 2018 Kei Kebreau <[email-masked]>
 ;;; Copyright © 2019 Mark H Weaver <[email-masked]>
+;;; Copyright © 2019 Carlo Zancanaro <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -77,6 +78,48 @@
   #:use-module (guix packages)
   #:use-module (guix utils))
 
+(define-public opensubdiv
+  (package
+    (name "opensubdiv")
+    (version "3.4.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_4_0.tar.gz"))
+              (sha256
+               (base32
+                "1r3ki5lql9i71c775n6d8gxix4svg9f17ck0i58wfw9kz29b4cnr"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:phases (modify-phases %standard-phases
+                  (add-before 'configure 'set-glew-location
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (setenv "GLEW_LOCATION" (assoc-ref inputs "glew"))
+                      #t))
+                  (add-before 'check 'start-xorg-server
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      ;; The test suite requires a running X server.
+                      (system (string-append (assoc-ref inputs "xorg-server")
+                                             "/bin/Xvfb :1 &"))
+                      (setenv "DISPLAY" ":1")
+                      #t)))))
+    (native-inputs
+     `(("xorg-server" ,xorg-server)))
+    (inputs
+     `(("glew" ,glew)
+       ("libxrandr" ,libxrandr)
+       ("libxcursor" ,libxcursor)
+       ("libxinerama" ,libxinerama)
+       ("libxi" ,libxi)
+       ("zlib" ,zlib)
+       ("glfw" ,glfw)))
+    (home-page "http://graphics.pixar.com/opensubdiv/")
+    (synopsis "High performance subdivision surface evaluation")
+    (description
+     "OpenSubdiv is a set of libraries that implement high performance
+subdivision surface (subdiv) evaluation on massively parallel CPU and GPU
+architectures.")
+    (license license:asl2.0)))
+
 (define-public blender
   (package
     (name "blender")
-- 
2.22.0