Bug 222175 - [NEW PORT] graphics/vulkan-sdk and dependencies
Summary: [NEW PORT] graphics/vulkan-sdk and dependencies
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Jan Beich
URL:
Keywords: feature, needs-qa
Depends on: 221540 227423
Blocks: 222182 231248
  Show dependency treegraph
 
Reported: 2017-09-09 19:45 UTC by Greg V
Modified: 2018-09-08 22:21 UTC (History)
4 users (show)

See Also:


Attachments
The patch (19.81 KB, patch)
2017-09-09 19:45 UTC, Greg V
no flags Details | Diff
vulkan-sdk-glslang-devel-spirv-tools-devel.patch (v2) (15.19 KB, patch)
2017-09-18 15:58 UTC, Greg V
no flags Details | Diff
vulkan-update-1_0_65.patch (4.25 KB, patch)
2017-12-26 18:34 UTC, Greg V
no flags Details | Diff
vulkan-1_0_68.patch (18.73 KB, patch)
2018-02-26 23:34 UTC, Greg V
no flags Details | Diff
vulkan-1_1_70.patch (19.00 KB, patch)
2018-03-10 19:30 UTC, Greg V
no flags Details | Diff
vulkan-1_1_82.patch (28.05 KB, patch)
2018-08-07 19:24 UTC, Greg V
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg V 2017-09-09 19:45:54 UTC
Created attachment 186206 [details]
The patch

Vulkan drivers in Mesa are enabled with bug #221540.

This patch adds the graphics/vulkan-sdk port. It installs the Vulkan ICD loader that loads these drivers, as well as headers, validation layers and demos.

Its build dependencies, devel/glslang-devel and devel/spirv-tools-devel, are provided too. The git revisions in these ports are the ones listed in the vulkan-sdk source, e.g. https://github.com/KhronosGroup/Vulkan-LoaderAndValidationLayers/blob/sdk-1.0.57.0/external_revisions/glslang_revision

These two dependencies shouldn't actually be required for building without demos and tests, but the provided CMake config ALWAYS requires them.

And yes, the version of glslang actually is "Overload400-PrecQual.2000 12-Apr-2017". That's what the binary reports. No, I have no idea what they're smoking at Khronos :D
Comment 1 Jan Beich freebsd_committer 2017-09-18 11:38:56 UTC
Comment on attachment 186206 [details]
The patch

=== devel/glslang-devel ===

> +PORTNAME=	glslang-devel

Use PKGNAMESUFFIX=-devel or just drop it due to lack of stable port. As maintainer you can switch to track releases once upstream starts doing those more often.

Ditto for devel/spirv-tools-devel.

> +DISTVERSION=	Overload400-PrecQual.2000-12-Apr-2017
[...]
> +GH_TAGNAME=	d5aedc199

Maybe convert to a tag offset:

  $ git describe --tags --match 3.0 d5aedc199
  3.0-1516-gd5aedc19

would be

  DISTVERSION=	3.0-1516
  DISTVERSIONSUFFIX=	-gd5aedc19

represented as

  $ make -V PKGNAME
  glslang-devel-3.0.1516

Maybe ditto for devel/spirv-tools-devel:

  DISTVERSIONPREFIX=	v
  DISTVERSION=	2016.6-155
  DISTVERSIONSUFFIX=	-gf0fe601
  [...]
  GH_ACCOUNT=	KhronosGroup
  GH_PROJECT=	SPIRV-Tools
  GH_TUPLE=	KhronosGroup:SPIRV-Headers:2bb92e6:headers/external/spirv-headers

  $ make -V PKGNAME
  spirv-tools-2016.6.155

In both cases you'd have a monotonically increasing version for each upstream commit, sparing inventing arbitrary suffixes.

> +LICENSE=	BSD3DLABS
> +LICENSE_NAME=	Modified BSD License (3Dlabs/LunarG)
> +LICENSE_FILE=	${FILESDIR}/LICENSE
> +LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept

