From 819c2511e0f1d920f7a04683ce07cfbc978b168e Mon Sep 17 00:00:00 2001 From: Kirill Artemov Date: Sat, 17 May 2025 19:17:08 +0200 Subject: [PATCH] Added install_llvmpipe script to replace -nographics in Windows builds (#706) * Added install_llvmpipe script * Replace ternary with a regular condition * Revert files I haven't changed * Pin llvmpipe version, expand test matrix with a single enableGPU target * Fixed parameter name * EnableGPU false by default * Fixed nitpick * Fixed scripts * Pass enableGpu into tests properly * Fixed script * Append With GPU to build name * Fix expression --- .github/workflows/build-tests-windows.yml | 13 ++++- dist/index.js | Bin 15142537 -> 15142127 bytes dist/index.js.map | Bin 16834012 -> 16834013 bytes dist/platforms/windows/build.ps1 | 9 +++- dist/platforms/windows/entrypoint.ps1 | 5 ++ dist/platforms/windows/install_llvmpipe.ps1 | 56 ++++++++++++++++++++ 6 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 dist/platforms/windows/install_llvmpipe.ps1 diff --git a/.github/workflows/build-tests-windows.yml b/.github/workflows/build-tests-windows.yml index db2fab20..c0c5de19 100644 --- a/.github/workflows/build-tests-windows.yml +++ b/.github/workflows/build-tests-windows.yml @@ -26,6 +26,14 @@ jobs: - StandaloneWindows64 # Build a Windows 64-bit standalone. - WSAPlayer # Build a UWP App - tvOS # Build an Apple TV XCode project + enableGpu: + - false + include: + # Additionally test enableGpu build for a standalone windows target + - projectPath: test-project + unityVersion: 2023.2.2f1 + targetPlatform: StandaloneWindows64 + enableGpu: true steps: ########################### @@ -71,6 +79,7 @@ jobs: projectPath: ${{ matrix.projectPath }} unityVersion: ${{ matrix.unityVersion }} targetPlatform: ${{ matrix.targetPlatform }} + enableGpu: ${{ matrix.enableGpu }} customParameters: -profile SomeProfile -someBoolean -someValue exampleValue allowDirtyBuild: true # We use dirty build because we are replacing the default project settings file above @@ -96,6 +105,7 @@ jobs: projectPath: ${{ matrix.projectPath }} unityVersion: ${{ matrix.unityVersion }} targetPlatform: ${{ matrix.targetPlatform }} + enableGpu: ${{ matrix.enableGpu }} customParameters: -profile SomeProfile -someBoolean -someValue exampleValue allowDirtyBuild: true # We use dirty build because we are replacing the default project settings file above @@ -120,6 +130,7 @@ jobs: projectPath: ${{ matrix.projectPath }} unityVersion: ${{ matrix.unityVersion }} targetPlatform: ${{ matrix.targetPlatform }} + enableGpu: ${{ matrix.enableGpu }} customParameters: -profile SomeProfile -someBoolean -someValue exampleValue allowDirtyBuild: true # We use dirty build because we are replacing the default project settings file above @@ -129,6 +140,6 @@ jobs: ########################### - uses: actions/upload-artifact@v4 with: - name: Build ${{ matrix.targetPlatform }} on Windows (${{ matrix.unityVersion }}) + name: Build ${{ matrix.targetPlatform }} on Windows (${{ matrix.unityVersion }})${{ matrix.enableGpu && ' With GPU' || '' }} path: build retention-days: 14 diff --git a/dist/index.js b/dist/index.js index 7ffa95afa17d8170df1abe277b44721221e89e71..aafcec4f7e08fb9fb897c240e23fc1403310e7a3 100644 GIT binary patch delta 2818 zcma*pX;f5476}$sDu$2P0!>^M8^~N==_0mRKDc+;rC9}y;ZkfRlN^y zZF!lh{i`xn$r0)K1xjd?-cc`FFgGPo+B@0Wl04f=4rs98B%l2j+ zZxcmfb#mz+E;95j>ND!ctn3`9_lY%QpIGxDH#TJlI_a~#6`dI;Ygo`t(q9$|8kQZ#Ku0&E}{toah{<$2hP8Yp?-Z z=mBPT)OgqCoC)~}^quT~6TwZh+J0-Y=hu%;0PKcyjL zvcCsqpAL59xIBO5W?C{M)S3p(4N$W4sNoY7%=Q7#@+fOscwcf)4)@eQToV8TVGsnu zU>E{HFcjY5hiit}o_JkJk4g}XiXjuWQPu6xqwIb=WJ?31ImMjqz6q@e>S!NWN$Vd( z*wDe60SeAZ3mahG5hW#ETozu#i+%~&t>P`q!_;k^H7F}M+?-lBMXaXy{BSKlNe)jl z>&jF)1}dpKCEP#}bHf8^MsT>Af1eYsl3u47=>psCh3xefi^JJsafF-e>jYzk%gU}k z-rAF9X;C~bFKm$hp{f^2=h=LIi4I|+_7zHsf8pgo; zFc!u^ER2UZ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(8{4~s0e#8S&F zx57%R{Asl{{_?kfthLU18*H@6X8#JY#a5xV*=~oOcG+!@z4qDffP)S>?1-a|Iqrm$ zPC4z2v(7p1f{QM>?24X zY_iKCr(AN&Bd>h&E1;l43M-|MRaH}64K>wLTOD=P zQ(prOHPToUO*PY83oW(MS{rS((_RNZ>!_2?y6CE#?t18{m)`p5>leTJO+Wn&Fwh`_ z4KY-ZVTKFF2qTR$+8ASvGu{LfO)}XOQ%y773^UC#+Z=PvGv5LWEwb1WOD(h93cvfq zN~`?oFRQJw);jBLu+b))ZL!rhA-3Bg)K0tXw#Q!k?03LHha7gqQO6v2!bzu`_O~<6 zI_JC#F1qBhE3Ufcx-j8xxapSL?zroo`yP1ck;k6+$5a3M&;Ooz?uD0LdF_q2-g)nX Pk3RYAi?1O8Vd38ZAgT&O diff --git a/dist/platforms/windows/build.ps1 b/dist/platforms/windows/build.ps1 index 6b126058..ac78d62b 100644 --- a/dist/platforms/windows/build.ps1 +++ b/dist/platforms/windows/build.ps1 @@ -148,13 +148,20 @@ Write-Output "# Building project #" Write-Output "###########################" Write-Output "" +$unityGraphics = "-nographics" + +if ($LLVMPIPE_INSTALLED -eq "true") +{ + $unityGraphics = "-force-opengl" +} + # If $Env:CUSTOM_PARAMETERS contains spaces and is passed directly on the command line to Unity, powershell will wrap it # in double quotes. To avoid this, parse $Env:CUSTOM_PARAMETERS into an array, while respecting any quotations within the string. $_, $customParametersArray = Invoke-Expression('Write-Output -- "" ' + $Env:CUSTOM_PARAMETERS) $unityArgs = @( "-quit", "-batchmode", - "-nographics", + $unityGraphics, "-silent-crashes", "-customBuildName", "`"$Env:BUILD_NAME`"", "-projectPath", "`"$Env:UNITY_PROJECT_PATH`"", diff --git a/dist/platforms/windows/entrypoint.ps1 b/dist/platforms/windows/entrypoint.ps1 index 4d7057e6..81d2bf0c 100644 --- a/dist/platforms/windows/entrypoint.ps1 +++ b/dist/platforms/windows/entrypoint.ps1 @@ -13,6 +13,11 @@ Get-Process -Name regsvr32 | ForEach-Object { Stop-Process -Id $_.Id -Force } # Setup Git Credentials . "c:\steps\set_gitcredential.ps1" +if ($env:ENABLE_GPU -eq "true") { + # Install LLVMpipe software graphics driver + . "c:\steps\install_llvmpipe.ps1" +} + # Activate Unity if ($env:SKIP_ACTIVATION -ne "true") { . "c:\steps\activate.ps1" diff --git a/dist/platforms/windows/install_llvmpipe.ps1 b/dist/platforms/windows/install_llvmpipe.ps1 new file mode 100644 index 00000000..fa88d2ea --- /dev/null +++ b/dist/platforms/windows/install_llvmpipe.ps1 @@ -0,0 +1,56 @@ +$Private:repo = "mmozeiko/build-mesa" +$Private:downloadPath = "$Env:TEMP\mesa.zip" +$Private:extractPath = "$Env:TEMP\mesa" +$Private:destinationPath = "$Env:UNITY_PATH\Editor\" +$Private:version = "25.1.0" + +$LLVMPIPE_INSTALLED = "false" + +try { + # Get the release info from GitHub API (version fixed to decrease probability of breakage) + $releaseUrl = "https://api.github.com/repos/$repo/releases/tags/$version" + $release = Invoke-RestMethod -Uri $releaseUrl -Headers @{ "User-Agent" = "PowerShell" } + + # Get the download URL for the zip asset + $zipUrl = $release.assets | Where-Object { $_.name -like "mesa-llvmpipe-x64*.zip" } | Select-Object -First 1 -ExpandProperty browser_download_url + + if (-not $zipUrl) { + throw "No zip file found in the latest release." + } + + # Download the zip file + Write-Host "Downloading $zipUrl..." + Invoke-WebRequest -Uri $zipUrl -OutFile $downloadPath + + # Create extraction directory if it doesn't exist + if (-not (Test-Path $extractPath)) { + New-Item -ItemType Directory -Path $extractPath | Out-Null + } + + # Extract the zip file + Write-Host "Extracting $downloadPath to $extractPath..." + Expand-Archive -Path $downloadPath -DestinationPath $extractPath -Force + + # Create destination directory if it doesn't exist + if (-not (Test-Path $destinationPath)) { + New-Item -ItemType Directory -Path $destinationPath | Out-Null + } + + # Copy extracted files to destination + Write-Host "Copying files to $destinationPath..." + Copy-Item -Path "$extractPath\*" -Destination $destinationPath -Recurse -Force + + Write-Host "Successfully downloaded, extracted, and copied Mesa files to $destinationPath" + + $LLVMPIPE_INSTALLED = "true" +} catch { + Write-Error "An error occurred: $_" +} finally { + # Clean up temporary files + if (Test-Path $downloadPath) { + Remove-Item $downloadPath -Force + } + if (Test-Path $extractPath) { + Remove-Item $extractPath -Recurse -Force + } +}