Rise
The Vieneo Province
Loading...
Searching...
No Matches
Tests/CheckCloudShaderBudget.ps1

Source at documentation-generation time. See Test catalog for fixture associations.

1param(
2 [Parameter(Mandatory=$true)][string]$HeaderPath,
3 [int]$MaxSlots=4096
4)
5$ErrorActionPreference='Stop'
6# Check the actual compiled shaders, not HLSL source size. This also runs on
7# AMD development machines whose D3D9 driver accepts much larger programs.
8$passName='unknown'
9$profile=$null
10$shaderCount=0
11$checkedCount=0
12$violations=@()
13foreach ($line in [System.IO.File]::ReadLines((Resolve-Path -LiteralPath $HeaderPath).Path)) {
14 if ($line -match '^\s*pass\s+(\w+)') { $passName=$Matches[1] }
15 if ($line -match '^\s*(ps_3_0|vs_3_0)\s*$') {
16 if ($null -ne $profile) { throw "Missing instruction count for $passName $profile" }
17 $profile=$Matches[1]
18 ++$shaderCount
19 }
20 if ($null -ne $profile -and $line -match '// approximately (\d+) instruction slots? used') {
21 $slots=[int]$Matches[1]
22 Write-Output "Cloud shader ${passName} ${profile}: $slots / $MaxSlots instruction slots"
23 if ($slots -gt $MaxSlots) { $violations+="${passName} ${profile} uses $slots slots (limit $MaxSlots)" }
24 ++$checkedCount
25 $profile=$null
26 }
27}
28if ($shaderCount -eq 0 -or $checkedCount -ne $shaderCount) {
29 throw "Incomplete cloud shader instruction audit: checked $checkedCount of $shaderCount shaders"
30}
31if ($violations.Count -gt 0) { throw ($violations -join '; ') }
32Write-Output "PASS: all $checkedCount cloud shaders fit the D3D9 instruction budget"