Merge pull request #158534 from reckenrode/moltenvk

This commit is contained in:
Sandro 2022-02-17 13:42:40 +01:00 committed by GitHub
commit 59e6eceb2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 579 additions and 10 deletions

View file

@ -10121,6 +10121,20 @@
githubId = 16624;
name = "Maxim Ivanov";
};
reckenrode = {
name = "Randy Eckenrode";
email = "randy@largeandhighquality.com";
matrix = "@reckenrode:matrix.org";
github = "reckenrode";
githubId = 7413633;
keys = [
# compare with https://keybase.io/reckenrode
{
longkeyid = "ed25519/0xFBF19A982CCE0048";
fingerprint = "01D7 5486 3A6D 64EA AC77 0D26 FBF1 9A98 2CCE 0048";
}
];
};
redfish64 = {
email = "engler@gmail.com";
github = "redfish64";

View file

@ -15,7 +15,7 @@ stdenv.mkDerivation rec {
meta = with lib; {
description = "Vulkan Header files and API registry";
homepage = "https://www.lunarg.com";
platforms = platforms.linux;
platforms = platforms.unix;
license = licenses.asl20;
maintainers = [ maintainers.ralith ];
};

View file

@ -1,5 +1,5 @@
{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, libX11, libxcb
, libXrandr, wayland, vulkan-headers, addOpenGLRunpath }:
, libXrandr, wayland, moltenvk, vulkan-headers, addOpenGLRunpath }:
stdenv.mkDerivation rec {
pname = "vulkan-loader";
@ -14,12 +14,12 @@ stdenv.mkDerivation rec {
});
nativeBuildInputs = [ cmake pkg-config ];
buildInputs = [ libX11 libxcb libXrandr vulkan-headers wayland ];
buildInputs = [ vulkan-headers ]
++ lib.optionals (!stdenv.isDarwin) [ libX11 libxcb libXrandr wayland ];
cmakeFlags = [
"-DSYSCONFDIR=${addOpenGLRunpath.driverLink}/share"
"-DCMAKE_INSTALL_INCLUDEDIR=${vulkan-headers}/include"
];
cmakeFlags = [ "-DCMAKE_INSTALL_INCLUDEDIR=${vulkan-headers}/include" ]
++ lib.optional stdenv.isDarwin "-DSYSCONFDIR=${moltenvk}/share"
++ lib.optional stdenv.isLinux "-DSYSCONFDIR=${addOpenGLRunpath.driverLink}/share";
outputs = [ "out" "dev" ];
@ -35,7 +35,7 @@ stdenv.mkDerivation rec {
meta = with lib; {
description = "LunarG Vulkan loader";
homepage = "https://www.lunarg.com";
platforms = platforms.linux;
platforms = platforms.unix;
license = licenses.asl20;
maintainers = [ maintainers.ralith ];
};

View file

@ -19,7 +19,7 @@ stdenv.mkDerivation rec {
inherit (src.meta) homepage;
description = "The SPIR-V Tools project provides an API and commands for processing SPIR-V modules";
license = licenses.asl20;
platforms = platforms.linux;
platforms = platforms.unix;
maintainers = [ maintainers.ralith ];
};
}

View file

@ -0,0 +1,146 @@
diff --git a/MoltenVK/MoltenVK.xcodeproj/project.pbxproj b/MoltenVK/MoltenVK.xcodeproj/project.pbxproj
index c23afce4..12ac12f4 100644
--- a/MoltenVK/MoltenVK.xcodeproj/project.pbxproj
+++ b/MoltenVK/MoltenVK.xcodeproj/project.pbxproj
@@ -365,13 +365,6 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
- 2F21D82E24983488009BEA5F /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = A9C86CB61C55B8350096CAF2 /* MoltenVKShaderConverter.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = 2FEA0CFF2490381A00EEF3AD;
- remoteInfo = "MoltenVKSPIRVToMSLConverter-tvOS";
- };
2FEA0D1B249040CA00EEF3AD /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = A9C86CB61C55B8350096CAF2 /* MoltenVKShaderConverter.xcodeproj */;
@@ -400,20 +393,6 @@
remoteGlobalIDString = A93903C71C57E9ED00FE90DC;
remoteInfo = "MVKSPIRVToMSLConverter-macOS";
};
- A981499A1FB6B9CF005F00B4 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = A9C86CB61C55B8350096CAF2 /* MoltenVKShaderConverter.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = A93903B81C57E9D700FE90DC;
- remoteInfo = "MVKSPIRVToMSLConverter-iOS";
- };
- A9B1C7F4251AA5AF001D12CC /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = A9C86CB61C55B8350096CAF2 /* MoltenVKShaderConverter.xcodeproj */;
- proxyType = 1;
- remoteGlobalIDString = A9092A8C1A81717B00051823;
- remoteInfo = MoltenVKShaderConverter;
- };
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
@@ -1019,7 +998,6 @@
buildRules = (
);
dependencies = (
- 2F21D82F24983488009BEA5F /* PBXTargetDependency */,
);
name = "MoltenVK-tvOS";
productName = MoltenVK;
@@ -1039,7 +1017,6 @@
buildRules = (
);
dependencies = (
- A981499B1FB6B9CF005F00B4 /* PBXTargetDependency */,
);
name = "MoltenVK-iOS";
productName = MoltenVK;
@@ -1059,7 +1036,6 @@
buildRules = (
);
dependencies = (
- A9B1C7F5251AA5AF001D12CC /* PBXTargetDependency */,
);
name = "MoltenVK-macOS";
productName = MoltenVK;
@@ -1476,24 +1452,6 @@
};
/* End PBXSourcesBuildPhase section */
-/* Begin PBXTargetDependency section */
- 2F21D82F24983488009BEA5F /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = "MoltenVKSPIRVToMSLConverter-tvOS";
- targetProxy = 2F21D82E24983488009BEA5F /* PBXContainerItemProxy */;
- };
- A981499B1FB6B9CF005F00B4 /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = "MVKSPIRVToMSLConverter-iOS";
- targetProxy = A981499A1FB6B9CF005F00B4 /* PBXContainerItemProxy */;
- };
- A9B1C7F5251AA5AF001D12CC /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- name = MoltenVKShaderConverter;
- targetProxy = A9B1C7F4251AA5AF001D12CC /* PBXContainerItemProxy */;
- };
-/* End PBXTargetDependency section */
-
/* Begin XCBuildConfiguration section */
2FEA0AB824902F9F00EEF3AD /* Debug */ = {
isa = XCBuildConfiguration;
@@ -1586,11 +1544,12 @@
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_MASTER_OBJECT_FILE = YES;
HEADER_SEARCH_PATHS = (
- "\"$(SRCROOT)/include\"",
- "\"$(SRCROOT)/../MoltenVKShaderConverter\"",
- "\"$(SRCROOT)/../MoltenVKShaderConverter/SPIRV-Cross\"",
- "\"$(SRCROOT)/../External/cereal/include\"",
- "\"${BUILT_PRODUCTS_DIR}\"",
+ "@@sourceRoot@@/outputs/include",
+ "@@sourceRoot@@/outputs/include/simd_workaround",
+ "@@sourceRoot@@/MoltenVKShaderConverter",
+ "@@cereal@@/include",
+ "@@spirv-cross@@/include/spirv_cross",
+ "@@vulkan-headers@@/include",
);
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACH_O_TYPE = staticlib;
@@ -1600,6 +1559,10 @@
MVK_SKIP_DYLIB = "";
"MVK_SKIP_DYLIB[sdk=appletvsimulator*]" = YES;
"MVK_SKIP_DYLIB[sdk=iphonesimulator*]" = YES;
+ OTHER_CFLAGS = (
+ "-isystem",
+ "@@libcxx@@/include/c++/v1",
+ );
PRELINK_LIBS = "${CONFIGURATION_BUILD_DIR}/libMoltenVKShaderConverter.a";
PRODUCT_NAME = MoltenVK;
SKIP_INSTALL = YES;
@@ -1658,11 +1621,12 @@
GCC_WARN_UNUSED_VARIABLE = YES;
GENERATE_MASTER_OBJECT_FILE = YES;
HEADER_SEARCH_PATHS = (
- "\"$(SRCROOT)/include\"",
- "\"$(SRCROOT)/../MoltenVKShaderConverter\"",
- "\"$(SRCROOT)/../MoltenVKShaderConverter/SPIRV-Cross\"",
- "\"$(SRCROOT)/../External/cereal/include\"",
- "\"${BUILT_PRODUCTS_DIR}\"",
+ "@@sourceRoot@@/outputs/include",
+ "@@sourceRoot@@/outputs/include/simd_workaround",
+ "@@sourceRoot@@/MoltenVKShaderConverter",
+ "@@cereal@@/include",
+ "@@spirv-cross@@/include/spirv_cross",
+ "@@vulkan-headers@@/include",
);
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACH_O_TYPE = staticlib;
@@ -1672,6 +1636,10 @@
MVK_SKIP_DYLIB = "";
"MVK_SKIP_DYLIB[sdk=appletvsimulator*]" = YES;
"MVK_SKIP_DYLIB[sdk=iphonesimulator*]" = YES;
+ OTHER_CFLAGS = (
+ "-isystem",
+ "@@libcxx@@/include/c++/v1",
+ );
PRELINK_LIBS = "${CONFIGURATION_BUILD_DIR}/libMoltenVKShaderConverter.a";
PRODUCT_NAME = MoltenVK;
SKIP_INSTALL = YES;

View file

@ -0,0 +1,180 @@
diff --git a/MoltenVKShaderConverter/MoltenVKShaderConverter.xcodeproj/project.pbxproj b/MoltenVKShaderConverter/MoltenVKShaderConverter.xcodeproj/project.pbxproj
index c7842b63..d55f73ed 100644
--- a/MoltenVKShaderConverter/MoltenVKShaderConverter.xcodeproj/project.pbxproj
+++ b/MoltenVKShaderConverter/MoltenVKShaderConverter.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 52;
+ objectVersion = 48;
objects = {
/* Begin PBXBuildFile section */
@@ -33,9 +33,6 @@
A920A8AC251B75B70076851C /* GLSLToSPIRVConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A920A8A2251B75B70076851C /* GLSLToSPIRVConverter.h */; };
A920A8AD251B75B80076851C /* GLSLToSPIRVConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A920A8A2251B75B70076851C /* GLSLToSPIRVConverter.h */; };
A920A8AE251B75B80076851C /* GLSLToSPIRVConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = A920A8A2251B75B70076851C /* GLSLToSPIRVConverter.h */; };
- A920A8AF251B77900076851C /* glslang.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A98386FD24EEE93700199A05 /* glslang.xcframework */; };
- A920A8B0251B77910076851C /* glslang.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A98386FD24EEE93700199A05 /* glslang.xcframework */; };
- A920A8B1251B77920076851C /* glslang.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A98386FD24EEE93700199A05 /* glslang.xcframework */; };
A925B71B1C78DEB2006E7ECD /* libMoltenVKShaderConverter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A93903C71C57E9ED00FE90DC /* libMoltenVKShaderConverter.a */; };
A928C9191D0488DC00071B88 /* SPIRVConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = A928C9171D0488DC00071B88 /* SPIRVConversion.h */; };
A928C91A1D0488DC00071B88 /* SPIRVConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = A928C9171D0488DC00071B88 /* SPIRVConversion.h */; };
@@ -55,12 +52,6 @@
A97CC7411C7527F3004A5C7E /* MoltenVKShaderConverterTool.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A97CC73E1C7527F3004A5C7E /* MoltenVKShaderConverterTool.cpp */; };
A98149681FB6A98A005F00B4 /* MVKStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = A98149651FB6A98A005F00B4 /* MVKStrings.h */; };
A98149691FB6A98A005F00B4 /* MVKStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = A98149651FB6A98A005F00B4 /* MVKStrings.h */; };
- A98386FA24EEE91A00199A05 /* SPIRVCross.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A98386F824EEE91A00199A05 /* SPIRVCross.xcframework */; };
- A98386FB24EEE91A00199A05 /* SPIRVCross.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A98386F824EEE91A00199A05 /* SPIRVCross.xcframework */; };
- A98386FC24EEE91A00199A05 /* SPIRVCross.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A98386F824EEE91A00199A05 /* SPIRVCross.xcframework */; };
- A983870724EEE94800199A05 /* SPIRVTools.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A983870224EEE94800199A05 /* SPIRVTools.xcframework */; };
- A983870824EEE94800199A05 /* SPIRVTools.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A983870224EEE94800199A05 /* SPIRVTools.xcframework */; };
- A983870924EEE94800199A05 /* SPIRVTools.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = A983870224EEE94800199A05 /* SPIRVTools.xcframework */; };
A9A14E332244388700C080F3 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9A14E322244388700C080F3 /* Metal.framework */; };
A9B51BDD225E98BB00AC74D2 /* MVKOSExtensions.mm in Sources */ = {isa = PBXBuildFile; fileRef = A9B51BDB225E98BB00AC74D2 /* MVKOSExtensions.mm */; };
A9F042B21FB4D060009FCCB8 /* MVKCommonEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = A9F042AA1FB4D060009FCCB8 /* MVKCommonEnvironment.h */; };
@@ -115,9 +106,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- A983870824EEE94800199A05 /* SPIRVTools.xcframework in Frameworks */,
- A98386FB24EEE91A00199A05 /* SPIRVCross.xcframework in Frameworks */,
- A920A8B0251B77910076851C /* glslang.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -134,9 +122,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- A983870724EEE94800199A05 /* SPIRVTools.xcframework in Frameworks */,
- A98386FA24EEE91A00199A05 /* SPIRVCross.xcframework in Frameworks */,
- A920A8AF251B77900076851C /* glslang.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -144,9 +129,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- A983870924EEE94800199A05 /* SPIRVTools.xcframework in Frameworks */,
- A98386FC24EEE91A00199A05 /* SPIRVCross.xcframework in Frameworks */,
- A920A8B1251B77920076851C /* glslang.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -313,7 +295,7 @@
A925B71D1C78DEBF006E7ECD /* PBXTargetDependency */,
);
name = MoltenVKShaderConverter;
- productName = MetalGLShaderConverterTool;
+ productName = MoltenVKShaderConverter;
productReference = A964BD5F1C57EFBD00D930D8 /* MoltenVKShaderConverter */;
productType = "com.apple.product-type.tool";
};
@@ -349,7 +331,7 @@
dependencies = (
);
name = "MoltenVKShaderConverter-macOS";
- productName = "MetalGLShaderConverter-macOS";
+ productName = MoltenVKShaderConverter;
productReference = A93903C71C57E9ED00FE90DC /* libMoltenVKShaderConverter.a */;
productType = "com.apple.product-type.library.static";
};
@@ -536,6 +518,17 @@
OTHER_LDFLAGS = (
"-ObjC",
"-w",
+ "-lMachineIndependent",
+ "-lGenericCodeGen",
+ "-lOGLCompiler",
+ "-lglslang",
+ "-lOSDependent",
+ "-lSPIRV",
+ "-lSPIRV-Tools",
+ "-lSPIRV-Tools-opt",
+ "-lspirv-cross-msl",
+ "-lspirv-cross-core",
+ "-lspirv-cross-glsl",
);
SDKROOT = macosx;
};
@@ -548,6 +541,17 @@
OTHER_LDFLAGS = (
"-ObjC",
"-w",
+ "-lMachineIndependent",
+ "-lGenericCodeGen",
+ "-lOGLCompiler",
+ "-lglslang",
+ "-lOSDependent",
+ "-lSPIRV",
+ "-lSPIRV-Tools",
+ "-lSPIRV-Tools-opt",
+ "-lspirv-cross-msl",
+ "-lspirv-cross-core",
+ "-lspirv-cross-glsl",
);
SDKROOT = macosx;
};
@@ -624,15 +628,24 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)\"",
- "\"$(SRCROOT)/SPIRV-Cross\"",
- "\"$(SRCROOT)/glslang\"",
- "\"$(SRCROOT)/glslang/External/spirv-tools/include\"",
+ "@@sourceRoot@@/Common",
+ "@@glslang@@/include",
+ "@@spirv-cross@@/include/spirv_cross",
+ "@@spirv-tools@@/include",
+ "@@spirv-headers@@/include/spirv/unified1/",
);
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ LIBRARY_SEARCH_PATHS = (
+ "@@glslang@@/lib",
+ "@@spirv-cross@@/lib",
+ "@@spirv-tools@@/lib",
+ );
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.11;
+ OTHER_CFLAGS = (
+ "-isystem",
+ "@@libcxx@@/include/c++/v1",
+ );
PRODUCT_NAME = MoltenVKShaderConverter;
SKIP_INSTALL = YES;
TVOS_DEPLOYMENT_TARGET = 9.0;
@@ -683,15 +696,24 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
HEADER_SEARCH_PATHS = (
- "$(inherited)",
- "\"$(SRCROOT)\"",
- "\"$(SRCROOT)/SPIRV-Cross\"",
- "\"$(SRCROOT)/glslang\"",
- "\"$(SRCROOT)/glslang/External/spirv-tools/include\"",
+ "@@sourceRoot@@/Common",
+ "@@glslang@@/include",
+ "@@spirv-cross@@/include/spirv_cross",
+ "@@spirv-tools@@/include",
+ "@@spirv-headers@@/include/spirv/unified1/",
);
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ LIBRARY_SEARCH_PATHS = (
+ "@@glslang@@/lib",
+ "@@spirv-cross@@/lib",
+ "@@spirv-tools@@/lib",
+ );
MACH_O_TYPE = staticlib;
MACOSX_DEPLOYMENT_TARGET = 10.11;
+ OTHER_CFLAGS = (
+ "-isystem",
+ "@@libcxx@@/include/c++/v1",
+ );
PRODUCT_NAME = MoltenVKShaderConverter;
SKIP_INSTALL = YES;
TVOS_DEPLOYMENT_TARGET = 9.0;

