Merge pull request #175851 from reckenrode/dxvk-refactor
dxvk: refactor derivation and Darwin support
This commit is contained in:
commit
1ec895fd1d
|
@ -1,13 +1,8 @@
|
|||
Source: https://github.com/marzent/dxvk/commit/65247afe2de5dd6b555b8fdd46dddcdc6325e1d6
|
||||
---
|
||||
src/d3d11/d3d11_device.cpp | 12 +-
|
||||
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/d3d11/d3d11_device.cpp b/src/d3d11/d3d11_device.cpp
|
||||
index 21f0d1b4a..5b1d05335 100644
|
||||
index 09f3559a..215787f9 100644
|
||||
--- a/src/d3d11/d3d11_device.cpp
|
||||
+++ b/src/d3d11/d3d11_device.cpp
|
||||
@@ -799,8 +799,12 @@ namespace dxvk {
|
||||
@@ -801,8 +801,12 @@ namespace dxvk {
|
||||
InitReturnPtr(ppGeometryShader);
|
||||
D3D11CommonShader module;
|
||||
|
||||
|
@ -22,7 +17,25 @@ index 21f0d1b4a..5b1d05335 100644
|
|||
|
||||
// Zero-init some counterss so that we can increment
|
||||
// them while walking over the stream output entries
|
||||
@@ -1973,8 +1977,8 @@ namespace dxvk {
|
||||
@@ -1920,7 +1924,7 @@ namespace dxvk {
|
||||
DxvkDeviceFeatures supported = adapter->features();
|
||||
DxvkDeviceFeatures enabled = {};
|
||||
|
||||
- enabled.core.features.geometryShader = VK_TRUE;
|
||||
+ enabled.core.features.geometryShader = supported.core.features.geometryShader;
|
||||
enabled.core.features.robustBufferAccess = VK_TRUE;
|
||||
enabled.core.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
|
||||
enabled.core.features.depthBounds = supported.core.features.depthBounds;
|
||||
@@ -1951,7 +1955,7 @@ namespace dxvk {
|
||||
enabled.core.features.sampleRateShading = VK_TRUE;
|
||||
enabled.core.features.samplerAnisotropy = supported.core.features.samplerAnisotropy;
|
||||
enabled.core.features.shaderClipDistance = VK_TRUE;
|
||||
- enabled.core.features.shaderCullDistance = VK_TRUE;
|
||||
+ enabled.core.features.shaderCullDistance = supported.core.features.shaderCullDistance;
|
||||
enabled.core.features.textureCompressionBC = VK_TRUE;
|
||||
enabled.extDepthClipEnable.depthClipEnable = supported.extDepthClipEnable.depthClipEnable;
|
||||
enabled.extHostQueryReset.hostQueryReset = VK_TRUE;
|
||||
@@ -1971,8 +1975,8 @@ namespace dxvk {
|
||||
enabled.core.features.logicOp = supported.core.features.logicOp;
|
||||
enabled.core.features.shaderImageGatherExtended = VK_TRUE;
|
||||
enabled.core.features.variableMultisampleRate = supported.core.features.variableMultisampleRate;
|
||||
|
|
|
@ -6,13 +6,17 @@
|
|||
, pkgsCross
|
||||
}:
|
||||
|
||||
let
|
||||
stdenvNoCC.mkDerivation (finalAttrs:
|
||||
let
|
||||
inherit (hostPlatform.uname) system;
|
||||
|
||||
# DXVK needs to be a separate derivation because it’s actually a set of DLLs for Windows that
|
||||
# needs to be built with a cross-compiler.
|
||||
dxvk32 = pkgsCross.mingw32.callPackage ./dxvk.nix { inherit (self) src version dxvkPatches; };
|
||||
dxvk64 = pkgsCross.mingwW64.callPackage ./dxvk.nix { inherit (self) src version dxvkPatches; };
|
||||
dxvk32 = pkgsCross.mingw32.callPackage ./dxvk.nix {
|
||||
inherit (finalAttrs) src version dxvkPatches;
|
||||
};
|
||||
dxvk64 = pkgsCross.mingwW64.callPackage ./dxvk.nix {
|
||||
inherit (finalAttrs) src version dxvkPatches;
|
||||
};
|
||||
|
||||
# Split out by platform to make maintenance easy in case supported versions on Darwin and other
|
||||
# platforms diverge (due to the need for Darwin-specific patches that would fail to apply).
|
||||
|
@ -20,15 +24,13 @@ let
|
|||
srcs = rec {
|
||||
darwin = { inherit (default) rev hash version; };
|
||||
default = {
|
||||
rev = "v${self.version}";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-+6PkrkamSvhCaGj2tq+RXri/yQ7vs0cAqgdRAFtU8UA=";
|
||||
version = "1.10.1";
|
||||
};
|
||||
};
|
||||
|
||||
# Use the self pattern to support overriding `src` and `version` via `overrideAttrs`. A recursive
|
||||
# attrset wouldn’t work.
|
||||
self = stdenvNoCC.mkDerivation {
|
||||
in
|
||||
{
|
||||
name = "dxvk";
|
||||
inherit (srcs."${system}" or srcs.default) version;
|
||||
|
||||
|
@ -70,32 +72,12 @@ let
|
|||
done
|
||||
'';
|
||||
|
||||
# DXVK with MoltenVK requires a patched MoltenVK in addition to its own patches. Provide a
|
||||
# convenience function to handle the necessary patching.
|
||||
#
|
||||
# Usage:
|
||||
# let
|
||||
# patchedMoltenVK = dxvk.patchMoltenVK darwin.moltenvk;
|
||||
# in
|
||||
# wine64Packages.full.override { moltenvk = patchedMoltenVK; vkd3dSupport = false; }
|
||||
passthru.patchMoltenVK = moltenvk:
|
||||
moltenvk.overrideAttrs (old: {
|
||||
patches = old.patches or [ ] ++ [
|
||||
# Apply MoltenVK’s DXVK compatability patch. This is needed to fake support for certain
|
||||
# extensions. There is no package for a patched MoltenVK to avoid any confusion by users
|
||||
# whether they should use it. Except with DXVK, the answer is always no.
|
||||
old.passthru.dxvkPatch
|
||||
];
|
||||
});
|
||||
|
||||
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;
|
||||
platforms = lib.platforms.unix;
|
||||
platforms = [ "x86_64-darwin" "i686-linux" "x86_64-linux" ];
|
||||
};
|
||||
};
|
||||
in
|
||||
self
|
||||
})
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
let
|
||||
libcxx.dev = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr";
|
||||
in
|
||||
stdenvNoCC.mkDerivation rec {
|
||||
stdenvNoCC.mkDerivation (finalAttrs: {
|
||||
pname = "MoltenVK";
|
||||
version = "1.1.9";
|
||||
|
||||
|
@ -43,10 +43,6 @@ stdenvNoCC.mkDerivation rec {
|
|||
# MoltenVK requires specific versions of its dependencies.
|
||||
# Pin them here except for cereal, which is four years old and has several CVEs.
|
||||
passthru = {
|
||||
# The patch required to support DXVK may different from version to version. This should never
|
||||
# be used except with DXVK, so there’s no package for it. To emphasize that this patch should
|
||||
# never be used except with DXVK, `dxvk` provides a function for applying this patch.
|
||||
dxvkPatch = ./dxvk-moltenvk-compat.patch;
|
||||
glslang = (glslang.overrideAttrs (old: {
|
||||
src = fetchFromGitHub {
|
||||
owner = "KhronosGroup";
|
||||
|
@ -55,7 +51,7 @@ stdenvNoCC.mkDerivation rec {
|
|||
hash = "sha256-YLn/Mxuk6mXPGtBBgfwky5Nl1TCAW6i2g+AZLzqVz+A=";
|
||||
};
|
||||
})).override {
|
||||
inherit (passthru) spirv-headers spirv-tools;
|
||||
inherit (finalAttrs.passthru) spirv-headers spirv-tools;
|
||||
};
|
||||
spirv-cross = spirv-cross.overrideAttrs (old: {
|
||||
cmakeFlags = (old.cmakeFlags or [ ]) ++ [
|
||||
|
@ -84,7 +80,7 @@ stdenvNoCC.mkDerivation rec {
|
|||
hash = "sha256-2Mr3HbhRslLpRfwHascl7e/UoPijhrij9Bjg3aCiqBM=";
|
||||
};
|
||||
})).override {
|
||||
inherit (passthru) spirv-headers;
|
||||
inherit (finalAttrs.passthru) spirv-headers;
|
||||
};
|
||||
vulkan-headers = vulkan-headers.overrideAttrs (old: {
|
||||
src = fetchFromGitHub {
|
||||
|
@ -99,7 +95,7 @@ stdenvNoCC.mkDerivation rec {
|
|||
src = fetchFromGitHub {
|
||||
owner = "KhronosGroup";
|
||||
repo = "MoltenVK";
|
||||
rev = "v${version}";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-5ie1IGzZqaYbciFnrBJ1/9V0LEuz7JsEOFXXkG3hJzg=";
|
||||
};
|
||||
|
||||
|
@ -117,24 +113,24 @@ stdenvNoCC.mkDerivation rec {
|
|||
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}"
|
||||
--replace @@glslang@@ "${finalAttrs.passthru.glslang}" \
|
||||
--replace @@spirv-cross@@ "${finalAttrs.passthru.spirv-cross}" \
|
||||
--replace @@spirv-tools@@ "${finalAttrs.passthru.glslang.spirv-tools}" \
|
||||
--replace @@spirv-headers@@ "${finalAttrs.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}"
|
||||
--replace @@spirv-cross@@ "${finalAttrs.passthru.spirv-cross}" \
|
||||
--replace @@vulkan-headers@@ "${finalAttrs.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}"
|
||||
--replace @@glslang@@ "${finalAttrs.passthru.glslang}" \
|
||||
--replace @@spirv-tools@@ "${finalAttrs.passthru.glslang.spirv-tools}" \
|
||||
--replace @@spirv-cross@@ "${finalAttrs.passthru.spirv-cross}"
|
||||
substituteInPlace Scripts/gen_moltenvk_rev_hdr.sh \
|
||||
--replace @@sourceRoot@@ $(pwd) \
|
||||
--replace '$(git rev-parse HEAD)' ${src.rev}
|
||||
--replace '$(git rev-parse HEAD)' ${finalAttrs.src.rev}
|
||||
'';
|
||||
|
||||
dontConfigure = true;
|
||||
|
@ -197,4 +193,4 @@ stdenvNoCC.mkDerivation rec {
|
|||
license = lib.licenses.asl20;
|
||||
platforms = lib.platforms.darwin;
|
||||
};
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
Source: https://github.com/Gcenx/MoltenVK/commit/1f268bd45f6c928784d7cb90dedce382895f10ae
|
||||
|
||||
Fake extensions for DXVK;
|
||||
- _features.geometryShader
|
||||
- _features.tessellationShader
|
||||
- _features.shaderCullDistance
|
||||
|
||||
Enabled defaults;
|
||||
- MVK_ALLOW_METAL_FENCES=1
|
||||
- MVK_CONFIG_RESUME_LOST_DEVICE=1
|
||||
---
|
||||
MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm | 3 +++
|
||||
MoltenVK/MoltenVK/Utility/MVKEnvironment.h | 4 ++--
|
||||
2 files changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
|
||||
index bc6d19df..e1959c6e 100644
|
||||
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
|
||||
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
|
||||
@@ -1656,6 +1656,8 @@
|
||||
_features.robustBufferAccess = true; // XXX Required by Vulkan spec
|
||||
_features.fullDrawIndexUint32 = true;
|
||||
_features.independentBlend = true;
|
||||
+ _features.geometryShader = true; // XXX Required by DXVK for D3D10
|
||||
+ _features.tessellationShader = true; // XXX Required by DXVK for D3D11
|
||||
_features.sampleRateShading = true;
|
||||
_features.depthBiasClamp = true;
|
||||
_features.fillModeNonSolid = true;
|
||||
@@ -1669,6 +1671,7 @@
|
||||
_features.shaderUniformBufferArrayDynamicIndexing = true;
|
||||
_features.shaderStorageBufferArrayDynamicIndexing = true;
|
||||
_features.shaderClipDistance = true;
|
||||
+ _features.shaderCullDistance = true; // XXX Required by DXVK for 10level9
|
||||
_features.shaderInt16 = true;
|
||||
_features.multiDrawIndirect = true;
|
||||
_features.inheritedQueries = true;
|
||||
diff --git a/MoltenVK/MoltenVK/Utility/MVKEnvironment.h b/MoltenVK/MoltenVK/Utility/MVKEnvironment.h
|
||||
index 81d0defc..80c414d3 100644
|
||||
--- a/MoltenVK/MoltenVK/Utility/MVKEnvironment.h
|
||||
+++ b/MoltenVK/MoltenVK/Utility/MVKEnvironment.h
|
||||
@@ -240,7 +240,7 @@ void mvkSetConfig(const MVKConfiguration& mvkConfig);
|
||||
# define MVK_ALLOW_METAL_EVENTS 1
|
||||
#endif
|
||||
#ifndef MVK_ALLOW_METAL_FENCES
|
||||
-# define MVK_ALLOW_METAL_FENCES 0
|
||||
+# define MVK_ALLOW_METAL_FENCES 1 // XXX Required by DXVK for Apple/NVidia GPUs (better FPS than CPU Emulation)
|
||||
#endif
|
||||
|
||||
/** Substitute Metal 2D textures for Vulkan 1D images. Enabled by default. */
|
||||
@@ -275,7 +275,7 @@ void mvkSetConfig(const MVKConfiguration& mvkConfig);
|
||||
|
||||
/** Resume MVKDevice VK_ERROR_DEVICE_LOST errors that do not cause MVKPhysicalDevice errors. Disabled by default. */
|
||||
#ifndef MVK_CONFIG_RESUME_LOST_DEVICE
|
||||
-# define MVK_CONFIG_RESUME_LOST_DEVICE 0
|
||||
+# define MVK_CONFIG_RESUME_LOST_DEVICE 1
|
||||
#endif
|
||||
|
||||
/** Support Metal argument buffers. Disabled by default. */
|
||||
|
Loading…
Reference in a new issue