Mark Lobodzinski | f39d70c | 2015-08-14 14:24:50 -0600 | [diff] [blame] | 1 | # Powershell script for running the vktrace trace/replay auto test
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 2 | # To run this test:
|
| 3 | # cd <this-dir>
|
Mark Lobodzinski | f39d70c | 2015-08-14 14:24:50 -0600 | [diff] [blame] | 4 | # powershell C:\src\LoaderAndTools\vktracereplay.ps1 [-Debug]
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 5 | $exitstatus = 0
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 6 |
|
| 7 | if ($args[0] -eq "-Debug") {
|
| 8 | $dPath = "Debug"
|
| 9 | } else {
|
| 10 | $dPath = "Release"
|
| 11 | }
|
| 12 |
|
| 13 | write-host -background black -foreground green "[ RUN ] " -nonewline
|
Mark Lobodzinski | f39d70c | 2015-08-14 14:24:50 -0600 | [diff] [blame] | 14 | write-host "vktracereplay.ps1: Vktrace trace/replay"
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 15 |
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 16 | # Create a temp directory to run the test in
|
| 17 | rm -recurse -force vktracereplay_tmp > $null 2> $null
|
| 18 | new-item vktracereplay_tmp -itemtype directory > $null 2> $null
|
| 19 |
|
| 20 | # Copy everything we need into the temp directory, so we
|
| 21 | # can make sure we are using the correct dll and exe files
|
| 22 | cd vktracereplay_tmp
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 23 | cp ..\..\vktrace\$dPath\vkreplay.exe .
|
| 24 | cp ..\..\vktrace\$dPath\vktrace.exe .
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 25 | cp ..\..\demos\$dPath\cube.exe .
|
| 26 | cp ..\..\demos\*.png .
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 27 | cp ..\..\demos\*.spv .
|
Cody Northrop | b229f97 | 2015-09-09 13:01:34 -0600 | [diff] [blame] | 28 | cp ..\..\loader\$dPath\vulkan-0.dll .
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 29 | cp ..\..\layers\$dPath\VKLayerScreenShot.dll .
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 30 | cp ..\..\layers\$dPath\screenshot.json .
|
Cody Northrop | 3513c15 | 2015-09-18 10:52:42 -0600 | [diff] [blame] | 31 | cp ..\..\layers\$dPath\vktrace_layer.dll .
|
| 32 | cp ..\..\layers\$dPath\vktrace_layer.json .
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 33 |
|
| 34 | # Change PATH to the temp directory
|
| 35 | $oldpath = $Env:PATH
|
| 36 | $Env:PATH = $pwd
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 37 |
|
| 38 | # Set up some modified env vars
|
Cody Northrop | bc6ecfa | 2015-08-14 10:59:35 -0600 | [diff] [blame] | 39 | $Env:VK_LAYER_PATH = $pwd
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 40 |
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 41 | # Temporarily set ScreenShot layer by hand until these are worked out
|
| 42 | $Env:_VK_SCREENSHOT = 1
|
Jon Ashburn | 7d4cd76 | 2015-09-11 11:33:09 -0600 | [diff] [blame] | 43 | $Env:VK_INSTANCE_LAYERS = "ScreenShot"
|
| 44 | $Env:VK_DEVICE_LAYERS = "ScreenShot"
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 45 |
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 46 | # Do a trace and replay
|
Jon Ashburn | b947005 | 2015-09-21 14:01:41 -0600 | [diff] [blame^] | 47 | & vktrace -o c01.vktrace -s 1 -p cube -a "--c 10" > trace.sout 2> trace.serr
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 48 | rename-item -path 1.ppm -newname 1-trace.ppm
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 49 | & vkreplay -s 1 -t c01.vktrace > replay.sout 2> replay.serr
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 50 | rename-item -path 1.ppm -newname 1-replay.ppm
|
| 51 |
|
| 52 | # Force a failure - for testing this script
|
| 53 | #cp vulkan.dll 1-replay.ppm
|
| 54 | #rm 1-trace.ppm
|
| 55 | #rm 1-replay.ppm
|
| 56 |
|
| 57 | # Restore PATH
|
| 58 | $Env:PATH = $oldpath
|
| 59 |
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 60 | if ($exitstatus -eq 0) {
|
| 61 | # Check that two screenshots were created
|
| 62 | if (!(Test-Path 1-trace.ppm) -or !(Test-Path 1-replay.ppm)) {
|
| 63 | echo 'Trace file does not exist'
|
| 64 | write-host -background black -foreground red "[ FAILED ] " -nonewline;
|
| 65 | $exitstatus = 1
|
| 66 | }
|
| 67 | }
|
| 68 |
|
| 69 | if ($exitstatus -eq 0) {
|
| 70 | # ensure the trace and replay snapshots are identical
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 71 | fc.exe /b 1-trace.ppm 1-replay.ppm > $null
|
| 72 | if (!(Test-Path 1-trace.ppm) -or !(Test-Path 1-replay.ppm) -or $LastExitCode -eq 1) {
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 73 | echo 'Trace files do not match'
|
| 74 | write-host -background black -foreground red "[ FAILED ] " -nonewline;
|
| 75 | $exitstatus = 1
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 76 | }
|
| 77 | }
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 78 |
|
| 79 | # check the average pixel value of each screenshot to ensure something plausible was written
|
| 80 | if ($exitstatus -eq 0) {
|
| 81 | $trace_mean = (convert 1-trace.ppm -format "%[mean]" info:)
|
| 82 | $replay_mean = (convert 1-replay.ppm -format "%[mean]" info:)
|
| 83 | $version = (identify -version)
|
| 84 |
|
| 85 | # normalize the values so we can support Q8 and Q16 imagemagick installations
|
| 86 | if ($version -match "Q8") {
|
| 87 | $trace_mean = $trace_mean / 255 # 2^8-1
|
| 88 | $replay_mean = $replay_mean / 255 # 2^8-1
|
| 89 | } else {
|
| 90 | $trace_mean = $trace_mean / 65535 # 2^16-1
|
| 91 | $replay_mean = $replay_mean / 65535 # 2^16-1
|
| 92 | }
|
| 93 |
|
| 94 | # if either screenshot is too bright or too dark, it either failed, or is a bad test
|
| 95 | if (($trace_mean -lt 0.10) -or ($trace_mean -gt 0.90)){
|
| 96 | echo ''
|
| 97 | echo 'Trace screenshot failed mean check, must be in range [0.1, 0.9]'
|
| 98 | write-host 'Detected mean:' $trace_mean
|
| 99 | echo ''
|
| 100 | write-host -background black -foreground red "[ FAILED ] " -nonewline;
|
| 101 | $exitstatus = 1
|
| 102 | }
|
| 103 | if (($replay_mean -lt 0.10) -or ($replay_mean -gt 0.90)){
|
| 104 | echo ''
|
| 105 | echo 'Replay screenshot failed mean check, must be in range [0.1, 0.9]'
|
| 106 | write-host 'Detected mean:' $replay_mean
|
| 107 | echo ''
|
| 108 | write-host -background black -foreground red "[ FAILED ] " -nonewline;
|
| 109 | $exitstatus = 1
|
| 110 | }
|
| 111 | }
|
| 112 |
|
| 113 | # if we passed all the checks, the test is good
|
| 114 | if ($exitstatus -eq 0) {
|
| 115 | write-host -background black -foreground green "[ PASSED ] " -nonewline;
|
| 116 | }
|
| 117 |
|
Mark Lobodzinski | f39d70c | 2015-08-14 14:24:50 -0600 | [diff] [blame] | 118 | write-host "vktracereplay.ps1: Vktrace trace/replay"
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 119 | write-host
|
| 120 | if ($exitstatus) {
|
| 121 | echo '1 FAILED TEST'
|
| 122 | }
|
| 123 |
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 124 | # cleanup
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 125 | cd ..
|
| 126 | rm -recurse -force vktracereplay_tmp > $null 2> $null
|
Cody Northrop | fb207af | 2015-08-31 11:33:35 -0600 | [diff] [blame] | 127 | Remove-Item Env:\VK_LAYER_PATH
|
| 128 | Remove-Item Env:\_VK_SCREENSHOT
|
| 129 | Remove-Item Env:\VK_INSTANCE_LAYERS
|
| 130 | Remove-Item Env:\VK_DEVICE_LAYERS
|
David Pinedo | 1405a43 | 2015-06-30 15:37:50 -0600 | [diff] [blame] | 131 | exit $exitstatus
|