View file

@ -0,0 +1,13 @@
diff --git a/Scripts/create_dylib.sh b/Scripts/create_dylib.sh
index 5ba75f67..a0405067 100755
--- a/Scripts/create_dylib.sh
+++ b/Scripts/create_dylib.sh
@@ -57,6 +57,8 @@ ${MVK_SAN} \
-framework Metal ${MVK_IOSURFACE_FWK} -framework ${MVK_UX_FWK} -framework QuartzCore -framework CoreGraphics ${MVK_IOKIT_FWK} -framework Foundation \
--library-directory ${MVK_USR_LIB_DIR} \
-o "${MVK_BUILT_PROD_DIR}/dynamic/${MVK_DYLIB_NAME}" \
+-L@@sourceRoot@@/outputs/lib -L@@glslang@@/lib -L@@spirv-tools@@/lib -L@@spirv-cross@@/lib \
+-lobjc -lMoltenVKShaderConverter -lGenericCodeGen -lMachineIndependent -lOGLCompiler -lOSDependent -lSPIRV -lSPIRV-Tools -lSPIRV-Tools-opt -lspirv-cross-core -lspirv-cross-glsl -lspirv-cross-msl -lspirv-cross-reflect \
-force_load "${MVK_BUILT_PROD_DIR}/lib${PRODUCT_NAME}.a"
if test "$CONFIGURATION" = Debug; then