Doesn't look modified compared to regular variants[1]. Google copyrights are also missing. Maybe generate license text on-the-fly:

  LICENSE=	BSD3CLAUSE
  LICENSE_FILE=	${WRKDIR}/LICENSE

  post-extract:
  	${SED} '/^$$/,$$d' ${WRKSRC}/${PORTNAME}/Include/Types.h \
  		>${WRKDIR}/LICENSE

[1] https://fedoraproject.org/wiki/Licensing:BSD

> +USES=	cmake:outsource compiler:c++11-lang

Can you reindent with 8 column tabs to achieve consistent whitespace alignment?

Ditto for devel/spirv-tools-devel.

> +Khronos reference front-end for GLSL and ESSL, and sample SPIR-V generator.

A bit terse for pkg-descr. Maybe use the first paragraph from khronos.org link.

> +WWW: https://www.khronos.org/opengles/sdk/tools/Reference-Compiler/
> +WWW: https://github.com/KhronosGroup/glslang

One of those can probably be dropped given both cross-reference each other.

=== devel/spirv-tools-devel ===

Fails to build with DEVELOPER=1 set in make.conf:

====> Running Q/A tests (stage-qa)
Error: '/bin/bash' is an invalid shebang you need USES=shebangfix for 'bin/spirv-lesspipe.sh'
*** Error code 1

> +USES=	cmake:outsource compiler:c++11-lang python:2

- USES=compiler:c++11-lib instead as std::unique_ptr isn't available in libstdc++ 4.2.
- USES=python:build instead given it builds fine with "python3.6" and runtime doesn't call "python2".

Ditto for graphics/vulkan-sdk.

> +LICENSE=	APACHE20
> +LICENSE_FILE=	${WRKSRC}/LICENSE

In this case, defining LICENSE_FILE isn't necessary. Apache 2.0 is a standardized license for which there's a copy under Templates/Licenses/.

Ditto for graphics/vulkan-sdk.

=== graphics/vulkan-sdk ===

Fails to build in poudriere:

In file included from /wrkdirs/usr/ports/graphics/vulkan-sdk/work/Vulkan-LoaderAndValidationLayers-sd
k-1.0.57.0/layers/vk_layer_extension_utils.cpp:22:
In file included from /wrkdirs/usr/ports/graphics/vulkan-sdk/work/Vulkan-LoaderAndValidationLayers-sd
k-1.0.57.0/layers/vk_layer_extension_utils.h:21:
In file included from /wrkdirs/usr/ports/graphics/vulkan-sdk/work/Vulkan-LoaderAndValidationLayers-sd
k-1.0.57.0/include/vulkan/vk_layer.h:29:
/wrkdirs/usr/ports/graphics/vulkan-sdk/work/Vulkan-LoaderAndValidationLayers-sdk-1.0.57.0/layers/../include/vulkan/vulkan.h:5916:10: fatal error: 'X11/extensions/Xrandr.h' file not found
#include <X11/extensions/Xrandr.h>
         ^

http://sprunge.us/OaAM

> +XLIB_CMAKE_ON=	-DBUILD_WSI_XLIB_SUPPORT:BOOL=ON
> +XLIB_CMAKE_OFF=	-DBUILD_WSI_XLIB_SUPPORT:BOOL=OFF

Switch to _CMAKE_BOOL to improve readability.

