-
Notifications
You must be signed in to change notification settings - Fork 137
ci: add hlsl validation #1145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ci: add hlsl validation #1145
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
ae35aad
ci: add hlsl validation
alandtse 2932bc4
ci: add names for jobs
alandtse f468628
ci: fix errors due to missing code
alandtse 6f184fc
ci: fix vcpkg failure
alandtse 5833b5e
ci: remove setup-cmake step
alandtse 8ea612b
ci: fix version references
alandtse 31ed0b1
ci: fix syntax
alandtse c105181
ci: simplify hlsllkit use
alandtse 9d07e37
ci: remove fxc.exe check
alandtse 235c444
ci: update parameters description
alandtse e35b856
ci: allow cancellation
alandtse fc1171c
ci: test flat and vr shaders
alandtse 917f6be
ci: save hlsl logs
alandtse f3a975a
Merge branch 'dev' of https://github.com/doodlum/skyrim-community-sha…
alandtse dcc0611
feat: add shader config generation script
alandtse 19e3fc2
ci: fix bad cache keys
alandtse 96a30ef
build: fix powershell detection
alandtse dd02ff8
fix: stop parameter injection
alandtse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Build Configuration Files | ||
|
|
||
| This directory contains configuration files used by the CI/CD pipeline for build validation and testing. | ||
|
|
||
| ## Files | ||
|
|
||
| - `shader-validation.yaml`: Configuration for shader compilation validation using hlslkit (Skyrim SE) | ||
| - `shader-validation-vr.yaml`: VR Configuration for shader compilation validation using hlslkit (Skyrim VR) | ||
|
|
||
| ## Generating Configuration Files | ||
|
|
||
| These configuration files can be regenerated using the `generate-shader-configs.ps1` script in this directory. This script requires: | ||
|
|
||
| 1. A valid Skyrim installation (SE and/or VR) | ||
| 2. The [hlslkit](https://github.com/alandtse/hlslkit) package installed (`pip install hlslkit`) | ||
| 3. Community Shaders to be run once with specific settings to generate the required log data | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| Before running the generation script, you must run each version of Skyrim (SE and VR) **once** with the following Community Shaders settings: | ||
|
|
||
| 1. **Set Debug Log Level**: In the Community Shaders menu, set the log level to "Debug" or "Trace" | ||
| 2. **Clear Disk Cache**: Clear the shader disk cache before running | ||
| 3. **Enable Disk Cache**: Ensure disk cache is enabled and will be saved | ||
| 4. **Run the Game**: Launch and wait for compilation to complete to generate shader compilation logs | ||
|
|
||
| The required log files will be created at: | ||
|
|
||
| - **Skyrim SE**: `%USERPROFILE%\Documents\My Games\Skyrim Special Edition\SKSE\CommunityShaders.log` | ||
| - **Skyrim VR**: `%USERPROFILE%\Documents\My Games\Skyrim VR\SKSE\CommunityShaders.log` | ||
|
|
||
| ### Running the Script | ||
|
|
||
| ```powershell | ||
| # From the repository root | ||
| .\.github\configs\generate-shader-configs.ps1 | ||
|
|
||
| # Or from the configs directory | ||
| cd .github\configs | ||
| .\generate-shader-configs.ps1 | ||
| ``` | ||
|
|
||
| The script will: | ||
|
|
||
| 1. Detect available Skyrim installations | ||
| 2. Check for required log files | ||
| 3. Generate configuration files using hlslkit | ||
| 4. Update the files in `.github\configs\` | ||
|
|
||
| ### Manual Generation | ||
|
|
||
| You can also generate the files manually using hlslkit: | ||
|
|
||
| ```bash | ||
| # For Skyrim SE | ||
| hlslkit-generate --log "%USERPROFILE%\Documents\My Games\Skyrim Special Edition\SKSE\CommunityShaders.log" --output .\.github\configs\shader-validation.yaml | ||
|
|
||
| # For Skyrim VR | ||
| hlslkit-generate --log "%USERPROFILE%\Documents\My Games\Skyrim VR\SKSE\CommunityShaders.log" --output .\.github\configs\shader-validation-vr.yaml | ||
| ``` | ||
|
|
||
| ## Usage in CI/CD | ||
|
|
||
| These files are automatically used by the GitHub Actions workflows during shader validation. They define: | ||
|
|
||
| - Common shader compilation defines | ||
| - Expected warnings (with suppression) | ||
| - Shader file configurations | ||
| - Compilation parameters | ||
|
|
||
| The files should be regenerated when: | ||
|
|
||
| - New shaders are added to the project | ||
| - Shader compilation behavior changes | ||
| - New warnings need to be suppressed | ||
| - Build configurations are modified |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,258 @@ | ||
| #!/usr/bin/env pwsh | ||
| <# | ||
| .SYNOPSIS | ||
| Generates shader validation configuration files for Community Shaders. | ||
|
|
||
| .DESCRIPTION | ||
| This script generates shader-validation.yaml and shader-validation-vr.yaml files by analyzing | ||
| Community Shaders log files from Skyrim installations. It requires hlslkit to be installed | ||
| and both Skyrim Special Edition and/or Skyrim VR to have been run with specific settings. | ||
|
|
||
| .PARAMETER OutputDir | ||
| Directory where the generated YAML files will be saved. Defaults to current directory. | ||
|
|
||
| .PARAMETER Force | ||
| Force generation even if log files are not recent. | ||
|
|
||
| .PARAMETER LogFile | ||
| Process a specific log file directly instead of searching for Skyrim installations. | ||
| When used, also specify -OutputName for the generated config file name. | ||
|
|
||
| .PARAMETER OutputName | ||
| Name of the output YAML file when using -LogFile. Defaults to "shader-validation.yaml". | ||
|
|
||
| .EXAMPLE | ||
| .\generate-shader-configs.ps1 | ||
|
|
||
| .EXAMPLE | ||
| .\generate-shader-configs.ps1 -OutputDir "custom/path" -Force | ||
|
|
||
| .EXAMPLE | ||
| .\generate-shader-configs.ps1 -LogFile "C:\Path\To\CommunityShaders.log" -OutputName "my-validation.yaml" | ||
|
|
||
| .NOTES | ||
| Prerequisites: | ||
| 1. Install hlslkit: pip install hlslkit | ||
| 2. For automatic detection (default mode): | ||
| a. For each Skyrim version you want to generate configs for: | ||
| - Clear the disk cache (Community Shaders menu -> Advanced -> Clear Disk Cache) | ||
| - Set log level to Debug or Trace (Community Shaders menu -> Advanced -> Log Level) | ||
| - Enable disk cache if not already enabled | ||
| - Run the game and wait for shader compilation to complete. | ||
| b. The log files should be recent (generated after clearing cache) | ||
| 3. For direct log file processing: | ||
| - Use -LogFile parameter to specify the path to a Community Shaders log file | ||
| - Use -OutputName to specify the name of the generated config file | ||
| #> | ||
|
|
||
| param( | ||
| [Parameter(Mandatory=$false)] | ||
| [string]$OutputDir = ".", | ||
|
|
||
| [Parameter(Mandatory=$false)] | ||
| [switch]$Force, | ||
|
|
||
| [Parameter(Mandatory=$false)] | ||
| [string]$LogFile, | ||
|
|
||
| [Parameter(Mandatory=$false)] | ||
| [string]$OutputName = "shader-validation.yaml" | ||
| ) | ||
|
|
||
| # Check if hlslkit is installed | ||
| try { | ||
| $null = Get-Command "hlslkit-generate" -ErrorAction Stop | ||
| Write-Host "hlslkit-generate found" -ForegroundColor Green | ||
| } catch { | ||
| Write-Error "hlslkit-generate not found. Please install hlslkit: pip install hlslkit" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Function to find Skyrim installation paths | ||
| function Find-SkyrimPaths { | ||
| $paths = @() | ||
|
|
||
| # Check common document locations | ||
| $documentsPath = [Environment]::GetFolderPath("MyDocuments") | ||
| $myGamesPath = Join-Path $documentsPath "My Games" | ||
|
|
||
| # Check for Skyrim Special Edition | ||
| $sePath = Join-Path $myGamesPath "Skyrim Special Edition" | ||
| if (Test-Path $sePath) { | ||
| $paths += @{ | ||
| Name = "Skyrim Special Edition" | ||
| Path = $sePath | ||
| LogPath = Join-Path $sePath "SKSE\CommunityShaders.log" | ||
| ConfigName = "shader-validation.yaml" | ||
| Type = "SE" | ||
| } | ||
| } | ||
|
|
||
| # Check for Skyrim VR | ||
| $vrPath = Join-Path $myGamesPath "Skyrim VR" | ||
| if (Test-Path $vrPath) { | ||
| $paths += @{ | ||
| Name = "Skyrim VR" | ||
| Path = $vrPath | ||
| LogPath = Join-Path $vrPath "SKSE\CommunityShaders.log" | ||
| ConfigName = "shader-validation-vr.yaml" | ||
| Type = "VR" | ||
| } | ||
| } | ||
|
|
||
| # Check CommunityShadersOutputDir environment variable | ||
| $outputDir = $env:CommunityShadersOutputDir | ||
| if ($outputDir -and (Test-Path $outputDir)) { | ||
| Write-Host "Found CommunityShadersOutputDir: $outputDir" -ForegroundColor Yellow | ||
|
|
||
| # Try to detect if this is a Skyrim installation by looking for common files | ||
| $skyrimExe = Get-ChildItem -Path $outputDir -Recurse -Name "SkyrimSE.exe" -ErrorAction SilentlyContinue | Select-Object -First 1 | ||
| $skyrimVRExe = Get-ChildItem -Path $outputDir -Recurse -Name "SkyrimVR.exe" -ErrorAction SilentlyContinue | Select-Object -First 1 | ||
|
|
||
| if ($skyrimExe) { | ||
| Write-Host "Detected Skyrim SE installation in CommunityShadersOutputDir" -ForegroundColor Green | ||
| } | ||
| if ($skyrimVRExe) { | ||
| Write-Host "Detected Skyrim VR installation in CommunityShadersOutputDir" -ForegroundColor Green | ||
| } | ||
| } | ||
|
|
||
| return $paths | ||
| } | ||
|
|
||
| # Function to check if log file is recent and valid | ||
| function Test-LogFile { | ||
| param( | ||
| [string]$LogPath, | ||
| [string]$GameName | ||
| ) | ||
|
|
||
| if (-not (Test-Path $LogPath)) { | ||
| Write-Warning "Log file not found for $GameName`: $LogPath" | ||
| return $false | ||
| } | ||
|
|
||
| $logFile = Get-Item $LogPath | ||
| $age = (Get-Date) - $logFile.LastWriteTime | ||
|
|
||
| if ($age.TotalHours -gt 24 -and -not $Force) { | ||
| Write-Warning "Log file for $GameName is older than 24 hours. Use -Force to generate anyway." | ||
| Write-Host "Log file age: $($age.TotalHours.ToString('F1')) hours" -ForegroundColor Yellow | ||
| return $false | ||
| } | ||
|
|
||
| # Check if log contains shader compilation activity | ||
| $content = Get-Content $LogPath -Tail 1000 | Out-String | ||
| if ($content -notmatch "shader|compilation|cache") { | ||
| Write-Warning "Log file for $GameName doesn't appear to contain shader compilation activity." | ||
| if (-not $Force) { | ||
| Write-Host "Make sure you've cleared the disk cache and run the game to trigger shader compilation." -ForegroundColor Yellow | ||
| return $false | ||
| } | ||
| } | ||
|
|
||
| Write-Host "Log file for $GameName is valid" -ForegroundColor Green | ||
| return $true | ||
| } | ||
|
|
||
| # Main script | ||
| Write-Host "Community Shaders Configuration Generator" -ForegroundColor Cyan | ||
| Write-Host "=========================================" -ForegroundColor Cyan | ||
|
|
||
| # Ensure output directory exists | ||
| if (-not (Test-Path $OutputDir)) { | ||
| New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null | ||
| Write-Host "Created output directory: $OutputDir" -ForegroundColor Green | ||
| } | ||
|
|
||
| # Handle direct log file processing | ||
| if ($LogFile) { | ||
| Write-Host "Processing log file directly: $LogFile" -ForegroundColor Yellow | ||
|
|
||
| if (-not (Test-Path $LogFile)) { | ||
| Write-Error "Log file not found: $LogFile" | ||
| exit 1 | ||
| } | ||
|
|
||
| if (-not (Test-LogFile -LogPath $LogFile -GameName "Direct Log File")) { | ||
| Write-Host "Log file validation failed. Use -Force to process anyway." -ForegroundColor Red | ||
| if (-not $Force) { | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| $outputPath = Join-Path $OutputDir $OutputName | ||
| try { | ||
| Write-Host "Generating $OutputName..." -ForegroundColor Blue | ||
| Write-Host "Running: hlslkit-generate --log `"$LogFile`" --output `"$outputPath`"" -ForegroundColor Gray | ||
|
|
||
| & hlslkit-generate --log $LogFile --output $outputPath | ||
|
|
||
| if ($LASTEXITCODE -eq 0) { | ||
| Write-Host "Successfully generated $OutputName" -ForegroundColor Green | ||
| Write-Host "File saved to: $outputPath" -ForegroundColor Gray | ||
| } else { | ||
| Write-Error "Failed to generate $OutputName (exit code: $LASTEXITCODE)" | ||
| exit 1 | ||
| } | ||
| } catch { | ||
| Write-Error "Error generating $OutputName`: $($_.Exception.Message)" | ||
| exit 1 | ||
| } | ||
|
|
||
| exit 0 | ||
| } | ||
|
|
||
| # Find Skyrim installations | ||
| $skyrimPaths = Find-SkyrimPaths | ||
|
|
||
| if ($skyrimPaths.Count -eq 0) { | ||
| Write-Error "No Skyrim installations found. Please ensure Skyrim SE or VR is installed." | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Host "Found $($skyrimPaths.Count) Skyrim installation(s):" -ForegroundColor Green | ||
| foreach ($path in $skyrimPaths) { | ||
| Write-Host " - $($path.Name): $($path.Path)" -ForegroundColor Gray | ||
| } | ||
|
|
||
| # Process each installation | ||
| $generated = 0 | ||
| foreach ($skyrim in $skyrimPaths) { | ||
| Write-Host "`nProcessing $($skyrim.Name)..." -ForegroundColor Yellow | ||
|
|
||
| if (-not (Test-LogFile -LogPath $skyrim.LogPath -GameName $skyrim.Name)) { | ||
| Write-Host "Skipping $($skyrim.Name) due to invalid/missing log file." -ForegroundColor Red | ||
| continue } | ||
|
|
||
| $outputPath = Join-Path $OutputDir $skyrim.ConfigName | ||
|
|
||
| try { | ||
| Write-Host "Generating $($skyrim.ConfigName)..." -ForegroundColor Blue | ||
| Write-Host "Running: hlslkit-generate --log `"$($skyrim.LogPath)`" --output `"$outputPath`"" -ForegroundColor Gray | ||
|
|
||
| & hlslkit-generate --log $skyrim.LogPath --output $outputPath | ||
|
|
||
| if ($LASTEXITCODE -eq 0) { | ||
| Write-Host "Successfully generated $($skyrim.ConfigName)" -ForegroundColor Green | ||
| $generated++ | ||
| } else { | ||
| Write-Error "Failed to generate $($skyrim.ConfigName) (exit code: $LASTEXITCODE)" | ||
| } | ||
| } catch { | ||
| Write-Error "Error generating $($skyrim.ConfigName): $($_.Exception.Message)" | ||
| } | ||
| } | ||
|
|
||
| Write-Host "`n=========================================" -ForegroundColor Cyan | ||
| if ($generated -gt 0) { | ||
| Write-Host "Successfully generated $generated configuration file(s)" -ForegroundColor Green | ||
| Write-Host "Files saved to: $OutputDir" -ForegroundColor Gray | ||
| } else { | ||
| Write-Host "No configuration files were generated" -ForegroundColor Red | ||
| Write-Host "To generate shader validation configs:" -ForegroundColor Yellow | ||
| Write-Host "1. Clear the disk cache in Community Shaders menu" -ForegroundColor Gray | ||
| Write-Host "2. Set log level to Debug in Community Shaders menu" -ForegroundColor Gray | ||
| Write-Host "3. Run the game and load a save to trigger shader compilation" -ForegroundColor Gray | ||
| Write-Host "4. Run this script again" -ForegroundColor Gray | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.