View file

@ -0,0 +1,200 @@
{ lib
, stdenv
, stdenvNoCC
, fetchurl
, fetchFromGitHub
, cctools
, sigtool
, cereal
, glslang
, spirv-cross
, spirv-headers
, spirv-tools
, vulkan-headers
, AppKit
, Foundation
, Metal
, QuartzCore
}:
# Even though the derivation is currently impure, it is written to build successfully using
# `xcbuild`. Once the SDK on x86_64-darwin is updated, it should be possible to switch from being
# an impure derivation.
#
# The `sandboxProfile` was copied from the iTerm2 derivation. In order to build you at least need
# the `sandbox` option set to `relaxed` or `false`. Xcode should be available in the default
# location.
let
libcxx.dev = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr";
in
stdenvNoCC.mkDerivation rec {
pname = "MoltenVK";
version = "1.1.7";
buildInputs = [
AppKit
Foundation
Metal
QuartzCore
];
outputs = [ "out" "bin" ];
# MoltenVK requires specific versions of its dependencies.
# Pin them here except for cereal, which is four years old and has several CVEs.
passthru = {
glslang = (glslang.overrideAttrs (old: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "glslang";
rev = "2742e959347ae2fac58acd0d022c92a0ff1f24bf";
hash = "sha256-Q0sk4bPj/skPat1n4GJyuXAlZqpfEn4Td8Bm2IBNUqE=";
};
})).override {
inherit (passthru) spirv-headers spirv-tools;
};
spirv-cross = spirv-cross.overrideAttrs (old: {
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
"-DSPIRV_CROSS_NAMESPACE_OVERRIDE=MVK_spirv_cross"
];
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Cross";
rev = "131278458ea8eebe6a6e9c476fbcf71278726e1a";
hash = "sha256-LrRYDFGv3Zxfy4qRNLwM2OOa8jbcq0ttPxDamCH21xU=";
};
});
spirv-headers = spirv-headers.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "spirv-headers";
rev = "b42ba6d92faf6b4938e6f22ddd186dbdacc98d78";
hash = "sha256-ks9JCj5rj+Xu++7z5RiHDkU3/sFXhcScw8dATfB/ot0";
};
});
spirv-tools = (spirv-tools.overrideAttrs (old: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "spirv-tools";
rev = "45dd184c790d6bfc78a5a74a10c37e888b1823fa";
hash = "sha256-DSqZlwfNTbN4fyIrVBKltm5U2U4GthW3L+Ksw4lSVG8=";
};
meta = old.meta // {
platforms = old.meta.platforms ++ lib.platforms.darwin;
};
})).override {
inherit (passthru) spirv-headers;
};
vulkan-headers = vulkan-headers.overrideAttrs (old: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "Vulkan-Headers";
rev = "1dace16d8044758d32736eb59802d171970e9448";
hash = "sha256-C6YgxWcinI3QumcWmoJaiTAf0u6jSDc8sCIarn2t04k";
};
meta = old.meta // {
platforms = old.meta.platforms ++ lib.platforms.darwin;
};
});
};
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "MoltenVK";
rev = "v${version}";
hash = "sha256-I9QcjyE09qclWPCLAVfKEaifP89q1ftLh9cXWy9m7kw=";
};
patches = [
# Specify the libraries to link directly since XCFrameworks are not being used.
./createDylib.patch
# Move `mvkGitRevDerived.h` to a stable location
./gitRevHeaderStability.patch
# Fix the Xcode projects to play nicely with `xcbuild`.
./MoltenVKShaderConverter.xcodeproj.patch
./MoltenVK.xcodeproj.patch
];
postPatch = ''
substituteInPlace MoltenVKShaderConverter/MoltenVKShaderConverter.xcodeproj/project.pbxproj \
--replace @@sourceRoot@@ $(pwd) \
--replace @@libcxx@@ "${libcxx.dev}" \
--replace @@glslang@@ "${passthru.glslang}" \
--replace @@spirv-cross@@ "${passthru.spirv-cross}" \
--replace @@spirv-tools@@ "${passthru.glslang.spirv-tools}" \
--replace @@spirv-headers@@ "${passthru.glslang.spirv-headers}"
substituteInPlace MoltenVK/MoltenVK.xcodeproj/project.pbxproj \
--replace @@sourceRoot@@ $(pwd) \
--replace @@libcxx@@ "${libcxx.dev}" \
--replace @@cereal@@ "${cereal}" \
--replace @@spirv-cross@@ "${passthru.spirv-cross}" \
--replace @@vulkan-headers@@ "${passthru.vulkan-headers}"
substituteInPlace Scripts/create_dylib.sh \
--replace @@sourceRoot@@ $(pwd) \
--replace @@glslang@@ "${passthru.glslang}" \
--replace @@spirv-tools@@ "${passthru.glslang.spirv-tools}" \
--replace @@spirv-cross@@ "${passthru.spirv-cross}"
substituteInPlace Scripts/gen_moltenvk_rev_hdr.sh \
--replace @@sourceRoot@@ $(pwd) \
--replace '$(git rev-parse HEAD)' ${src.rev}
'';
dontConfigure = true;
buildPhase = ''
# Build each project on its own because `xcbuild` fails to build `MoltenVKPackaging.xcodeproj`.
derived_data_path=$(pwd)/DerivedData
pushd MoltenVKShaderConverter
/usr/bin/xcodebuild build \
-jobs $NIX_BUILD_CORES \
-derivedDataPath "$derived_data_path" \
-configuration Release \
-project MoltenVKShaderConverter.xcodeproj \
-scheme MoltenVKShaderConverter \
-arch ${stdenv.targetPlatform.darwinArch}
popd
mkdir -p outputs/bin outputs/lib
declare -A outputs=( [MoltenVKShaderConverter]=bin [libMoltenVKShaderConverter.a]=lib )
for output in "''${!outputs[@]}"; do
cp DerivedData/Build/Products/Release/$output "outputs/''${outputs[$output]}/$output"
done
pushd MoltenVK
/usr/bin/xcodebuild build \
-jobs $NIX_BUILD_CORES \
-derivedDataPath "$derived_data_path" \
-configuration Release \
-project MoltenVK.xcodeproj \
-scheme MoltenVK-macOS \
-arch ${stdenv.targetPlatform.darwinArch}
popd
cp DerivedData/Build/Products/Release/dynamic/libMoltenVK.dylib outputs/lib/libMoltenVK.dylib
'';
installPhase = ''
mkdir -p "$out/lib" "$out/share/vulkan/icd.d" "$bin/bin"
cp outputs/bin/MoltenVKShaderConverter "$bin/bin/"
cp outputs/lib/libMoltenVK.dylib "$out/lib/"
${cctools}/bin/install_name_tool -id "$out/lib/libMoltenVK.dylib" "$out/lib/libMoltenVK.dylib"
# FIXME: https://github.com/NixOS/nixpkgs/issues/148189
/usr/bin/codesign -s - -f "$out/lib/libMoltenVK.dylib"
install -m644 MoltenVK/icd/MoltenVK_icd.json "$out/share/vulkan/icd.d/MoltenVK_icd.json"
substituteInPlace $out/share/vulkan/icd.d/MoltenVK_icd.json \
--replace ./libMoltenVK.dylib "$out/share/vulkan/icd.d/MoltenVK_icd.json"
'';
sandboxProfile = ''
(allow file-read* file-write* process-exec mach-lookup)
; block homebrew dependencies
(deny file-read* file-write* process-exec mach-lookup (subpath "/usr/local") (with no-log))
'';
meta = {
description = "A Vulkan Portability implementation built on top of Apples Metal API";
homepage = "https://github.com/KhronosGroup/MoltenVK";
changelog = "https://github.com/KhronosGroup/MoltenVK/releases";
maintainers = [ lib.maintainers.reckenrode ];
license = lib.licenses.asl20;
platforms = lib.platforms.darwin;
};
}

