Move glslang and vulkan-validation-layers overrides out of all-packages

This commit is contained in:
Câju Mihai-Drosi 2020-10-14 15:47:10 +03:00
parent bda92bfad0
commit 00946dc283
3 changed files with 87 additions and 55 deletions

View file

@ -5,7 +5,36 @@
, python3
, spirv-headers
, spirv-tools
, argSpirv-tools ? null
, argSpirv-headers ? null
}:
# glslang requires custom versions of spirv-tools and spirb-headers.
# The exact versions are taken from:
# https://github.com/KhronosGroup/glslang/blob/master/known_good.json
let
localSpirv-tools = if argSpirv-tools == null
then spirv-tools.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Tools";
rev = "fd8e130510a6b002b28eee5885a9505040a9bdc9";
sha256 = "00b7xgyrcb2qq63pp3cnw5q1xqx2d9rfn65lai6n6r89s1vh3vg6";
};
})
else argSpirv-tools;
localSpirv-headers = if argSpirv-headers == null
then spirv-headers.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Headers";
rev = "f8bf11a0253a32375c32cad92c841237b96696c0";
sha256 = "1znwjy02dl9rshqzl87rqsv9mfczw7gvwfhcirbl81idahgp4p6l";
};
})
else argSpirv-headers;
in
stdenv.mkDerivation rec {
pname = "glslang";
@ -20,22 +49,23 @@ stdenv.mkDerivation rec {
# These get set at all-packages, keep onto them for child drvs
passthru = {
inherit spirv-tools spirv-headers;
spirv-tools = localSpirv-tools;
spirv-headers = localSpirv-headers;
};
nativeBuildInputs = [ cmake python3 bison jq ];
enableParallelBuilding = true;
postPatch = ''
cp --no-preserve=mode -r "${spirv-tools.src}" External/spirv-tools
ln -s "${spirv-headers.src}" External/spirv-tools/external/spirv-headers
cp --no-preserve=mode -r "${localSpirv-tools.src}" External/spirv-tools
ln -s "${localSpirv-headers.src}" External/spirv-tools/external/spirv-headers
'';
# Ensure spirv-headers and spirv-tools match exactly to what is expected
preConfigure = ''
HEADERS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools/external/spirv-headers"))[0].commit')
TOOLS_COMMIT=$(jq -r < known_good.json '.commits|map(select(.name=="spirv-tools"))[0].commit')
if [ "$HEADERS_COMMIT" != "${spirv-headers.src.rev}" ] || [ "$TOOLS_COMMIT" != "${spirv-tools.src.rev}" ]; then
if [ "$HEADERS_COMMIT" != "${localSpirv-headers.src.rev}" ] || [ "$TOOLS_COMMIT" != "${localSpirv-tools.src.rev}" ]; then
echo "ERROR: spirv-tools commits do not match expected versions: expected tools at $TOOLS_COMMIT, headers at $HEADERS_COMMIT";
exit 1;
fi

View file

@ -1,6 +1,51 @@
{ stdenv, fetchFromGitHub, cmake, writeText, python3
, vulkan-headers, vulkan-loader, glslang, spirv-headers
, pkgconfig, xlibsWrapper, libxcb, libXrandr, wayland }:
{ stdenv
, fetchFromGitHub
, cmake
, writeText
, python3
, spirv-headers
, spirv-tools
, vulkan-headers
, vulkan-loader
, glslang
, pkgconfig
, xlibsWrapper
, libxcb
, libXrandr
, wayland
}:
# vulkan-validation-layers requires a custom glslang version, while glslang requires
# custom versions for spirv-tools and spirv-headers. The git hashes required for all
# of these deps is documented upstream here:
# https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/scripts/known_good.json
let
localGlslang = (glslang.override {
argSpirv-tools = spirv-tools.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Tools";
rev = "e128ab0d624ce7beb08eb9656bb260c597a46d0a";
sha256 = "0jj8zrl3dh9fq71jc8msx3f3ifb2vjcb37nl0w4sa8sdhfff74pv";
};
});
argSpirv-headers = spirv-headers.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Headers";
rev = "ac638f1815425403e946d0ab78bac71d2bdbf3be";
sha256 = "1lkhs7pxcrfkmiizcxl0w5ajx6swwjv7w3iq586ipgh571fc75gx";
};
});
}).overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "glslang";
rev = "e00d27c6d65b7d3e72506a311d7f053da4051295";
sha256 = "00lzvzk613gpm1vsdxffmx52z3c52ijwvzk4sfhh95p71kdydhgv";
};
});
in
stdenv.mkDerivation rec {
pname = "vulkan-validation-layers";
@ -20,8 +65,8 @@ stdenv.mkDerivation rec {
];
buildInputs = [
glslang
spirv-headers
localGlslang
localGlslang.spirv-headers
vulkan-headers
vulkan-loader
libxcb
@ -32,7 +77,7 @@ stdenv.mkDerivation rec {
enableParallelBuilding = true;
cmakeFlags = [
"-DGLSLANG_INSTALL_DIR=${glslang}"
"-DGLSLANG_INSTALL_DIR=${localGlslang}"
];
# Help vulkan-loader find the validation layers

View file

@ -9094,24 +9094,7 @@ in
dotnetPackages = recurseIntoAttrs (callPackage ./dotnet-packages.nix {});
glslang = callPackage ../development/compilers/glslang {
spirv-tools = spirv-tools.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Tools";
rev = "fd8e130510a6b002b28eee5885a9505040a9bdc9";
sha256 = "00b7xgyrcb2qq63pp3cnw5q1xqx2d9rfn65lai6n6r89s1vh3vg6";
};
});
spirv-headers = spirv-headers.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Headers";
rev = "f8bf11a0253a32375c32cad92c841237b96696c0";
sha256 = "1znwjy02dl9rshqzl87rqsv9mfczw7gvwfhcirbl81idahgp4p6l";
};
});
};
glslang = callPackage ../development/compilers/glslang { };
go_bootstrap = if stdenv.isAarch64 then
srcOnly {
@ -15818,33 +15801,7 @@ in
vulkan-headers = callPackage ../development/libraries/vulkan-headers { };
vulkan-loader = callPackage ../development/libraries/vulkan-loader { };
vulkan-tools = callPackage ../tools/graphics/vulkan-tools { };
vulkan-validation-layers = callPackage ../development/tools/vulkan-validation-layers {
glslang = (glslang.override {
spirv-tools = spirv-tools.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Tools";
rev = "e128ab0d624ce7beb08eb9656bb260c597a46d0a";
sha256 = "0jj8zrl3dh9fq71jc8msx3f3ifb2vjcb37nl0w4sa8sdhfff74pv";
};
});
spirv-headers = spirv-tools.overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "SPIRV-Headers";
rev = "ac638f1815425403e946d0ab78bac71d2bdbf3be";
sha256 = "1lkhs7pxcrfkmiizcxl0w5ajx6swwjv7w3iq586ipgh571fc75gx";
};
});
}).overrideAttrs (_: {
src = fetchFromGitHub {
owner = "KhronosGroup";
repo = "glslang";
rev = "e00d27c6d65b7d3e72506a311d7f053da4051295";
sha256 = "00lzvzk613gpm1vsdxffmx52z3c52ijwvzk4sfhh95p71kdydhgv";
};
});
};
vulkan-validation-layers = callPackage ../development/tools/vulkan-validation-layers { };
vtkWithQt5 = vtk.override { qtLib = qt514; };