Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.
HTML apple-siliconbattle-netcrossover-alternatived3dmetaldiablo-ii-resurrecteddxmtea-appepic-gamesgame-porting-toolkitgogmac-gamingmacosmacos-gamingrockstar-gamessteamubisoft-connectwhisky-alternativewindows-gameswinewine-wrapper
Steam: Detroit: Become Human runs (MoltenVK 1.4.2 with Highball's patches, Steam support v5) (#135)
Mikek8c796fba2021
diff --git a/NOTICE b/NOTICEindex a0043eb0d67..1162543063c 100644--- a/NOTICE+++ b/NOTICE@@ -14,6 +14,10 @@ Built or downloaded by the scripts (open-source component releases include correpinned URL and checksum in resources/steam-wine.json- DXMT pinned notpop fork: MIT, Copyright (c) 2023 Feifan He(built from the notpop fork of github.com/3Shain/dxmt)+- MoltenVK v1.4.2 in the Steam support package (libMoltenVK.dylib): Apache-2.0, built by+ scripts/build-moltenvk.sh with patches/moltenvk/*.patch. Those two patches come from Highball+ (github.com/gauthierpiarrette/highball, GPL-3.0-or-later), ported there from DiAvisoo's MoltenVK-Detroit+ (work by alexdremov and squidbus in KhronosGroup/MoltenVK#2054).- wine-mono: MIT (dotnet parts MIT/BSD-like); MoltenVK: Apache-2.0; gnutls: LGPL-2.1+;freetype: FTL/GPL-2.0 dual- Apple Game Porting Toolkit payload (libd3dshared/D3DMetal): Apple proprietary,diff --git a/README.ko.md b/README.ko.mdindex ea909833c97..b6168977ba3 100644--- a/README.ko.md+++ b/README.ko.md@@ -47,6 +47,7 @@ soju install| 디아블로 4 | Battle.net | ✅ 인게임 (무료 체험판) | 캐릭터 생성, 첫 지역 진입까지 확인. 소리와 프레임은 미확인. 고해상도 에셋 제외 97GB. [가이드](https://didimlabs.com/guides/ko/diablo-4-mac.html) || Hogwarts Legacy | Epic | ✅ 인게임 | 시작할 때 뜨는 "AMD 드라이버" 경고는 무시해도 됩니다. 입력 소스는 영어로 || StarCraft: Remastered | Battle.net | ✅ 인게임 | 컴퓨터 상대 대전까지 확인, 멀티플레이는 미확인, [가이드](https://didimlabs.com/guides/ko/starcraft-mac.html) |+| 디트로이트: 비컴 휴먼 (데모) | Steam | ✅ 인게임 | 맥 미니 M4 Pro, macOS 26.5. Steam 지원 v5의 MoltenVK로 Vulkan을 그립니다. 처음 실행할 때 셰이더 준비에 몇 분 걸립니다. "그래픽카드가 공식 지원되지 않는다" 경고는 OK를 누르면 됩니다 || 오버워치 2 | Steam | ✅ 메인 메뉴, 온라인 | Platforms > Steam > **Overwatch and Diablo II mode**를 켭니다(`soju steam-gptk on`). 처음 한 번 배틀넷 계정 연결을 묻습니다. [가이드](https://didimlabs.com/guides/ko/overwatch-2-mac.html) || The Elder Scrolls V: Skyrim Special Edition | Steam | ✅ 인게임 (사용자 제보) | M5 Pro, macOS 27.2, Soju 1.14.8. 대사와 서라운드 소리 확인 ([#95](https://github.com/BCD1210/soju/issues/95)) || Guilt Free (Unity Direct3D 11 게임) | Steam | ✅ 인게임, 창 모드 | [docs/STEAM-GAMES.md](docs/STEAM-GAMES.md) |diff --git a/README.md b/README.mdindex 7ce544da6f4..0055935dc86 100644--- a/README.md+++ b/README.md@@ -49,6 +49,7 @@ Tested by us on an M4 Pro with macOS 26.5, unless a row says it is a player's re| Diablo IV | Battle.net | ✅ in-game (free trial) | character created and in the first area; sound and frame rate not checked; 97 GB without High-Resolution Assets; [guide](https://didimlabs.com/guides/diablo-4-apple-silicon.html) || Hogwarts Legacy | Epic | ✅ in-game | the "AMD driver" warning at start is harmless || StarCraft: Remastered | Battle.net | ✅ in-game | a match against the computer; multiplayer not tried; [guide](https://didimlabs.com/guides/starcraft-remastered-apple-silicon.html) |+| Detroit: Become Human (demo) | Steam | ✅ in-game | Mac mini M4 Pro, macOS 26.5. Draws with Vulkan through the MoltenVK in Steam support v5; the first start compiles shaders for a few minutes. Press OK on the "graphics card is not officially supported" warning || Overwatch 2 | Steam | ✅ main menu, online | turn on Platforms > Steam > **Overwatch and Diablo II mode** (`soju steam-gptk on`); the game asks once to connect a Battle.net account; [guide](https://didimlabs.com/guides/overwatch-2-apple-silicon.html) || The Elder Scrolls V: Skyrim Special Edition | Steam | ✅ in-game (player's report) | M5 Pro, macOS 27.2, Soju 1.14.8; dialogue and surround sound confirmed ([#95](https://github.com/BCD1210/soju/issues/95)) || Guilt Free (a Unity Direct3D 11 game) | Steam | ✅ in-game, windowed | see [docs/STEAM-GAMES.md](docs/STEAM-GAMES.md) |diff --git a/README.zh.md b/README.zh.mdindex bc4b73f0fbe..9b2eb3d8b10 100644--- a/README.zh.md+++ b/README.zh.md@@ -47,6 +47,7 @@ soju install| Diablo IV | Battle.net | ✅ 进入游戏(免费试玩) | 已创建角色并进入第一个区域;声音和帧率未测试;不含高清素材约 97 GB;[指南](https://didimlabs.com/guides/diablo-4-apple-silicon.html) || Hogwarts Legacy | Epic | ✅ 进入游戏 | 启动时的“AMD 驱动”警告可以忽略 || StarCraft: Remastered | Battle.net | ✅ 进入游戏 | 已确认与电脑对战;多人未测试 |+| Detroit: Become Human(试玩版) | Steam | ✅ 游戏内 | Mac mini M4 Pro,macOS 26.5。通过 Steam 支持包 v5 中的 MoltenVK 用 Vulkan 绘制;首次启动需要几分钟编译着色器。出现“显卡未受官方支持”提示时按 OK || 守望先锋 2 | Steam | ✅ 主菜单,在线 | 打开 Platforms > Steam > **Overwatch and Diablo II mode**(`soju steam-gptk on`);首次会要求连接一次 Battle.net 账号 || The Elder Scrolls V: Skyrim Special Edition | Steam | ✅ 进入游戏(玩家反馈) | M5 Pro,macOS 27.2,Soju 1.14.8;对白和环绕声已确认([#95](https://github.com/BCD1210/soju/issues/95)) || Guilt Free(Unity Direct3D 11 游戏) | Steam | ✅ 进入游戏,窗口模式 | 见 [docs/STEAM-GAMES.md](docs/STEAM-GAMES.md) |diff --git a/docs/STEAM-PREBUILTS.md b/docs/STEAM-PREBUILTS.mdindex c9b8278947a..4f700313c72 100644--- a/docs/STEAM-PREBUILTS.md+++ b/docs/STEAM-PREBUILTS.md@@ -1,4 +1,4 @@-# Steam support release v4+# Steam support release v5The package contains only these open-source components:@@ -18,11 +18,17 @@ The package contains only these open-source components:stereo device is rendered through Apple's AUSpatialMixer, so centre and back channels are heard (#93)(LGPL-2.1-or-later).- Steam webhelper wrapper: vendored notpop source (MIT).+- MoltenVK v1.4.2: `db66022459ffb663aa2b50f6b018bc2e124f5edf` (Apache-2.0), x86_64, with+ `patches/moltenvk/cache-drawid-present.patch` and `patches/moltenvk/lenient-interfaces.patch` from Highball+ (GPL-3.0-or-later), built by `scripts/build-moltenvk.sh`. It replaces the Steam runtime's MoltenVK 1.4.1, which+ could not compile Detroit: Become Human's pipelines (`DrawIndex is not supported in MSL`). Steam starts with+ `HB_MVK_LENIENT_INTERFACES=1`, `MVK_CONFIG_SHOULD_MAXIMIZE_CONCURRENT_COMPILATION=1` and+ `MVK_CONFIG_SHADER_COMPRESSION_ALGORITHM=1`, Highball's settings for that game.- LLVM 15.0.7: `8dfdcc7b7bf66834a761bd8de445840ef68e4d1a`(Apache-2.0 with LLVM exceptions), statically linked into the renderer.-[Binary and corresponding source release](https://github.com/BCD1210/soju/releases/tag/steam-support-v4)-([v3](https://github.com/BCD1210/soju/releases/tag/steam-support-v3) is the same without the audio components;+[Binary and corresponding source release](https://github.com/BCD1210/soju/releases/tag/steam-support-v5)+([v4](https://github.com/BCD1210/soju/releases/tag/steam-support-v4) is the same without MoltenVK; [v3](https://github.com/BCD1210/soju/releases/tag/steam-support-v3) is the same without the audio components;[v2](https://github.com/BCD1210/soju/releases/tag/steam-support-v2) is the same without the pure virtualbackport; [v1](https://github.com/BCD1210/soju/releases/tag/steam-support-v1) also lacks the tessellation backport.)diff --git a/patches/moltenvk/cache-drawid-present.patch b/patches/moltenvk/cache-drawid-present.patchnew file mode 100644index 00000000000..164bd5668f6--- /dev/null+++ b/patches/moltenvk/cache-drawid-present.patch@@ -0,0 +1,96 @@+From Highball (github.com/gauthierpiarrette/highball, spike/patches/moltenvk-cache-drawid-present.patch, GPL-3.0-or-later),+ported there from DiAvisoo's MoltenVK-Detroit (alexdremov's and squidbus's work in KhronosGroup/MoltenVK#2054).+Applied by scripts/build-moltenvk.sh on MoltenVK v1.4.2 for Detroit: Become Human.++diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm b/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm+index 664276b..f7b99b5 100644+--- a/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm++++ b/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm+@@ -209,7 +209,10 @@+ tempDrawIDBuff = cmdEncoder->getTempMTLBuffer(sizeof(uint32_t));++ // We don't currently support non-indirect multi-draw commands, so just 0.+- memset([tempDrawIDBuff->_mtlBuffer contents], 0, sizeof(uint32_t));++ // HIGHBALL cache-drawid-present: at this allocation's offset, where the shader reads it. The memset++ // wrote the start of the shared temporary MTLBuffer, over another allocation, and left the draw ID++ // unset (alexdremov in MoltenVK-Detroit, highball#125; upstream fixed it after 1.4.2 in bc0d5bf7).++ *(uint32_t*)tempDrawIDBuff->getContents() = 0;+ }+ for (uint32_t s : stages) {+ auto stage = MVKGraphicsStage(s);+@@ -492,7 +495,10 @@+ tempDrawIDBuff = cmdEncoder->getTempMTLBuffer(sizeof(uint32_t));++ // We don't currently support non-indirect multi-draw commands, so just 0.+- memset([tempDrawIDBuff->_mtlBuffer contents], 0, sizeof(uint32_t));++ // HIGHBALL cache-drawid-present: at this allocation's offset, where the shader reads it. The memset++ // wrote the start of the shared temporary MTLBuffer, over another allocation, and left the draw ID++ // unset (alexdremov in MoltenVK-Detroit, highball#125; upstream fixed it after 1.4.2 in bc0d5bf7).++ *(uint32_t*)tempDrawIDBuff->getContents() = 0;+ }+ for (uint32_t s : stages) {+ auto stage = MVKGraphicsStage(s);+diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm+index 28eb255..804a8fb 100644+--- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm++++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm+@@ -1684,9 +1684,16 @@ static void signalAndUntrack(const MVKSwapchainSignaler& signaler) {+ [mtlCmdBuff addCompletedHandler: ^(id<MTLCommandBuffer> mcb) {+ signal(fence);+ if (fence) { fence->release(); }++ // HIGHBALL cache-drawid-present: tell the swapchain before letting go of this image. When the swapchain++ // was destroyed meanwhile (a window, fullscreen or resolution change), release() can free this image,++ // and _swapchain was then read from freed memory. The detachment lock keeps the swapchain from being++ // detached and freed during the call (DiAvisoo in MoltenVK-Detroit, highball#125).++ {++ lock_guard<mutex> lock(_detachmentLock);++ if (_swapchain) { _swapchain->notifyPresentComplete(presentInfo); }++ }+ [mtlDrwbl release];+ release();+- if (_swapchain) { _swapchain->notifyPresentComplete(presentInfo); }+ }];++ signal(signaler.semaphore, signaler.semaphoreSignalToken, mtlCmdBuff);+diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm+index 7eae64c..9019727 100644+--- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm++++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm+@@ -2656,6 +2656,24 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura++ if ( !pDataSize ) { return VK_SUCCESS; }+++ // HIGHBALL cache-drawid-present: the size is known only after a size query, and any pipeline added++ // since then resets it to zero. A call that passed a buffer in that state serialized into zero bytes,++ // threw, and returned VK_INCOMPLETE with nothing written, so a game that saves its pipeline cache while++ // other threads still compile, or without asking the size first (both valid Vulkan), saved nothing.++ // Compute the size first for both forms of the call (alexdremov's fix in DiAvisoo's MoltenVK-Detroit,++ // highball#125).++ if (_dataSize == 0) {++ mvk::countbuf cb;++ ostream outStream(&cb);++ writeData(outStream, true);++ _dataSize = cb.buffSize;++ static bool reported = false;++ if (pData && !reported) {++ reported = true;++ reportMessage(MVK_CONFIG_LOG_LEVEL_INFO, "HIGHBALL cache-drawid-present: vkGetPipelineCacheData() got a buffer while the cache size was unknown; the size was computed first (reported once).");++ }++ }+++ if (pData) {+ if (*pDataSize >= _dataSize) {+ mvk::membuf mb((char*)pData, _dataSize);+@@ -2668,12 +2686,6 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura+ return VK_INCOMPLETE;+ }+ } else {+- if (_dataSize == 0) {+- mvk::countbuf cb;+- ostream outStream(&cb);+- writeData(outStream, true);+- _dataSize = cb.buffSize;+- }+ *pDataSize = _dataSize;+ return VK_SUCCESS;+ }diff --git a/patches/moltenvk/lenient-interfaces.patch b/patches/moltenvk/lenient-interfaces.patchnew file mode 100644index 00000000000..7ee76599968--- /dev/null+++ b/patches/moltenvk/lenient-interfaces.patch@@ -0,0 +1,242 @@+From Highball (github.com/gauthierpiarrette/highball, spike/patches/moltenvk-lenient-interfaces.patch, GPL-3.0-or-later),+ported there from DiAvisoo's MoltenVK-Detroit (alexdremov's and squidbus's work in KhronosGroup/MoltenVK#2054).+Applied by scripts/build-moltenvk.sh on MoltenVK v1.4.2 for Detroit: Become Human.++diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm+index ca05b5e..4bbc2e5 100644+--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm++++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm+@@ -3276,6 +3276,11 @@ static uint32_t mvkGetEntryProperty(io_registry_entry_t entry, CFStringRef prope+ // might affect the contents of the pipeline cache (mostly MSL content).+ uint32_t mtlFeatures = 0;+ mtlFeatures |= _isUsingMetalArgumentBuffers << 0;++ // HIGHBALL lenient-interfaces: HB_MVK_LENIENT_INTERFACES=1 changes what a cached vertex shader library++ // records (MVKPipeline.mm), so cache data saved with and without it must not be mixed: a game's cache from++ // before the switch would otherwise serve libraries without the placeholders and keep failing pipelines.++ const char* hbLenient = getenv("HB_MVK_LENIENT_INTERFACES");++ mtlFeatures |= (uint32_t)(hbLenient && hbLenient[0] == '1') << 31;+ *(uint32_t*)&_properties.pipelineCacheUUID[uuidComponentOffset] = NSSwapHostIntToBig(mtlFeatures);+ uuidComponentOffset += sizeof(mtlFeatures);+ }+diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h+index e385e9b..f0a6de2 100644+--- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h++++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h+@@ -358,7 +358,7 @@ protected:+ bool addVertexInputToPipeline(T* inputDesc, const VkPipelineVertexInputStateCreateInfo* pVI, const mvk::SPIRVToMSLConversionConfiguration& shaderConfig);+ void adjustVertexInputForMultiview(MTLVertexDescriptor* inputDesc, const VkPipelineVertexInputStateCreateInfo* pVI, uint32_t viewCount, uint32_t oldViewCount = 1);+ void addTessellationToPipeline(MTLRenderPipelineDescriptor* plDesc, const mvk::SPIRVTessReflectionData& reflectData, const VkPipelineTessellationStateCreateInfo* pTS);+- void addFragmentOutputToPipeline(MTLRenderPipelineDescriptor* plDesc, const VkGraphicsPipelineCreateInfo* pCreateInfo);++ void addFragmentOutputToPipeline(MTLRenderPipelineDescriptor* plDesc, const VkGraphicsPipelineCreateInfo* pCreateInfo, const SPIRVShaderOutputs* pFragOutputs = nullptr);+ bool isRenderingPoints();+ bool isRasterizationDisabled(const VkGraphicsPipelineCreateInfo* pCreateInfo);+ bool isDepthClipNegativeOneToOne(const VkGraphicsPipelineCreateInfo* pCreateInfo);+diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm+index 9019727..3804f9c 100644+--- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm++++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm+@@ -43,6 +43,56 @@+ using namespace mvk;+ using namespace SPIRV_CROSS_NAMESPACE;+++// HIGHBALL lenient-interfaces: some games build pipelines whose stages disagree in ways Metal refuses and PC++// drivers tolerate. Detroit: Become Human's vertex shaders read attributes the pipeline never describes++// ("Vertex attribute in_vfMsBindPosePosition(12) is missing from the vertex descriptor"), and some of its++// fragment shaders write float4 into an R32Uint color attachment. MoltenVK then fails the pipeline and the++// game stops at the end of its shader preparation or crashes in a scene (highball#125). With++// HB_MVK_LENIENT_INTERFACES=1, an attribute the shader reads but the pipeline does not describe reads four bytes++// from the start of a vertex buffer the pipeline already uses, and a color attachment whose integer or float++// kind differs from the fragment output takes a format of the output's kind and the same size. This is the code++// squidbus and alexdremov wrote in KhronosGroup/MoltenVK#2054 and DiAvisoo shipped in MoltenVK-Detroit, with++// which players finished the game. It is invalid Vulkan made to work, so it stays off unless a game's recipe++// sets the variable; unset, nothing changes.++static bool mvkHighballLenientInterfaces() {++ static const bool enabled = [] {++ const char* val = getenv("HB_MVK_LENIENT_INTERFACES");++ bool on = val && val[0] == '1';++ if (on) {++ MVKBaseObject::reportMessage(nullptr, MVK_CONFIG_LOG_LEVEL_WARNING,++ "HIGHBALL lenient-interfaces: undescribed vertex attributes and color attachments of another kind than the fragment output are allowed (HB_MVK_LENIENT_INTERFACES=1).");++ }++ return on;++ }();++ return enabled;++}++++// HIGHBALL lenient-interfaces: adds each vertex input location the shader declares and the pipeline does not++// describe, before the conversion, which then reports whether the MSL reads it, so addVertexInputToPipeline()++// can give it a placeholder. Added before the conversion, the entries are part of the shader library's cache++// key, so a later pipeline with the same shader and attributes still finds the converted library.++static void mvkHighballAddUndescribedVertexInputs(SPIRVToMSLConversionConfiguration& shaderConfig,++ MVKShaderModule* vtxModule,++ const VkPipelineShaderStageCreateInfo* pVertexSS) {++ if ( !mvkHighballLenientInterfaces() || !vtxModule || !pVertexSS ) { return; }++ MVKSmallVector<SPIRVShaderInterfaceVariable, 32> vtxInputs;++ std::string errorLog;++ if ( !getShaderInputs(vtxModule->getSPIRV(), spv::ExecutionModelVertex, pVertexSS->pName, vtxInputs, errorLog) ) { return; }++ for (auto& vi : vtxInputs) {++ if (vi.builtin != spv::BuiltInMax || vi.location >= kMVKMaxBufferCount) { continue; }++ bool isDescribed = false;++ for (auto& si : shaderConfig.shaderInputs) {++ if (si.shaderVar.builtin == spv::BuiltInMax && si.shaderVar.location == vi.location) { isDescribed = true; break; }++ }++ if ( !isDescribed ) {++ mvk::MSLShaderInput si;++ si.shaderVar.location = vi.location;++ si.binding = 0;++ shaderConfig.shaderInputs.push_back(si);++ }++ }++}++++ #pragma mark - MVKPipelineLayout++@@ -1196,7 +1246,11 @@ static bool usesConstantColor(MVKRenderStateFlags dynamic, const VkPipelineColor+ if (!addFragmentShaderToPipeline(plDesc, pCreateInfo, shaderConfig, vtxOutputs, pFragmentSS, pFragmentFB)) { return nil; }++ // Output+- addFragmentOutputToPipeline(plDesc, pCreateInfo);++ SPIRVShaderOutputs fragOutputs; // HIGHBALL lenient-interfaces++ if (mvkHighballLenientInterfaces() && pFragmentSS && _fragmentModule) {++ getShaderOutputs(_fragmentModule->getSPIRV(), spv::ExecutionModelFragment, pFragmentSS->pName, fragOutputs, errorLog);++ }++ addFragmentOutputToPipeline(plDesc, pCreateInfo, &fragOutputs);++ // Metal does not allow the name of the pipeline to be changed after it has been created,+ // and we need to create the Metal pipeline immediately to provide error feedback to app.+@@ -1430,7 +1484,11 @@ static MTLVertexFormat mvkAdjustFormatVectorToSize(MTLVertexFormat format, uint3+ addTessellationToPipeline(plDesc, reflectData, pCreateInfo->pTessellationState);++ // Output+- addFragmentOutputToPipeline(plDesc, pCreateInfo);++ SPIRVShaderOutputs fragOutputs; // HIGHBALL lenient-interfaces++ if (mvkHighballLenientInterfaces() && pFragmentSS && _fragmentModule) {++ getShaderOutputs(_fragmentModule->getSPIRV(), spv::ExecutionModelFragment, pFragmentSS->pName, fragOutputs, errorLog);++ }++ addFragmentOutputToPipeline(plDesc, pCreateInfo, &fragOutputs);++ return plDesc;+ }+@@ -1507,6 +1565,7 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura+ shaderConfig.options.mslOptions.disable_rasterization = !_isRasterizing;+ setEmulatedReversedDepthViewportConfig(shaderConfig, implicit, getPhysicalDevice()->shouldEmulateReversedDepthViewport());+ addVertexInputToShaderConversionConfig(shaderConfig, pCreateInfo);++ mvkHighballAddUndescribedVertexInputs(shaderConfig, _vertexModule, pVertexSS); // HIGHBALL lenient-interfaces++ MVKMTLFunction func = getMTLFunction(shaderConfig, pVertexSS, pVertexFB, _vertexModule, "Vertex");+ id<MTLFunction> mtlFunc = func.getMTLFunction();+@@ -1545,6 +1604,7 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura+ shaderConfig.options.mslOptions.disable_rasterization = true;+ setEmulatedReversedDepthViewportConfig(shaderConfig, implicit, false);+ addVertexInputToShaderConversionConfig(shaderConfig, pCreateInfo);++ mvkHighballAddUndescribedVertexInputs(shaderConfig, _vertexModule, pVertexSS); // HIGHBALL lenient-interfaces+ addNextStageInputToShaderConversionConfig(shaderConfig, tcInputs);++ // We need to compile this function three times, with no indexing, 16-bit indices, and 32-bit indices.+@@ -1774,10 +1834,12 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura+ }++ // Vertex attributes++ std::vector<uint32_t> boundLocations; // HIGHBALL lenient-interfaces+ uint32_t vaCnt = pVI->vertexAttributeDescriptionCount;+ for (uint32_t i = 0; i < vaCnt; i++) {+ const VkVertexInputAttributeDescription* pVKVA = &pVI->pVertexAttributeDescriptions[i];+ if (shaderConfig.isShaderInputLocationUsed(pVKVA->location)) {++ boundLocations.push_back(pVKVA->location);+ uint32_t vaBinding = pVKVA->binding;+ uint32_t vaOffset = pVKVA->offset;+ auto vaDesc = inputDesc.attributes[pVKVA->location];+@@ -1834,6 +1896,41 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura+ }+ }+++ // HIGHBALL lenient-interfaces: Metal requires every attribute the vertex shader reads to be in the vertex++ // descriptor. Describe each one the app left out as four bytes at offset 0 of the first vertex buffer++ // the pipeline uses, or of a constant one-byte-stride layout when it uses none.++ if (mvkHighballLenientInterfaces()) {++ uint32_t dummyBufferIndex = 0;++ bool foundUsedBuffer = false;++ for (uint32_t i = 0; i < kMVKMaxBufferCount; i++) {++ if (_mtlVertexBuffers.get(i)) {++ dummyBufferIndex = i;++ foundUsedBuffer = true;++ break;++ }++ }++ bool addedDummy = false;++ for (auto& ctxSI : shaderConfig.shaderInputs) {++ if (ctxSI.outIsUsedByShader && ctxSI.shaderVar.builtin == spv::BuiltInMax &&++ ctxSI.shaderVar.location < kMVKMaxBufferCount &&++ std::find(boundLocations.begin(), boundLocations.end(), ctxSI.shaderVar.location) == boundLocations.end()) {++ auto vaDesc = inputDesc.attributes[ctxSI.shaderVar.location];++ if ((uint32_t)vaDesc.format == 0) {++ vaDesc.format = (decltype(vaDesc.format))MTLVertexFormatUChar4;++ vaDesc.bufferIndex = dummyBufferIndex;++ vaDesc.offset = 0;++ addedDummy = true;++ }++ }++ }++ if (addedDummy && !foundUsedBuffer) {++ auto vbDesc = inputDesc.layouts[dummyBufferIndex];++ vbDesc.stride = 1; // Metal requires a non-zero stride++ vbDesc.stepFunction = (decltype(vbDesc.stepFunction))MTLStepFunctionConstant;++ vbDesc.stepRate = 0;++ }++ }+++ // Run through the vertex bindings. Add a new Metal vertex layout for each translated binding,+ // identical to the original layout. The translated binding will index into the same MTLBuffer,+ // but at an offset that is one or more strides away from the original.+@@ -1940,7 +2037,8 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura+ }++ void MVKGraphicsPipeline::addFragmentOutputToPipeline(MTLRenderPipelineDescriptor* plDesc,+- const VkGraphicsPipelineCreateInfo* pCreateInfo) {++ const VkGraphicsPipelineCreateInfo* pCreateInfo,++ const SPIRVShaderOutputs* pFragOutputs) {+ // Topology+ if (pCreateInfo->pInputAssemblyState)+ plDesc.inputPrimitiveTopology = getPrimitiveTopologyClass();+@@ -1957,6 +2055,40 @@ static void setEmulatedReversedDepthViewportConfig(SPIRVToMSLConversionConfigura++ VkFormat attachFmt = pRendInfo->pColorAttachmentFormats[caIdx];+ MTLPixelFormat mtlPixFmt = getPixelFormats()->getMTLPixelFormat(attachFmt);++++ // HIGHBALL lenient-interfaces: Metal refuses a pipeline whose fragment output is float and whose++ // color attachment is an unsigned integer format, or the reverse ("output of type float4 is not++ // compatible with a MTLPixelFormatR32Uint color attachment"). Take a format of the output's kind++ // with the same bytes per pixel. pFragOutputs is filled only under HB_MVK_LENIENT_INTERFACES=1.++ if (pFragOutputs && mtlPixFmt) {++ for (const auto& so : *pFragOutputs) {++ if (so.builtin != spv::BuiltInMax || so.location != caLoc) { continue; }++ MVKFormatType fmtType = getPixelFormats()->getFormatType(mtlPixFmt);++ bool isFloatFmt = (fmtType == kMVKFormatColorHalf || fmtType == kMVKFormatColorFloat);++ bool isUIntFmt = (fmtType == kMVKFormatColorUInt8 || fmtType == kMVKFormatColorUInt16 || fmtType == kMVKFormatColorUInt32);++ MTLPixelFormat subFmt = MTLPixelFormatInvalid;++ if (so.baseType == SPIRV_CROSS_NAMESPACE::SPIRType::Float && isUIntFmt) {++ switch (getPixelFormats()->getBytesPerBlock(attachFmt)) {++ case 4: subFmt = MTLPixelFormatR32Float; break;++ case 8: subFmt = MTLPixelFormatRG32Float; break;++ case 16: subFmt = MTLPixelFormatRGBA32Float; break;++ }++ } else if (so.baseType == SPIRV_CROSS_NAMESPACE::SPIRType::UInt && isFloatFmt) {++ switch (getPixelFormats()->getBytesPerBlock(attachFmt)) {++ case 4: subFmt = MTLPixelFormatR32Uint; break;++ case 8: subFmt = MTLPixelFormatRG32Uint; break;++ case 16: subFmt = MTLPixelFormatRGBA32Uint; break;++ }++ }++ if (subFmt != MTLPixelFormatInvalid) {++ reportWarning(VK_ERROR_VALIDATION_FAILED, "HIGHBALL lenient-interfaces: fragment output %u does not match the kind of color attachment format %s; using %s.",++ caLoc, getPixelFormats()->getName(attachFmt), getPixelFormats()->getName(subFmt));++ mtlPixFmt = subFmt;++ }++ break;++ }++ }+++ bool supportsBlend = getPixelFormats()->getCapabilities(mtlPixFmt) & kMVKMTLFmtCapsBlend;+ MTLRenderPipelineColorAttachmentDescriptor* colorDesc = plDesc.colorAttachments[caLoc];+ colorDesc.pixelFormat = mtlPixFmt;diff --git a/resources/steam-support.json b/resources/steam-support.jsonindex 298393287de..f802dcbe7d2 100644--- a/resources/steam-support.json+++ b/resources/steam-support.json@@ -1,20 +1,22 @@{- "version": "steam-support-v4",+ "version": "steam-support-v5","wine_version": "wine-11.0","minimum_macos": "26.0",- "url": "https://github.com/BCD1210/soju/releases/download/steam-support-v4/soju-steam-support-v4.tar.gz",- "sha256": "1624e5c05e644456d16f505b9327fded0d5e7608e98051b9ec2f3b5d7c3512ab",- "source_url": "https://github.com/BCD1210/soju/releases/download/steam-support-v4/soju-steam-support-v4-sources.tar.gz",+ "url": "https://github.com/BCD1210/soju/releases/download/steam-support-v5/soju-steam-support-v5.tar.gz",+ "sha256": "95560be419621b72ad5e10d47c3cff08363369a209ba1db913ff5b0dc356b8bf",+ "source_url": "https://github.com/BCD1210/soju/releases/download/steam-support-v5/soju-steam-support-v5-sources.tar.gz","files": {- "SOURCES.txt": "b61d171123b4f05afdcdbf40c8600d177f142b8435f95a2ab149793ba3d588f1",+ "SOURCES.txt": "a961bc3a62478ccdd27ddf70f2b59ea4e66209a3a4557421aa2c01e28aed9d15","dxmt-x64/d3d10core.dll": "53bc695d1408abd9067cf219a70e11c2f00d0c9c4c1065516de0fcfc81b95186","dxmt-x64/d3d11.dll": "5c3056229d1cbcca67fdad1f89755f45e77c3adfd216905b265589ffba1400ce","dxmt-x64/dxgi.dll": "ec286d4323c2ac18fc405067526c93b07a9f5f1cef719ab15829e48b8bed79b9","dxmt-x64/winemetal.dll": "799b0a094e6b0b9d1d967956ea8bff67792abdf24741a7a7035bf3e08febf7c5","dxmt-x64/winemetal.so": "6ae39285534a645ce4f33e55c07bcdc111847231bf42b005d260b1b2ae6913dc",+ "libMoltenVK.dylib": "335fea790c1a1d599f6ad6f0f399d25839b9ff866c5b363d2b07895a43e9e680","licenses/DXMT-MIT.txt": "6b928413c6308c106f3e0080bd94b6427b56d587d400fd40e6cbfbab7d9c4ae1","licenses/DirectX-headers.txt": "f38e6194bd3bfa1b654f118e5acefe0aead437bbe669eee43957ccc65a7127f1","licenses/LLVM.txt": "8d85c1057d742e597985c7d4e6320b015a9139385cff4cbae06ffc0ebe89afee",+ "licenses/MoltenVK-Apache.txt": "cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30","licenses/Wine-LGPL.txt": "e237fa56668030e928551ddd60f05df5fe957f75eab874bbd017e085ed722e7c","licenses/wrapper-MIT.txt": "9678fa46fccba251d0444f19d73a4ca76118f33dbc711c8a4c73e7b63c62a1fa","mmdevapi-x64.dll": "349f60c04d7954cb0f6ca38d9e2a845312e6d444042c2b27f6cdb96b44ba4146",diff --git a/scripts/build-moltenvk.sh b/scripts/build-moltenvk.shnew file mode 100755index 00000000000..0de33eb6ce1--- /dev/null+++ b/scripts/build-moltenvk.sh@@ -0,0 +1,31 @@+#!/usr/bin/env bash+# Build the MoltenVK in the Steam support package (libMoltenVK.dylib): upstream v1.4.2 plus+# patches/moltenvk/*.patch, x86_64 only (the Steam runtime's Wine runs under Rosetta).+# bash scripts/build-moltenvk.sh [out-dir]+# Needs Xcode. The patches come from Highball (GPL-3.0-or-later): cache-drawid-present fixes the+# draw ID of direct draws, an empty pipeline cache read and a present that read a released image;+# lenient-interfaces (only with HB_MVK_LENIENT_INTERFACES=1) gives a vertex attribute the pipeline+# does not describe a placeholder and lets a color attachment take the fragment output's kind.+# Together they let Detroit: Become Human compile its pipelines (DrawIndex) and draw.+set -euo pipefail+ROOT="$(cd "$(dirname "$0")/.." && pwd)"+TAG=v1.4.2+COMMIT=db66022459ffb663aa2b50f6b018bc2e124f5edf+OUT="${1:-$ROOT/build/moltenvk}"+WORK="$(mktemp -d)"+trap 'rm -rf "$WORK"' EXIT+git clone -q --depth 1 --branch "$TAG" https://github.com/KhronosGroup/MoltenVK.git "$WORK/src"+[ "$(git -C "$WORK/src" rev-parse HEAD)" = "$COMMIT" ] || { echo "MoltenVK $TAG is not $COMMIT" >&2; exit 1; }+for p in cache-drawid-present lenient-interfaces; do git -C "$WORK/src" apply "$ROOT/patches/moltenvk/$p.patch"; done+(cd "$WORK/src" && ./fetchDependencies --macos)+(cd "$WORK/src" && xcodebuild build -project MoltenVKPackaging.xcodeproj -scheme "MoltenVK Package (macOS only)" \+ -destination "generic/platform=macOS" -configuration Release ARCHS=x86_64 ONLY_ACTIVE_ARCH=NO -quiet)+DYLIB="$WORK/src/Package/Release/MoltenVK/dynamic/dylib/macOS/libMoltenVK.dylib"+MARKS="$(strings -a "$DYLIB")"+for p in cache-drawid-present lenient-interfaces; do+ grep -q "HIGHBALL $p" <<< "$MARKS" || { echo "patch missing from build: $p" >&2; exit 1; }+done+mkdir -p "$OUT"+cp "$DYLIB" "$OUT/libMoltenVK.dylib"+cp "$WORK/src/LICENSE" "$OUT/MoltenVK-Apache.txt"+echo "Built $OUT/libMoltenVK.dylib ($(shasum -a 256 "$OUT/libMoltenVK.dylib" | cut -c1-64))"diff --git a/scripts/play.sh b/scripts/play.shindex eaea3edb8c8..d17ba29a7e3 100755--- a/scripts/play.sh+++ b/scripts/play.sh@@ -338,6 +338,21 @@ case "$MODE" in[[ -x "$WINESTABLE" ]] || { echo "Steam runtime not found. Reinstall Steam from Platforms or run: soju steam-install"; exit 1; }ST="$WINEPREFIX/drive_c/Program Files (x86)/Steam/steam.exe"[[ -f "$ST" ]] || { echo "Steam not found, run scripts/create-steam-bottle.sh first"; exit 1; }+ # A newer Steam support package (resources/steam-support.json) is set up before Steam+ # starts, so an app update brings its components without Update components.+ if [ -f "$STEAM_WINE_ROOT/.soju-runtime" ] && ! pgrep -f "$WINESTABLE_SERVER" >/dev/null 2>&1; then+ want=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1]))["version"])' \+ "$(dirname "${BASH_SOURCE[0]}")/../resources/steam-support.json" 2>/dev/null || true)+ if [ -n "$want" ] && [ "$(cat "$STEAM_WINE_ROOT/.soju-runtime")" != "$want" ]; then+ echo "Updating Steam components to $want"+ bash "$(dirname "${BASH_SOURCE[0]}")/setup-steam-games.sh" || echo "soju: Steam component update failed; Steam starts with the previous ones" >&2+ fi+ fi+ # Vulkan games through MoltenVK (Detroit: Become Human, Highball's settings): compile shaders+ # on every core, keep their source compressed, and let pipelines whose vertex inputs or color+ # outputs do not match exactly still build (the patched MoltenVK in the support package).+ export MVK_CONFIG_SHOULD_MAXIMIZE_CONCURRENT_COMPILATION=1 MVK_CONFIG_SHADER_COMPRESSION_ALGORITHM=1+ export HB_MVK_LENIENT_INTERFACES=1# Repair a bootstrap-only installation before deploying the CEF wrapper.python3 "$(dirname "${BASH_SOURCE[0]}")/bootstrap-steam.py" "$WINESTABLE"# Known DXVK games (resources/steam-profiles.json) get DXVK once, before Steamdiff --git a/scripts/setup-steam-games.sh b/scripts/setup-steam-games.shindex 4444cb596ee..b51ab359915 100755--- a/scripts/setup-steam-games.sh+++ b/scripts/setup-steam-games.sh@@ -100,6 +100,12 @@ if [ -f "$SUP/winecoreaudio-patched.so" ]; thencp -f "$SUP/winecoreaudio-patched.so" "$WLIB/x86_64-unix/winecoreaudio.so"cp -f "$SUP/mmdevapi-x64.dll" "$WLIB/x86_64-windows/mmdevapi.dll"fi+# MoltenVK 1.4.2 with Highball's Detroit: Become Human patches (scripts/build-moltenvk.sh), for+# games that draw with Vulkan and for DXVK. Older support packages have none: the runtime's stays.+if [ -f "$SUP/libMoltenVK.dylib" ]; then+ [ -f "$WAPP/lib/libMoltenVK.dylib.vanilla" ] || cp -f "$WAPP/lib/libMoltenVK.dylib" "$WAPP/lib/libMoltenVK.dylib.vanilla"+ cp -f "$SUP/libMoltenVK.dylib" "$WAPP/lib/libMoltenVK.dylib"+fi# i386 stays vanilla (protects the 32-bit steam.exe composer)BACKUP="$BASE/steam-support/prefix-backup-$(date +%Y%m%d-%H%M%S)"