• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 $exec_mode_to_stage = @{ Fragment = "fragment"; Vertex = "vertex"; GLCompute = "compute" }
2 
3 $spvasm_files = (Get-ChildItem C:\spirv-samples\spvasm\*.spvasm) | Sort-Object Name
4 foreach ($spvasm in $spvasm_files) {
5     $test_name = "Test:$($spvasm.Name):"
6     $spvfile = ($spvasm -replace '\.spvasm$', '.spv')
7     $content = Get-Content $spvasm
8     $spv_version = "1.0"
9     if ($content | Where-Object { $_ -match 'Version:\s(\d+\.\d+)' }) {
10         $spv_version = $Matches[1]
11     }
12 
13     $as_output = . "$env:VULKAN_SDK\Bin\spirv-as.exe" --target-env spv$spv_version --preserve-numeric-ids -o $spvfile $spvasm 2>&1 | % { if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.Exception.Message } else { $_ } }  | Out-String
14     if ($LASTEXITCODE -ne 0) {
15         Write-Output "$test_name Skip: Unable to assemble shader"
16         Write-Output "$as_output`n"
17         continue
18     }
19 
20     $entry_points = $content | Select-String -Pattern '^OpEntryPoint\s(\w+)[^"]+"(\w+)"' | Select-Object -ExpandProperty Matches -First 1
21     if ($entry_points.Count -eq 0) {
22         Write-Output "$test_name Skip"
23         Write-Output "No OpEntryPoint not found`n"
24         continue
25     }
26 
27     foreach ($match in $entry_points) {
28         $exec_mode, $entry_point = $match.Groups[1].Value, $match.Groups[2].Value
29         $subtest = "$test_name$entry_point|${exec_mode}:"
30         $stage = $exec_mode_to_stage[$exec_mode]
31         if ($stage -eq '') {
32             Write-Output "$subtest Fail: Unknown shader type ($exec_mode)"
33             continue
34         }
35 
36         $s2d_output = .\_install\bin\spirv2dxil.exe -v -e "$entry_point" -s "$stage" -o NUL $spvfile 2>&1 | ForEach-Object { if ($_ -is [System.Management.Automation.ErrorRecord]) { $_.Exception.Message } else { $_ } }  | Out-String
37         if ($LASTEXITCODE -eq 0) {
38             Write-Output "$subtest Pass"
39         }
40         else {
41             Write-Output "$subtest Fail"
42             $sanitized_output = $s2d_output -replace ', file .+, line \d+' -replace '    In file .+:\d+'
43             Write-Output "$sanitized_output`n"
44         }
45     }
46 }
47