2022-02-14 16:08:03 +00:00
|
|
|
|
{ lib
|
|
|
|
|
, stdenv
|
|
|
|
|
, fetchFromGitHub
|
|
|
|
|
, glslang
|
|
|
|
|
, meson
|
|
|
|
|
, ninja
|
|
|
|
|
, windows
|
2023-07-11 17:09:20 +00:00
|
|
|
|
, dxvkVersion ? "default"
|
2022-11-11 00:41:42 +00:00
|
|
|
|
, spirv-headers
|
|
|
|
|
, vulkan-headers
|
2023-01-27 04:38:10 +00:00
|
|
|
|
, SDL2
|
2023-01-27 05:50:05 +00:00
|
|
|
|
, glfw
|
|
|
|
|
, pkgsBuildHost
|
2023-07-11 17:09:20 +00:00
|
|
|
|
, gitUpdater
|
2023-01-27 05:50:05 +00:00
|
|
|
|
, sdl2Support ? true
|
|
|
|
|
, glfwSupport ? false
|
2023-07-11 17:23:32 +00:00
|
|
|
|
, enableMoltenVKCompat ? false
|
2022-02-14 16:08:03 +00:00
|
|
|
|
}:
|
|
|
|
|
|
2023-01-27 05:50:05 +00:00
|
|
|
|
# SDL2 and GLFW support are mutually exclusive.
|
|
|
|
|
assert !sdl2Support || !glfwSupport;
|
|
|
|
|
|
2022-11-11 00:41:42 +00:00
|
|
|
|
let
|
|
|
|
|
# DXVK 2.0+ no longer vendors certain dependencies. This derivation also needs to build on Darwin,
|
|
|
|
|
# which does not currently support DXVK 2.0, so adapt conditionally for this situation.
|
2023-01-27 04:23:26 +00:00
|
|
|
|
isDxvk2 = lib.versionAtLeast (srcs.${dxvkVersion}.version) "2.0";
|
|
|
|
|
|
|
|
|
|
# DXVK has effectively the same build script regardless of platform.
|
|
|
|
|
srcs = {
|
|
|
|
|
"1.10" = rec {
|
|
|
|
|
version = "1.10.3";
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
|
owner = "doitsujin";
|
|
|
|
|
repo = "dxvk";
|
|
|
|
|
rev = "v${version}";
|
|
|
|
|
hash = "sha256-T93ZylxzJGprrP+j6axZwl2d3hJowMCUOKNjIyNzkmE=";
|
|
|
|
|
};
|
|
|
|
|
# These patches are required when using DXVK with Wine on Darwin.
|
2023-07-11 17:23:32 +00:00
|
|
|
|
patches = lib.optionals enableMoltenVKCompat [
|
2023-01-27 04:23:26 +00:00
|
|
|
|
# Patch DXVK to work with MoltenVK even though it doesn’t support some required features.
|
|
|
|
|
# Some games work poorly (particularly Unreal Engine 4 games), but others work pretty well.
|
|
|
|
|
./darwin-dxvk-compat.patch
|
|
|
|
|
# Use synchronization primitives from the C++ standard library to avoid deadlocks on Darwin.
|
|
|
|
|
# See: https://www.reddit.com/r/macgaming/comments/t8liua/comment/hzsuce9/
|
|
|
|
|
./darwin-thread-primitives.patch
|
|
|
|
|
];
|
|
|
|
|
};
|
2023-07-11 17:09:20 +00:00
|
|
|
|
"default" = rec {
|
2023-09-23 09:11:16 +00:00
|
|
|
|
version = "2.3";
|
2023-01-27 04:23:26 +00:00
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
|
owner = "doitsujin";
|
|
|
|
|
repo = "dxvk";
|
|
|
|
|
rev = "v${version}";
|
2023-09-23 09:11:16 +00:00
|
|
|
|
hash = "sha256-RU+B0XfphD5HHW/vSzqHLUaGS3E31d5sOLp3lMmrCB8=";
|
2023-01-27 04:38:10 +00:00
|
|
|
|
fetchSubmodules = true; # Needed for the DirectX headers and libdisplay-info
|
2023-01-27 04:23:26 +00:00
|
|
|
|
};
|
|
|
|
|
patches = [ ];
|
|
|
|
|
};
|
|
|
|
|
};
|
2023-01-27 04:38:10 +00:00
|
|
|
|
|
|
|
|
|
isWindows = stdenv.targetPlatform.uname.system == "Windows";
|
|
|
|
|
isCross = stdenv.hostPlatform != stdenv.targetPlatform;
|
2022-11-11 00:41:42 +00:00
|
|
|
|
in
|
2023-07-11 17:09:20 +00:00
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2022-02-14 16:08:03 +00:00
|
|
|
|
pname = "dxvk";
|
2023-01-27 04:23:26 +00:00
|
|
|
|
inherit (srcs.${dxvkVersion}) version src patches;
|
2022-02-14 16:08:03 +00:00
|
|
|
|
|
|
|
|
|
nativeBuildInputs = [ glslang meson ninja ];
|
2023-03-10 22:55:17 +00:00
|
|
|
|
buildInputs = lib.optionals isWindows [ windows.pthreads ]
|
2023-01-27 04:38:10 +00:00
|
|
|
|
++ lib.optionals isDxvk2 (
|
|
|
|
|
[ spirv-headers vulkan-headers ]
|
|
|
|
|
++ lib.optional (!isWindows && sdl2Support) SDL2
|
2023-01-27 05:50:05 +00:00
|
|
|
|
++ lib.optional (!isWindows && glfwSupport) glfw
|
2023-01-27 04:38:10 +00:00
|
|
|
|
);
|
2022-02-14 16:08:03 +00:00
|
|
|
|
|
2023-01-27 05:50:05 +00:00
|
|
|
|
postPatch = lib.optionalString isDxvk2 ''
|
|
|
|
|
substituteInPlace "subprojects/libdisplay-info/tool/gen-search-table.py" \
|
|
|
|
|
--replace "/usr/bin/env python3" "${lib.getBin pkgsBuildHost.python3}/bin/python3"
|
|
|
|
|
'';
|
|
|
|
|
|
2023-01-27 04:38:10 +00:00
|
|
|
|
# Build with the Vulkan SDK in nixpkgs.
|
|
|
|
|
preConfigure = ''
|
|
|
|
|
rm -rf include/spirv/include include/vulkan/include
|
|
|
|
|
mkdir -p include/spirv/include include/vulkan/include
|
2022-11-11 00:41:42 +00:00
|
|
|
|
'';
|
|
|
|
|
|
2022-02-14 16:08:03 +00:00
|
|
|
|
mesonFlags =
|
|
|
|
|
let
|
|
|
|
|
arch = if stdenv.is32bit then "32" else "64";
|
|
|
|
|
in
|
|
|
|
|
[
|
|
|
|
|
"--buildtype" "release"
|
|
|
|
|
"--prefix" "${placeholder "out"}"
|
2023-01-27 04:38:10 +00:00
|
|
|
|
]
|
2023-01-27 05:50:05 +00:00
|
|
|
|
++ lib.optionals isCross [ "--cross-file" "build-win${arch}.txt" ]
|
|
|
|
|
++ lib.optional glfwSupport "-Ddxvk_native_wsi=glfw";
|
2023-01-27 04:38:10 +00:00
|
|
|
|
|
|
|
|
|
doCheck = isDxvk2 && !isCross;
|
2022-02-14 16:08:03 +00:00
|
|
|
|
|
2023-07-11 17:09:20 +00:00
|
|
|
|
passthru = lib.optionalAttrs (lib.versionAtLeast finalAttrs.version "2.0") {
|
|
|
|
|
updateScript = gitUpdater {
|
|
|
|
|
rev-prefix = "v";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-14 16:08:03 +00:00
|
|
|
|
meta = {
|
|
|
|
|
description = "A Vulkan-based translation layer for Direct3D 9/10/11";
|
|
|
|
|
homepage = "https://github.com/doitsujin/dxvk";
|
|
|
|
|
changelog = "https://github.com/doitsujin/dxvk/releases";
|
|
|
|
|
maintainers = [ lib.maintainers.reckenrode ];
|
|
|
|
|
license = lib.licenses.zlib;
|
2023-01-27 04:38:10 +00:00
|
|
|
|
platforms = lib.platforms.windows ++ lib.optionals isDxvk2 lib.platforms.linux;
|
2022-02-14 16:08:03 +00:00
|
|
|
|
};
|
2023-07-11 17:09:20 +00:00
|
|
|
|
})
|