View file

@ -0,0 +1,14 @@
diff --git a/Scripts/gen_moltenvk_rev_hdr.sh b/Scripts/gen_moltenvk_rev_hdr.sh
index c49ea4e6..9b7d13d1 100755
--- a/Scripts/gen_moltenvk_rev_hdr.sh
+++ b/Scripts/gen_moltenvk_rev_hdr.sh
@@ -2,7 +2,7 @@
# Record the MoltenVK GIT revision as a derived header file suitable for including in a build
MVK_GIT_REV=$(git rev-parse HEAD)
-MVK_HDR_FILE="${BUILT_PRODUCTS_DIR}/mvkGitRevDerived.h"
+MVK_HDR_FILE="@@sourceRoot@@/outputs/include/mvkGitRevDerived.h"
+mkdir -p $(dirname ${MVK_HDR_FILE})
echo "// Auto-generated by MoltenVK" > "${MVK_HDR_FILE}"
echo "static const char* mvkRevString = \"${MVK_GIT_REV}\";" >> "${MVK_HDR_FILE}"
-

View file

@ -20402,7 +20402,7 @@ with pkgs;
vulkan-extension-layer = callPackage ../tools/graphics/vulkan-extension-layer { };
vulkan-headers = callPackage ../development/libraries/vulkan-headers { };
vulkan-loader = callPackage ../development/libraries/vulkan-loader { };
vulkan-loader = callPackage ../development/libraries/vulkan-loader { inherit (darwin) moltenvk; };
vulkan-tools = callPackage ../tools/graphics/vulkan-tools { };
vulkan-tools-lunarg = callPackage ../tools/graphics/vulkan-tools-lunarg { };
vulkan-validation-layers = callPackage ../development/tools/vulkan-validation-layers { };

View file

@ -148,6 +148,8 @@ impure-cmds // appleSourcePackages // chooseLibs // {
lsusb = callPackage ../os-specific/darwin/lsusb { };
moltenvk = callPackage ../os-specific/darwin/moltenvk { };
opencflite = callPackage ../os-specific/darwin/opencflite { };
stubs = pkgs.callPackages ../os-specific/darwin/stubs { };