Server application for collaborative production of 3D assets and animations.
(define-module (vfx packages intel)
  #:use-module (gnu packages)
  #:use-module (gnu packages pkg-config)
  #:use-module (gnu packages llvm)
  #:use-module (gnu packages tbb)
  #:use-module (gnu packages vulkan)
  #:use-module (gnu packages compression)
  #:use-module (gnu packages flex)
  #:use-module (gnu packages bison)
  #:use-module (gnu packages m4)
  #:use-module (gnu packages protobuf)
  #:use-module (gnu packages python)
  #:use-module (gnu packages ncurses)

  #:use-module (vfx packages base)

  #:use-module (guix)
  #:use-module (guix gexp)
  #:use-module (guix build utils)
  #:use-module (guix build-system cmake)
  #:use-module ((guix licenses) #:prefix licenses:))

(define-public vc-intrinsics
  (package
   (name "vc-intrinsics")
   (version "0.11.0")
   (source
    (origin
     (method url-fetch)
     (uri
      (string-append "https://github.com/intel/vc-intrinsics/"
		     "archive/refs/tags/v" version ".tar.gz"))
     (sha256
      (base32 "17xvh6nw42k8ivr4xybawr777njyh2n50k0mrr0nvyp7diidbb75"))))
    (build-system cmake-build-system)
    (inputs
      (list llvm-11.1 python))
    (arguments
     `(#:tests? #f
       #:configure-flags
       (list (string-append "-DLLVM_DIR="
			    (assoc-ref %build-inputs "llvm")
			    "/lib/cmake/llvm"))))
    (home-page "https://github.com/intel/vc-intrinsics")
    (synopsis "Intel VC Intrinsics")
    (description "VC Intrinsics project contains a set of new intrinsics
on top of core LLVM IR instructions that represent SIMD semantics of a
program targeting GPU.")
    (license licenses:expat)))

(define-public graphics-compiler
  (package
    (name "graphics-compiler")
    (version "1.0.13181.1")
    (source
      (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/intel/intel-graphics-compiler/"
	  	             "archive/refs/tags/igc-" version ".tar.gz"))
        (sha256
          (base32 "1k0ffsp44mxyarxpjsnp81vh59j1lkjqcsaqdwwr9ya0r3qadhi9"))))
    (build-system cmake-build-system)
    (native-inputs
      (list flex bison lld))
    (inputs
      (list llvm-11.1 clang-11 opencl-clang spirv-llvm-translator spirv-tools-3 protobuf vc-intrinsics zlib))
    (arguments
     `(#:tests? #f
       #:configure-flags
       (list "-DIGC_OPTION__SPIRV_TOOLS_MODE=Prebuilds"
	     "-DIGC_OPTION__USE_PREINSTALLED_SPIRV_HEADERS=ON"
	     "-DSPIRV_TOOLS_BUILD_STATIC=OFF"
	     "-DIGC_OPTION__VC_INTRINSICS_MODE=Source"
	     (string-append "-DVC_INTRINSICS_SRC="
			    (assoc-ref %build-inputs "vc-intrinsics")
			    "/lib/cmake/LLVM")
	     ;;(string-append "-DLLVM_EXTERNAL_SPIRV_HEADERS_SOURCE_DIR="
             ;;               (assoc-ref %build-inputs "spirv-headers"))
	     ;;(string-append "-DPKG_CONFIG_PATH="
             ;;               (assoc-ref %build-inputs "spirv-tools")
	     ;;               "/lib/pkgconfig")	     
	     )
       ;; #:phases
       ;; (modify-phases %standard-phases
       ;;   (add-before 'configure 'integrate-dependencies
       ;;     (lambda _
       ;;       (symlink "saga-gis"))))
       ))
    (home-page "https://github.com/intel/intel-graphics-compiler")
    (synopsis "Intel Graphics Compiler for OpenCL")
    (description "The Intel Graphics Compiler for OpenCL is an LLVM based
compiler for OpenCL targeting Intel Gen graphics hardware architecture.")
    (license licenses:expat)))

(define-public graphics-compute-runtime
  (package
    (name "graphics-compute-runtime")
    (version "22.49.25018.23")
    (source
      (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/intel/compute-runtime/"
	  	             "archive/refs/tags/" version ".tar.gz"))
        (sha256
          (base32 "0mznb0zsw0slylq06kmla1l3ywxnpy9aa5xh6px669si7h26w3mq"))))
    (build-system cmake-build-system)
    (native-inputs
      (list pkg-config graphics-compiler))
    ;;(inputs
    ;;  (list zlib))
    (home-page "https://github.com/intel/compute-runtime")
    (synopsis "Intel Graphics Compute Runtime for OpenCL Driver")
    (description "The Intel(R) Graphics Compute Runtime for oneAPI Level Zero
and OpenCL(TM) Driver is an open source project providing compute API support
(Level Zero, OpenCL) for Intel graphics hardware architectures (HD Graphics, Xe).")
    (license licenses:expat)))

;; (define-public llvm-for-ispc
;;   (package/inherit llvm-13
;;     (name "llvm-for-ispc")
;;     ;; (source (origin                                                                                                                                          
;;     ;;           (inherit (package-source llvm-13))
;;     ;;           (patches (cons (origin-patches (package-source llvm-13))
;;     ;; 		 	     (search-patches "vfx/patches/llvm-for-ispc-disable-A-B-A-B-and-BSWAP-in-InstCombine.patch"
;;     ;; 					     "vfx/patches/llvm-for-ispc-disable-DIArgList-in-SPIR-V.patch")))))
;;     (arguments
;;      (substitute-keyword-arguments (package-arguments llvm-13)
;;        ((#:configure-flags flags)                                                                                                                            
;;         `(list "-DCMAKE_BUILD_TYPE=Release"
;; 	       "-DLLVM_ENABLE_PROJECTS=clang"
;; 	       "-DLLVM_ENABLE_DUMP=ON"
;; 	       "-DLLVM_ENABLE_ASSERTIONS=ON"
;; 	       "-DLLVM_INSTALL_UTILS=ON"
;; 	       "-DLLVM_TARGETS_TO_BUILD=AArch64"))))))

(define-public ispc
  (package
    (name "ispc")
    (version "1.18.1")
    (source
      (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/ispc/ispc/"
	  	             "archive/refs/tags/v" version ".tar.gz"))
        (sha256
         (base32 "1dx7mkwlkbhz53353n40591kxgg482i306dn9djwhfbs3q94q02v"))
        (snippet
            #~(begin
                (use-modules (guix build utils))
                (substitute* "cmake/FindLLVM.cmake"
                  ((" NO_DEFAULT_PATH") ""))))))
    (build-system cmake-build-system)
    (native-inputs (list llvm-13 clang-13 libomp bison flex m4 python ncurses))
    ;; (inputs
    ;;   (list tbb-2020 python-2))
    (arguments
     `(#:configure-flags
       (list "--trace-expand"
             (string-append "-DCURSES_EXTRA_LIBRARY="
		            (assoc-ref %build-inputs "ncurses-with-tinfo")
                            "/lib/libtinfo.so"))))
    (home-page "https://ispc.github.io")
    (synopsis "Intel Implicit SPMD Program Compiler")
    (description "Compiler for a variant of the C programming language,
with extensions for \"single program, multiple data\" (SPMD) programming. Under
the SPMD model, the programmer writes a program that generally appears to be a
regular serial program, though the execution model is actually that a number of
program instances execute in parallel on the hardware.")
    (license licenses:bsd-3)))

(define-public open-image-denoise
  (package
    (name "open-image-denoise")
    (version "1.4.3")
    (source
      (origin
        (method url-fetch)
        (uri
 	      (string-append "https://github.com/OpenImageDenoise/oidn/"
	  	             "releases/download/v" version "/"
			     "oidn-" version ".src.tar.gz"))
        (sha256
          (base32 "0ah6mna8pn2mr7jnl5kb2qg25yqcqgqdi64jk5xddfky559f4xij"))))
    (build-system cmake-build-system)
    (native-inputs
      (list clang-15 ispc))
    (inputs
      (list tbb-2020 python-2))
    (home-page "https://www.openimagedenoise.org")
    (synopsis "Intel High-Performance Denoising Library for Ray Tracing")
    (description "High-performance, high-quality denoising filters for images
rendered with ray tracing. Intel Open Image Denoise is part of the Intel
oneAPI Rendering Toolkit.")
    (license licenses:asl2.0)))