Luma: Fix constant buffer tracking #389
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release Luma Mods | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| # runs-on: windows-2025-vs2026 | |
| strategy: | |
| matrix: | |
| config: [Development-Debug, Development-Release, Test-Release, Publishing-Release] | |
| platform: [x64, Win32] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 0 | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v1.1.2 | |
| - name: Clone vcpkg | |
| run: git clone https://github.com/microsoft/vcpkg.git | |
| - name: Bootstrap vcpkg | |
| run: .\vcpkg\bootstrap-vcpkg.bat | |
| # Exclusively for Prey (which is x64). Ideally it should find the vcpkg.json automatically | |
| - name: Install vcpkg packages | |
| run: | | |
| .\vcpkg\vcpkg install --triplet x64-windows --x-manifest-root=./Source/Games/Prey | |
| #.\vcpkg\vcpkg install --triplet x86-windows --x-manifest-root=./Source/Games/Prey | |
| continue-on-error: true | |
| - name: Integrate vcpkg with MSBuild | |
| run: .\vcpkg\vcpkg integrate install | |
| # This requires the git directory to be added to the PATH Windows environment variables, to properly set up versioning information | |
| - name: Build ReShade.sln Release | |
| run: | | |
| msbuild "Source\External\reshade\ReShade.sln" /p:Configuration="Release" /p:Platform="64-bit" | |
| msbuild "Source\External\reshade\ReShade.sln" /p:Configuration="Release" /p:Platform="32-bit" | |
| continue-on-error: true | |
| - name: Build Luma.sln ${{ matrix.config }}-${{ matrix.platform }} | |
| run: | | |
| msbuild Luma.sln /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }} /p:DefineConstants="REMOTE_BUILD=1" | |
| continue-on-error: true # if only one or a few games failed to build, we should still build and package+release the other # TODO: add code to avoid doing an empty release if they all failed to build | |
| - name: Create ZIP per addon with matching shaders | |
| id: create_zip | |
| shell: pwsh | |
| # We only build publishing and test for now, development builds can be built locally by devs (with the exclusion of the Generic and Graphics Analyzer mod, which can also be used to quickly download a dev/debug environment) | |
| if: matrix.config == 'Publishing-Release' || matrix.config == 'Test-Release' || matrix.config == 'Development-Release' | |
| run: | | |
| # Scan vcxproj files to find projects that use NGX (DLSS) | |
| $ngxProjects = @() | |
| $vcxprojFiles = Get-ChildItem -Path "Source/Games" -Filter "*.vcxproj" -Recurse | |
| foreach ($vcxproj in $vcxprojFiles) { | |
| $content = Get-Content $vcxproj.FullName -Raw | |
| if ($content -match 'nvsdk_ngx') { | |
| $projectName = [System.IO.Path]::GetFileNameWithoutExtension($vcxproj.Name) | |
| $ngxProjects += $projectName | |
| Write-Host "Found NGX project: $projectName" | |
| } | |
| } | |
| Write-Host "NGX projects: $($ngxProjects -join ', ')" | |
| # Find the addon file in the build folder (adjust path accordingly) | |
| $addonDir = "Binaries\${{ matrix.platform }}-${{ matrix.config }}" | |
| $addonFiles = Get-ChildItem -Path $addonDir -Filter "Luma-*.addon" | |
| if ($addonFiles.Count -eq 0) { | |
| Write-Host "No addon files found." | |
| "skip_upload=true" >> $env:GITHUB_OUTPUT | |
| exit 0 | |
| } | |
| "skip_upload=false" >> $env:GITHUB_OUTPUT | |
| foreach ($addonFile in $addonFiles) { | |
| if (-not $addonFile) { | |
| Write-Host "Addon file not found, it's likely this configuration isn't present for this project. Skipping." | |
| continue | |
| } | |
| # Extract project name by removing prefix 'Luma-' and suffix '.addon' | |
| $fileName = $addonFile.Name | |
| # Replace "Luma-_" with "Luma-" in the filename, given that some projects (e.g. template, generic mod etc) might have an underscore in front of them to appear on top in alphabetical order | |
| $cleanFileName = $fileName -replace '^Luma-_', 'Luma-' | |
| $projectName = $cleanFileName -replace '^Luma-', '' -replace '\.addon$', '' | |
| $zipName = "Luma-$projectName" | |
| # Add "Test" tag for test builds | |
| if ("${{ matrix.config }}" -eq "Test-Release") { | |
| $zipName += "-Test" | |
| } | |
| # Add "Dev" tag for developments builds | |
| if ("${{ matrix.config }}" -eq "Development-Release") { | |
| $zipName += "-Dev" | |
| } | |
| if ("${{ matrix.config }}" -eq "Development-Debug") { | |
| $zipName += "-Dev-Dbg" | |
| } | |
| # Avoid naming conflicts if mods have both x64 and x32 versions | |
| if ("${{ matrix.platform }}" -eq "Win32") { | |
| $zipName += "-x32" | |
| } | |
| # Turn spaces into another nice looking character, given that the github release will replace them with a '.', which is more weird | |
| $zipName = $zipName -replace ' ', '_' | |
| $zipName += ".zip" | |
| Write-Host "Project name extracted: $projectName" | |
| # TODO: remove "_" from "Generic Mod" | |
| # We don't care to publish the template project, it's just there for reference | |
| if ($projectName -like '_Template' -or $projectName -like 'Template') { | |
| Write-Host "Project is a template. Skipping ZIP creation and upload." | |
| continue | |
| } | |
| # Allow the Generic and Graphics Analyzer mods to be downloaded directly | |
| elseif ("${{ matrix.config }}".StartsWith("Development") -and -not ( | |
| $projectName -like '_Generic' -or | |
| $projectName -like 'Generic' -or | |
| $projectName -like '_Generic Mod' -or | |
| $projectName -like 'Generic Mod' -or | |
| $projectName -like 'Graphics Analyzer' | |
| )) { | |
| continue | |
| } | |
| #if ($projectName -like '*Prey*') { | |
| # Write-Host "Note that Prey automated packaging isn't the whole Luma mod, that needs manual packaging as it comes with extra files." | |
| #} | |
| # Create a temp directory | |
| $tempDir = "temp_package" | |
| Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue | |
| New-Item -ItemType Directory -Path "$tempDir/Luma" -Force | Out-Null | |
| # Copy shaders folder contents into Data subfolder | |
| Copy-Item -Path "Shaders/*" -Destination "$tempDir/Luma" -Recurse | |
| # Allowed subdirectories | |
| $allowedDirs = @("Global", "Includes", $projectName) | |
| # Allowed file extensions | |
| $allowedExtensions = @(".hlsl", ".hlsli") | |
| # Full path to the copied Shaders folder | |
| $shaderRoot = Join-Path $tempDir "Luma" | |
| # Remove disallowed folders (e.g. shaders for other mods) immediately inside $shaderRoot | |
| Get-ChildItem -Path $shaderRoot -Directory | ForEach-Object { | |
| if ($allowedDirs -notcontains $_.Name) { | |
| Write-Host "Removing disallowed folder: $($_.FullName)" | |
| Remove-Item $_.FullName -Recurse -Force | |
| } elseif (-not "${{ matrix.config }}".StartsWith("Development")) { | |
| # Inside allowed folders, delete specific subfolders that we don't need for non dev builds | |
| $foldersToDelete = @("Unused", "Dev", "Sample") | |
| foreach ($folder in $foldersToDelete) { | |
| $target = Join-Path $_.FullName $folder | |
| if (Test-Path $target) { | |
| Write-Host "Removing subfolder from allowed dir: $target" | |
| Remove-Item $target -Recurse -Force | |
| } | |
| } | |
| } | |
| } | |
| # Get all files under the copied Shaders folder | |
| Get-ChildItem -Path $shaderRoot -Recurse -File | ForEach-Object { | |
| $relativePath = [System.IO.Path]::GetRelativePath($shaderRoot, $_.FullName) | |
| # Extract top-level directory (first segment) | |
| $topDir = ($relativePath -split '[\\/]', 2)[0] | |
| #Write-Host "Checking file: $($_.Name), Extension: $($_.Extension), TopDir: $topDir" | |
| # Check if it's a .hlsl/hlsli file in an allowed directory | |
| #if ( $allowedExtensions -notcontains $_.Extension.ToLower() -or ($allowedDirs -notcontains $topDir)) { | |
| if ($allowedExtensions -notcontains $_.Extension.ToLower()) { | |
| #Write-Host "Removing: $($_.FullName)" | |
| Remove-Item $_.FullName -Force | |
| } | |
| } | |
| # Copy shaders folder contents into Data subfolder | |
| # Note: ideally these should be updated once in a while, I got them from "C:\Program Files (x86)\Windows Kits\10\Redist\D3D\...", which seemengly had the latest version for redistribution (the one in System32 doesn't seem to be for that, even if it'd probably work) | |
| if ("${{ matrix.platform }}" -eq "Win32") { | |
| Copy-Item -Path "Shaders/Decompiler/d3dcompiler_47_x32.dll" -Destination "$tempDir/Luma" | |
| } | |
| else { | |
| Copy-Item -Path "Shaders/Decompiler/d3dcompiler_47.dll" -Destination "$tempDir/Luma" | |
| } | |
| # Bundle in ReShade files (assuming DX10/11/12), for simplicity (to avoid users from having to download it separately, and being able to distribute the right version for luma, possibly even a custom one) (ReShade should automatically generate configs, or re-use the ones that were there) | |
| # Note: these might be submitted to the repository directly, manually, to avoid re-building them every time on the build machine, wasting time and power. | |
| if ("${{ matrix.platform }}" -eq "Win32") { | |
| $rsSrc = "Source/External/reshade/bin/Win32/Release/ReShade32.dll" | |
| } else { | |
| $rsSrc = "Source/External/reshade/bin/x64/Release/ReShade64.dll" | |
| } | |
| if (Test-Path $rsSrc) { | |
| $rsDst = Join-Path $tempDir "dxgi.dll" | |
| Copy-Item -Path $rsSrc -Destination $rsDst -Force | |
| Write-Host "Copied ReShade to $rsDst" | |
| } else { | |
| Write-Host "ReShade file not found at $rsSrc — skipping" | |
| } | |
| # Add DLSS for the projects that need it based on vcxproj analysis | |
| if ($ngxProjects -contains $projectName) { | |
| # Source path for NGX DLSS DLL | |
| if (("${{ matrix.config }}" -eq "Development-Debug") -or ("${{ matrix.config }}" -eq "Development-Release")) { | |
| $ngxSrc = "Source/External/NGX/bin/dev/nvngx_dlss.dll" | |
| } else { | |
| $ngxSrc = "Source/External/NGX/bin/rel/nvngx_dlss.dll" | |
| } | |
| # Destination in the root of $tempDir, keeping original name | |
| if (Test-Path $ngxSrc) { | |
| Copy-Item -Path $ngxSrc -Destination $tempDir -Force | |
| } else { | |
| Write-Host "NGX DLSS DLL not found at $ngxSrc — skipping" | |
| } | |
| } | |
| # Copy addon file to temp root (and rename it) | |
| Copy-Item -Path $addonFile.FullName -Destination (Join-Path $tempDir $cleanFileName) | |
| # Create zip with addon and renamed Shaders folder | |
| Compress-Archive -Path "$tempDir/*" -DestinationPath "$zipName" -Force | |
| # Optional: clean up | |
| Remove-Item -Recurse -Force $tempDir | |
| Write-Host "Mod packaged: $projectName" | |
| #"zipfile=$zipName" >> $env:GITHUB_OUTPUT | |
| #"skip_upload=false" >> $env:GITHUB_OUTPUT | |
| } | |
| - name: Upload ZIP | |
| if: (matrix.config == 'Publishing-Release' || matrix.config == 'Test-Release' || matrix.config == 'Development-Release') && steps.create_zip.outputs.skip_upload != 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Package-${{ matrix.config }}-${{ matrix.platform }} | |
| #path: ${{ steps.create_zip.outputs.zipfile }} | |
| path: | | |
| Luma-*.zip | |
| release: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' # Don't run this on PRs but only on push, otherwise it will fail to upload release files | |
| runs-on: ubuntu-latest | |
| needs: build | |
| permissions: | |
| contents: write | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: Package-* | |
| merge-multiple: true # puts all files in a single folder | |
| - name: Create release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: latest-${{ github.run_number }} | |
| name: Release (Build ${{ github.run_number }}) | |
| body: | | |
| The current version of all Luma mods (based on latest commit). | |
| Installation instructions: | |
| - Extract all the files directly in the game main executable folder (replace the previous ones if you are updating) | |
| - If you already had a ReShade installation (dxgi.dll) overwrite it unless it's the same version. If you have other mods that used the dxgi.dll file, find a way to proxy them | |
| - Boot the game | |
| - Press home to bring out the ReShade and Luma menus (if they don't appear, ReShade or Luma failed to install or run) | |
| - Customize the settings if you'd like, the defaults are already good and pick up on your display calibration | |
| Note that not all mods here are playable, some are work in progress. Consult the wiki mod list for their state, or ask in "HDR Den" discord for more information. | |
| Note that some mods here might not be complete, like "Prey", which misses (optional) data for the rest of the mod, these should be downloaded from Nexus. | |
| "Test" mods are made to be tested and have tools to investigate what's going on, and help the developers gather information. | |
| The "Generic" mod will work in many games out of the box, especially if you pair it with a separate Auto HDR upgrade method. | |
| Proton should be fully compatible out of the box. | |
| --- | |
| Last commit: ${{ github.event.head_commit.message }} | |
| files: | | |
| Luma-*.zip |