• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 # Ensure that dxil.dll in on the %PATH%
2 $dxil_dll = cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=amd64 -no_logo && where dxil.dll" 2>&1
3 if ($dxil_dll -notmatch "dxil.dll$") {
4     Write-Output "Couldn't get path to dxil.dll"
5     exit 1
6 }
7 $env:Path = "$(Split-Path $dxil_dll);$env:Path"
8 
9 $exec_mode_to_stage = @{ Fragment = "fragment"; Vertex = "vertex"; GLCompute = "compute" }
10 
11 $spvasm_files = (Get-ChildItem C:\spirv-samples\spvasm\*.spvasm) | Sort-Object Name
12 foreach ($spvasm in $spvasm_files) {
13     $test_name = "Test:$($spvasm.Name):"
14     $spvfile = ($spvasm -replace '\.spvasm$', '.spv')
15     $content = Get-Content $spvasm
16     $spv_version = "1.0"
17     if ($content | Where-Object { $_ -match 'Version:\s(\d+\.\d+)' }) {
18         $spv_version = $Matches[1]
19     }
20 
21     $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
22     if ($LASTEXITCODE -ne 0) {
23         Write-Output "$test_name Skip: Unable to assemble shader"
24         Write-Output "$as_output`n"
25         continue
26     }
27 
28     $entry_points = $content | Select-String -Pattern '^OpEntryPoint\s(\w+)[^"]+"(\w+)"' | Select-Object -ExpandProperty Matches -First 1
29     if ($entry_points.Count -eq 0) {
30         Write-Output "$test_name Skip"
31         Write-Output "No OpEntryPoint not found`n"
32         continue
33     }
34 
35     foreach ($match in $entry_points) {
36         $exec_mode, $entry_point = $match.Groups[1].Value, $match.Groups[2].Value
37         $subtest = "$test_name$entry_point|${exec_mode}:"
38         $stage = $exec_mode_to_stage[$exec_mode]
39         if ($stage -eq '') {
40             Write-Output "$subtest Fail: Unknown shader type ($exec_mode)"
41             continue
42         }
43 
44         $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
45         if ($LASTEXITCODE -eq 0) {
46             Write-Output "$subtest Pass"
47         }
48         else {
49             Write-Output "$subtest Fail"
50             $sanitized_output = $s2d_output -replace ', file .+, line \d+' -replace '    In file .+:\d+'
51             Write-Output "$sanitized_output`n"
52         }
53     }
54 }
55