> +-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
> ++if((CMAKE_SYSTEM_NAME STREQUAL "Linux") OR (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD"))

What about other BSDs? DragonFly is a downstream of FreeBSD Ports. Maybe switch to if(UNIX AND NOT APPLE)

Ditto in other places.

> +-    set(FALLBACK_CONFIG_DIRS "/etc/xdg" CACHE STRING
> ++    set(FALLBACK_CONFIG_DIRS "/usr/local/etc/xdg:/etc/xdg" CACHE STRING

Would it respect LOCALBASE? Maybe replace /usr/local with ${CMAKE_INSTALL_PREFIX}.

> ++if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
> ++    include_directories("/usr/local/include")
> + endif()

Better add include_directories(SYSTEM ${XCB_INCLUDE_DIR}) just after find_package(XCB) and include_directories(SYSTEM ${X11_Xlib_INCLUDE_PATH}) just after find_package(X11).

> ++++ demos/cube.cpp
[...]
> +-#elif __linux__
> ++#elif defined(__linux__) || defined(__FreeBSD__)

Maybe use #elif !defined(__APPLE__)

> ++    list(APPEND libraries PRIVATE -lrt)

On BSDs clock_gettime() is in libc. Maybe limit to if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU|SunOS)$")

> ++    if(NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
> ++        list(APPEND libraries PRIVATE -ldl)
> ++    endif()

Switch to ${CMAKE_DL_LIBS}.

> ++++ loader/loader.c
[...]
> +-#if defined(__linux__)
> ++#if defined(__linux__) || defined(__FreeBSD__)

getenv() is part of POSIX. Maybe use #ifndef _WIN32 or #if !defined(_WIN32) && !defined(__APPLE__) depending on how weird OS X is. ;)

> ++++ loader/vk_loader_platform.h
[...]
> +-#if defined(__linux__)
> ++#if defined(__linux__) || defined(__FreeBSD__)

Ditto.
Comment 2 Greg V 2017-09-18 15:58:33 UTC
Created attachment 186513 [details]
vulkan-sdk-glslang-devel-spirv-tools-devel.patch (v2)

Thanks a lot for the review! Didn't know about some things (like _CMAKE_BOOL).

Yeah, the license looks exactly like BSD3CLAUSE. I guess they just called it "modified" because they wrote their names in :D

For the ifdef, using __unix__ now, which is supposedly also NOT APPLE. By the way, Apple doesn't have Vulkan, except via a 3rd party commercial library that translates Vulkan to Apple's Metal.
Comment 3 Greg V 2017-12-26 18:34:44 UTC
Created attachment 189119 [details]
vulkan-update-1_0_65.patch

Update to 1.0.65.1 (on top of the previous patch)
Comment 4 Johannes Lundberg 2018-02-26 18:50:50 UTC
There are files like distinfo and pkg-plist missing in vulkan-sdk and the second patch does not apply. 

Please make one patch file that includes all necessary changes.
Comment 5 Greg V 2018-02-26 23:34:37 UTC
Created attachment 191036 [details]
vulkan-1_0_68.patch

Here's an update to 1.0.68, as one patch
Comment 6 Johannes Lundberg 2018-02-27 19:16:15 UTC
Build failure in poudriere

===>   Returning to build of vulkan-sdk-1.0.68.0
===========================================================================
=======================<phase: configure      >============================
===>  Configuring for vulkan-sdk-1.0.68.0
===>  Performing out-of-source build
/bin/mkdir -p /wrkdirs/usr/ports/graphics/vulkan-sdk/work/.build
-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find PythonInterp: Found unsuitable version "2.7.14", but
  required is at least "3" (found /usr/local/bin/python2.7)
Call Stack (most recent call first):
  /usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:376 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/share/cmake/Modules/FindPythonInterp.cmake:152 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:16 (find_package)


-- Configuring incomplete, errors occurred!
See also "/wrkdirs/usr/ports/graphics/vulkan-sdk/work/.build/CMakeFiles/CMakeOutput.log".
*** Error code 1

Stop.
make: stopped in /usr/ports/graphics/vulkan-sdk
=>> Cleaning up wrkdir
===>  Cleaning for vulkan-sdk-1.0.68.0
build of graphics/vulkan-sdk | vulkan-sdk-1.0.68.0 ended at Tue Feb 27 17:19:07 GMT 2018
build time: 00:00:26
!!! build failure encountered !!!
Comment 7 Greg V 2018-03-10 19:30:19 UTC
Created attachment 191374 [details]
vulkan-1_1_70.patch

Updated to version 1.1. Added python 3 requirement.
Comment 8 Greg V 2018-08-07 19:24:12 UTC
Created attachment 195987 [details]
vulkan-1_1_82.patch

Update to 1.1.82 — no longer one monolithic port, since the original repo has exploded into four :)

Note: wayland-egl is depended on from the wayland port instead of the mesa port (bug 227423).
Comment 9 Jan Beich freebsd_committer 2018-09-02 23:25:00 UTC
I don't like the spread of Vulkan SDK across different categories, especially devel/vulkan-headers vs. graphics/vulkan-loader. Is it OK to move everything under graphics/? devel/ is usually the last resort and it's hard to distinguish ports there.

https://www.freebsd.org/doc/en/books/porters-handbook/makefile-categories.html
Comment 10 commit-hook freebsd_committer 2018-09-03 17:44:16 UTC
A commit references this bug:

Author: jbeich
Date: Mon Sep  3 17:43:58 UTC 2018
New revision: 478883
URL: https://svnweb.freebsd.org/changeset/ports/478883

Log:
  Add Vulkan SDK ports

  https://www.khronos.org/vulkan/

  PR:		222175
  Tested by:	Johannes Lundberg <johalun0@gmail.com>
  Submitted by:	Greg V <greg@unrelenting.technology>

Changes:
  head/devel/Makefile
  head/devel/glslang/
  head/devel/glslang/Makefile
  head/devel/glslang/distinfo
  head/devel/glslang/pkg-descr
  head/devel/glslang/pkg-plist
  head/devel/spirv-tools/
  head/devel/spirv-tools/Makefile
  head/devel/spirv-tools/distinfo
  head/devel/spirv-tools/pkg-descr
  head/devel/spirv-tools/pkg-plist
  head/devel/vulkan-headers/
  head/devel/vulkan-headers/Makefile
  head/devel/vulkan-headers/distinfo
  head/devel/vulkan-headers/pkg-descr
  head/devel/vulkan-headers/pkg-plist
  head/devel/vulkan-tools/
  head/devel/vulkan-tools/Makefile
  head/devel/vulkan-tools/distinfo
  head/devel/vulkan-tools/files/
  head/devel/vulkan-tools/files/patch-cube_CMakeLists.txt
  head/devel/vulkan-tools/files/patch-cube_cube.cpp
  head/devel/vulkan-tools/files/patch-vulkaninfo_CMakeLists.txt
  head/devel/vulkan-tools/pkg-descr
  head/devel/vulkan-tools/pkg-plist
  head/devel/vulkan-validation-layers/
  head/devel/vulkan-validation-layers/Makefile
  head/devel/vulkan-validation-layers/distinfo
  head/devel/vulkan-validation-layers/files/
  head/devel/vulkan-validation-layers/files/patch-CMakeLists.txt
  head/devel/vulkan-validation-layers/files/patch-layers_CMakeLists.txt
  head/devel/vulkan-validation-layers/files/patch-layers_vk__loader__platform.h
  head/devel/vulkan-validation-layers/pkg-descr
  head/devel/vulkan-validation-layers/pkg-plist
  head/emulators/rpcs3/Makefile
  head/graphics/Makefile
  head/graphics/vulkan-loader/
  head/graphics/vulkan-loader/Makefile
  head/graphics/vulkan-loader/distinfo
  head/graphics/vulkan-loader/files/
  head/graphics/vulkan-loader/files/patch-CMakeLists.txt
  head/graphics/vulkan-loader/files/patch-loader_CMakeLists.txt
  head/graphics/vulkan-loader/files/patch-loader_loader.c
  head/graphics/vulkan-loader/files/patch-loader_vk__loader__platform.h
  head/graphics/vulkan-loader/pkg-descr
  head/graphics/vulkan-loader/pkg-plist
Comment 11 Jan Beich freebsd_committer 2018-09-03 17:59:24 UTC
Thanks. Landed. Renaming is slated for later. Bringing other Vulkan consumers in the tree is more important.