diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index aab3707..4893f6d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -67,24 +67,102 @@ jobs: BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL: ${{ secrets.BANNERLORD_BUTR_COMPATIBILITY_SCORE_URL }} shell: pwsh - - name: Add GPU acceleration hint + - name: Upload Bannerlord folder + uses: actions/upload-artifact@v4 + with: + name: bannerlord-tmp-${{matrix.project}}-${{matrix.configuration}} + path: ./bannerlord/ + + gpu-hint: + name: Add GPU Hints + needs: [build] + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup + uses: butr/actions-common-setup@v2 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + + - name: Download Bannerlord Temp artifact Pattern + uses: actions/download-artifact@v4 + with: + pattern: bannerlord-tmp-* + merge-multiple: true + path: ./bannerlord + continue-on-error: true + + - name: Add Dedicated GPU Hint run: | - # dotnet tool install -g Topten.nvpatch; - # $env:DOTNET_ROLL_FORWARD="Major"; - dotnet tool install -g dotnet-script; + echo "Downloading ILAsm"; + Invoke-WebRequest https://globalcdn.nuget.org/packages/runtime.win-x64.microsoft.netcore.ilasm.8.0.0.nupkg -OutFile ilasm.nupkg; + Invoke-WebRequest https://globalcdn.nuget.org/packages/runtime.win-x64.microsoft.netcore.ildasm.8.0.0.nupkg -OutFile ildasm.nupkg; + echo "Extracting ILAsm"; + Expand-Archive ilasm.nupkg -d tools/ilasm; + Expand-Archive ildasm.nupkg -d tools/ildasm; + #echo "chmod ILAsm"; + #chmod +x tools/ilasm/runtimes/linux-x64/native/ilasm; + #chmod +x tools/ildasm/runtimes/linux-x64/native/ildasm; + + # So what is happening here? + # We're not able to export global variables from C# + # But ILAsm is able to do it + # So we compile our .exe files from C# + # Then we decompile them with ILDasm + # Then we compile them back to .exe with ILAsm and with the .il file for exporting the global variable + # Then we set the icon back because ILAsm doesn't support setting the icon + $workingDir = "$PWD"; + mkdir tmp; + + cd build/set-icon; + yarn install; + cd $workingDir; + + $fileNames = Get-ChildItem -Path "bannerlord/" -Recurse -Include *.exe; foreach ($f in $fileNames) { + cd $workingDir/tmp; + echo $f.FullName; - # nvpatch --enable $f.FullName; - dotnet script build/gpu.csx -- --enable-gpu "$f"; + + $runtime = ""; + If ($f.FullName.Contains("Win64_Shipping_Client")) { + $runtime = "Win64_Shipping_Client"; + } + If ($f.FullName.Contains("Gaming.Desktop.x64_Shipping_Client")) { + $runtime = "Gaming.Desktop.x64_Shipping_Client"; + } + + $fileDirname = $f.DirectoryName; + $dirname = [System.IO.Path]::GetFileNameWithoutExtension($f.FullName); + New-Item -ItemType Directory -Path $dirname/$runtime -Force + cd $dirname/$runtime; + + # Decompile to IL Code + & "$workingDir/tools/ildasm/runtimes/win-x64/native/ildasm.exe" "$f" /OUT=Code.il + #& "$workingDir/tools/ildasm/runtimes/linux-x64/native/ildasm" "$f" -OUT="Code.il" + Copy-Item -Path $workingDir/build/ForceDedicatedGraphicCard.il -Destination ForceDedicatedGraphicCard.il; + + # Recompile to .exe + & "$workingDir/tools/ilasm/runtimes/win-x64/native/ilasm.exe" -QUIET -NOLOGO -OPTIMIZE -EXE /X64 -OUTPUT="$dirname.exe" Code.il ForceDedicatedGraphicCard.il + #& "$workingDir/tools/ilasm/runtimes/linux-x64/native/ilasm" -QUIET -NOLOGO -OPTIMIZE -EXE -X64 -OUTPUT="$dirname.exe" Code.il ForceDedicatedGraphicCard.il + + # Set Icon + cd $workingDir/build/set-icon; + node index.js "$workingDir/tmp/$dirname/$runtime/$dirname.exe" "$workingDir/resources/BLSE_SMALL.ico"; + + Copy-Item -Path "$workingDir/tmp/$dirname/$runtime/$dirname.exe" -Destination "$fileDirname/$dirname.exe" -force } + cd $workingDir; + rmdir tmp -Recurse -Force; shell: pwsh - name: Upload Bannerlord folder uses: actions/upload-artifact@v4 with: - name: bannerlord-${{matrix.project}}-${{matrix.configuration}} + name: bannerlord path: ./bannerlord/ ########################### @@ -92,14 +170,14 @@ jobs: ########################### publish-on-nexusmods: if: github.ref == 'refs/heads/master' - needs: [get-changelog, build] + needs: [get-changelog, build, gpu-hint] uses: BUTR/workflows/.github/workflows/release-nexusmods.yml@master with: nexusmods_game_id: mountandblade2bannerlord nexusmods_mod_id: 1 mod_filename: 'Bannerlord Software Extender (BLSE)' mod_version: ${{ needs.get-changelog.outputs.mod_version }} - mod_description: ${{ needs.build.outputs.mod_description }} + mod_description: ${{ needs.get-changelog.outputs.mod_description }} artifact_name: bannerlord secrets: NEXUSMODS_APIKEY: ${{ secrets.ARAGAS_NEXUSMODS_API_KEY }} @@ -110,12 +188,12 @@ jobs: ########################### publish-on-github: if: github.ref == 'refs/heads/master' - needs: [get-changelog, build] + needs: [get-changelog, build, gpu-hint] uses: BUTR/workflows/.github/workflows/release-github.yml@master with: mod_id: Bannerlord.BLSE mod_version: ${{ needs.get-changelog.outputs.mod_version }} - mod_description: ${{ needs.build.outputs.mod_description }} + mod_description: ${{ needs.get-changelog.outputs.mod_description }} artifact_name: bannerlord ########################### @@ -123,7 +201,7 @@ jobs: ########################### publish-on-steam: if: false && github.ref == 'refs/heads/master' - needs: [get-changelog, build] + needs: [get-changelog, build, gpu-hint] runs-on: ubuntu-latest steps: - name: Download Module artifact diff --git a/.gitignore b/.gitignore index 1217d9e..30f401f 100644 --- a/.gitignore +++ b/.gitignore @@ -349,3 +349,5 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ /src/.idea/* +/tmp/* +/tools/* diff --git a/build/ForceDedicatedGraphicCard.il b/build/ForceDedicatedGraphicCard.il new file mode 100644 index 0000000..7f9ccb3 --- /dev/null +++ b/build/ForceDedicatedGraphicCard.il @@ -0,0 +1,15 @@ + .class public Bannerlord.BLSE.ForceDedicatedGraphicCard + { + .method public static int32 NvOptimusEnablement() cil managed + { + .export [1] + ldc.i4.1 + ret + } + .method public static uint32 AmdPowerXpressRequestHighPerformance() cil managed + { + .export [2] + ldc.i4.1 + ret + } + } \ No newline at end of file diff --git a/build/common.props b/build/common.props index 0e6399c..722b11d 100644 --- a/build/common.props +++ b/build/common.props @@ -11,7 +11,7 @@ - 1.5.5 + 1.5.6 2.2.2 3.0.0.139 5.0.222 diff --git a/build/set-icon/index.js b/build/set-icon/index.js new file mode 100644 index 0000000..8791ac1 --- /dev/null +++ b/build/set-icon/index.js @@ -0,0 +1,7 @@ +const changeExe = require('changeexe'); + +const args = process.argv; + +(async () => { + await changeExe.icon(args[2], args[3]); +})(); \ No newline at end of file diff --git a/build/set-icon/package.json b/build/set-icon/package.json new file mode 100644 index 0000000..b6be7c4 --- /dev/null +++ b/build/set-icon/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "changeexe": "^1.0.3" + } +} diff --git a/build/set-icon/yarn.lock b/build/set-icon/yarn.lock new file mode 100644 index 0000000..c19f53b --- /dev/null +++ b/build/set-icon/yarn.lock @@ -0,0 +1,15 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +adm-zip@^0.5.10: + version "0.5.12" + resolved "https://registry.yarnpkg.com/adm-zip/-/adm-zip-0.5.12.tgz#87786328e91d54b37358d8a50f954c4cd73ba60b" + integrity sha512-6TVU49mK6KZb4qG6xWaaM4C7sA/sgUMLy/JYMOzkcp3BvVLpW0fXDFQiIzAuxFCt/2+xD7fNIiPFAoLZPhVNLQ== + +changeexe@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/changeexe/-/changeexe-1.0.3.tgz#e9ccc889aa78179edce7128bb09bf0ff379c65ac" + integrity sha512-UpX2cVZW7smLML+fmdvBw12Nhz1PxODswpOx+9kYDOY+IWSntuFVaC3nFVIJ6+3dmZNFbwR2DDrkBrV861KRCA== + dependencies: + adm-zip "^0.5.10" diff --git a/changelog.txt b/changelog.txt index 8da57d9..3af9ec0 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 1.5.6 +Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.x +* BETA Release! +* Added back support for GPU Acceleration Hints +--------------------------------------------------------------------------------------------------- Version: 1.5.5 Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0,v1.1.1,v1.1.2,v1.1.3,v1.1.4,v1.1.5,v1.1.6,v1.2.x * BETA Release!