hcttestcmds.cmd 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. @echo off
  2. if "%1"=="" (
  3. echo First argument to hcttestcmds should be directory with command-line tools.
  4. exit /b 1
  5. )
  6. if "%2"=="" (
  7. echo Second argument to hcttestcmds should be the absolute path to tools\clang\test\HLSL
  8. exit /b 1
  9. )
  10. echo Testing command line programs at %1 ...
  11. setlocal
  12. pushd %1
  13. echo Smoke test for dxr command line program ...
  14. dxr.exe -remove-unused-globals smoke.hlsl -Emain 1> nul
  15. if %errorlevel% neq 0 (
  16. echo Failed - %CD%\dxr.exe -remove-unused-globals %CD%\smoke.hlsl -Emain
  17. call :cleanup 2>nul
  18. exit /b 1
  19. )
  20. dxc.exe /T ps_6_0 smoke.hlsl /Fc smoke.hlsl.c 1>nul
  21. if %errorlevel% neq 0 (
  22. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Fc %CD%\smoke.hlsl.c
  23. call :cleanup 2>nul
  24. exit /b 1
  25. )
  26. dxc.exe /T ps_6_0 smoke.hlsl /Zi /Fd smoke.hlsl.d 1>nul
  27. if %errorlevel% neq 0 (
  28. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Zi /Fd %CD%\smoke.hlsl.d
  29. call :cleanup 2>nul
  30. exit /b 1
  31. )
  32. rem When dxil.dll is present, /Fd with trailing will not produce a name.
  33. if exist dxil.dll (
  34. echo Skipping /Fd with trailing backslash when dxil.dll is present.
  35. echo A future dxil.dll will provide this information.
  36. goto :skipfdtrail
  37. )
  38. dxc.exe /T ps_6_0 smoke.hlsl /Zi /Fd %CD%\ /Fo smoke.hlsl.strip 1>nul
  39. if %errorlevel% neq 0 (
  40. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Zi /Fd %CD%\
  41. call :cleanup 2>nul
  42. exit /b 1
  43. )
  44. rem .lld file should be produced
  45. dir %CD%\*.lld 1>nul
  46. if %errorlevel% neq 0 (
  47. echo Failed to find some .lld file at %CD%
  48. call :cleanup 2>nul
  49. exit /b 1
  50. )
  51. rem /Fd with trailing backslash implies /Qstrip_debug
  52. dxc.exe -dumpbin smoke.hlsl.strip | findstr "shader debug name" 1>nul
  53. if %errorlevel% neq 0 (
  54. echo Failed to find shader debug name.
  55. call :cleanup 2>nul
  56. exit /b 1
  57. )
  58. dxc.exe -dumpbin smoke.hlsl.strip | findstr "DICompileUnit" 1>nul
  59. if %errorlevel% equ 0 (
  60. echo Found DICompileUnit after implied strip.
  61. call :cleanup 2>nul
  62. exit /b 1
  63. )
  64. :skipfdtrail
  65. dxc.exe /T ps_6_0 smoke.hlsl /Fe smoke.hlsl.e 1>nul
  66. if %errorlevel% neq 0 (
  67. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Fe %CD%\smoke.hlsl.e
  68. call :cleanup 2>nul
  69. exit /b 1
  70. )
  71. dxc.exe /T ps_6_0 smoke.hlsl /ast-dump 1>nul
  72. if %errorlevel% neq 0 (
  73. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /ast-dump
  74. call :cleanup 2>nul
  75. exit /b 1
  76. )
  77. dxc.exe /T ps_6_0 smoke.hlsl /Dcheck_warning 1>nul 2>smoke.warning.txt
  78. if %errorlevel% neq 0 (
  79. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Dcheck_warning
  80. call :cleanup 2>nul
  81. exit /b 1
  82. )
  83. findstr warning: %CD%\smoke.warning.txt 1>nul
  84. if %errorlevel% neq 0 (
  85. echo Failed to get warning message from command %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Dcheck_warning
  86. call :cleanup 2>nul
  87. exit /b 1
  88. )
  89. dxc.exe /T ps_6_0 smoke.hlsl /Dcheck_warning /no-warnings 1>nul 2>smoke.no.warning.txt
  90. if %errorlevel% neq 0 (
  91. echo Failed - %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Dcheck_warning /no-warnings
  92. call :cleanup 2>nul
  93. exit /b 1
  94. )
  95. findstr warning: %CD%\smoke.no.warning.txt 1>nul
  96. if %errorlevel% equ 0 (
  97. echo no-warning option failed : %CD%\dxc.exe /T ps_6_0 smoke.hlsl /Dcheck_warning /no-warnings
  98. call :cleanup 2>nul
  99. exit /b 1
  100. )
  101. echo Smoke test for dxc command line program ...
  102. dxc.exe /T ps_6_0 smoke.hlsl /Fh smoke.hlsl.h /Vn g_myvar 1> nul
  103. if %errorlevel% neq 0 (
  104. echo Failed - %CD%\dxc.exe /T ps_6_0 %CD%\smoke.hlsl /Fh %CD%\smoke.hlsl.h /Vn g_myvar
  105. call :cleanup 2>nul
  106. exit /b 1
  107. )
  108. findstr g_myvar %CD%\smoke.hlsl.h 1>nul
  109. if %errorlevel% neq 0 (
  110. echo Failed to find the variable g_myvar in %CD%\smoke.hlsl.h
  111. echo Debug with start devenv /debugexe %CD%\dxc.exe /T ps_6_0 %CD%\smoke.hlsl /Fh %CD%\smoke.hlsl.h /Vn g_myvar
  112. call :cleanup 2>nul
  113. exit /b 1
  114. )
  115. findstr "0x44, 0x58" %CD%\smoke.hlsl.h 1>nul
  116. if %errorlevel% neq 0 (
  117. echo Failed to find the bytecode for DXBC container in %CD%\smoke.hlsl.h
  118. call :cleanup 2>nul
  119. exit /b 1
  120. )
  121. dxc.exe smoke.hlsl /P preprocessed.hlsl 1>nul
  122. if %errorlevel% neq 0 (
  123. echo Failed to preprocess smoke.hlsl
  124. call :cleanup 2>nul
  125. exit /b 1
  126. )
  127. dxc.exe /T ps_6_0 smoke.hlsl -force_rootsig_ver rootsig_1_0 1>nul
  128. if %errorlevel% neq 0 (
  129. echo Failed to compile with forcing rootsignature rootsig_1_0
  130. call :cleanup 2>nul
  131. exit /b 1
  132. )
  133. dxc.exe /T ps_6_0 smoke.hlsl -force_rootsig_ver rootsig_1_1 1>nul
  134. if %errorlevel% neq 0 (
  135. echo Failed to compile with forcing rootsignature rootsig_1_1
  136. call :cleanup 2>nul
  137. exit /b 1
  138. )
  139. dxc.exe /T ps_6_0 smoke.hlsl -force_rootsig_ver rootsig_2_0 2>nul
  140. if %errorlevel% equ 0 (
  141. echo rootsig_2_0 is not supported but compilation passed
  142. call :cleanup 2>nul
  143. exit /b 1
  144. )
  145. dxc.exe /T ps_6_0 smoke.hlsl /HV 2016 1>nul
  146. if %errorlevel% neq 0 (
  147. echo Failed to compile with HLSL version 2016
  148. call :cleanup 2>nul
  149. exit /b 1
  150. )
  151. dxc.exe /T ps_6_0 smoke.hlsl /HV 2015 2>nul
  152. if %errorlevel% equ 0 (
  153. echo Unsupported HLSL version 2015 should fail but did not fail
  154. call :cleanup 2>nul
  155. exit /b 1
  156. )
  157. dxc.exe /T ps_6_0 smoke.hlsl /Zi /Fo smoke.cso 1> nul
  158. if %errorlevel% neq 0 (
  159. echo Failed to compile to binary object from %CD%\smoke.hlsl
  160. call :cleanup 2>nul
  161. exit /b 1
  162. )
  163. dxc.exe /T ps_6_0 smoke.hlsl /Zi /Fo smoke.cso /Cc /Ni /No /Lx 1> nul
  164. if %errorlevel% neq 0 (
  165. echo Failed to compile to binary object from %CD%\smoke.hlsl with disassembly options
  166. call :cleanup 2>nul
  167. exit /b 1
  168. )
  169. dxc.exe -dumpbin smoke.cso 1> nul
  170. if %errorlevel% neq 0 (
  171. echo Failed to disassemble binary object from %CD%\smoke.hlsl
  172. call :cleanup 2>nul
  173. exit /b 1
  174. )
  175. dxc.exe smoke.cso /recompile 1>nul
  176. if %errorlevel% neq 0 (
  177. echo Failed to recompile binary object compiled from %CD%\smoke.hlsl
  178. call :cleanup 2>nul
  179. exit /b 1
  180. )
  181. dxc.exe smoke.cso /recompile /T ps_6_0 /E main 1>nul
  182. if %errorlevel% neq 0 (
  183. echo Failed to recompile binary object with target ps_6_0 from %CD%\smoke.hlsl
  184. call :cleanup 2>nul
  185. exit /b 1
  186. )
  187. dxc.exe smoke.hlsl /D "semantic = SV_Position" /T vs_6_0 /Zi /DDX12 /Fo smoke.cso 1> nul
  188. if %errorlevel% neq 0 (
  189. echo Failed to compile smoke.hlsl with command line defines
  190. call :cleanup 2>nul
  191. exit /b 1
  192. )
  193. dxc.exe smoke.cso /recompile 1> nul
  194. if %errorlevel% neq 0 (
  195. echo Failed to recompile smoke.cso with command line defines
  196. call :cleanup 2>nul
  197. exit /b 1
  198. )
  199. dxc.exe smoke.cso /dumpbin /Qstrip_debug /Fo nodebug.cso 1>nul
  200. if %errorlevel% neq 0 (
  201. echo Failed to strip debug part from DXIL container blob
  202. call :cleanup 2>nul
  203. exit /b 1
  204. )
  205. dxc.exe smoke.cso /dumpbin /Qstrip_rootsignature /Fo norootsignature.cso 1>nul
  206. if %errorlevel% neq 0 (
  207. echo Failed to strip rootsignature from DXIL container blob
  208. call :cleanup 2>nul
  209. exit /b 1
  210. )
  211. dxc.exe smoke.cso /dumpbin /extractrootsignature /Fo rootsig.cso 1>nul
  212. if %errorlevel% neq 0 (
  213. echo Failed to extract rootsignature from DXIL container blob
  214. call :cleanup 2>nul
  215. exit /b 1
  216. )
  217. dxc.exe norootsignature.cso /dumpbin /setrootsignature rootsig.cso /Fo smoke.cso 1>nul
  218. if %errorlevel% neq 0 (
  219. echo Failed to setrootsignature to DXIL conatiner with no root signature
  220. call :cleanup 2>nul
  221. exit /b 1
  222. )
  223. dxc.exe "%2"\..\CodeGenHLSL\NonUniform.hlsl /T ps_6_0 /DDX12 /Fo NonUniform.cso 1>nul
  224. if %errorlevel% neq 0 (
  225. echo Failed to compile NonUniform.hlsl
  226. call :cleanup 2>nul
  227. exit /b 1
  228. )
  229. dxc.exe NonUniform.cso /dumpbin /Qstrip_rootsignature /Fo NonUniformNoRootSig.cso 1>nul
  230. if %errorlevel% neq 0 (
  231. echo Failed to strip rootsignature from DXIL container blob for NonUniform.cso
  232. call :cleanup 2>nul
  233. exit /b 1
  234. )
  235. dxc.exe NonUniform.cso /dumpbin /extractrootsignature /Fo NonUniformRootSig.cso 1>nul
  236. if %errorlevel% neq 0 (
  237. echo Failed to extract rootsignature from DXIL container blob for NonUniform.cso
  238. call :cleanup 2>nul
  239. exit /b 1
  240. )
  241. dxc.exe smoke.cso /dumpbin /verifyrootsignature rootsig.cso 1>nul
  242. if %errorlevel% neq 0 (
  243. echo Failed to verify root signature for somke.cso
  244. call :cleanup 2>nul
  245. exit /b 1
  246. )
  247. dxc.exe norootsignature.cso /dumpbin /verifyrootsignature rootsig.cso 1>nul
  248. if %errorlevel% neq 0 (
  249. echo Failed to verify root signature for smoke.cso without root signature
  250. call :cleanup 2>nul
  251. exit /b 1
  252. )
  253. dxc.exe NonUniform.cso /dumpbin /verifyrootsignature NonUniformRootSig.cso 1>nul
  254. if %errorlevel% neq 0 (
  255. echo Failed to verify root signature for NonUniform.cso
  256. call :cleanup 2>nul
  257. exit /b 1
  258. )
  259. dxc.exe NonUniformNoRootSig.cso /dumpbin /verifyrootsignature NonUniformRootSig.cso 1>nul
  260. if %errorlevel% neq 0 (
  261. echo Failed to verify root signature for somke1.cso without root signature
  262. call :cleanup 2>nul
  263. exit /b 1
  264. )
  265. dxc.exe NonUniformNoRootSig.cso /dumpbin /verifyrootsignature rootsig.cso 2>nul
  266. if %errorlevel% equ 0 (
  267. echo Verifying invalid root signature for NonUniformNoRootSig.cso should fail but passed
  268. call :cleanup 2>nul
  269. exit /b 1
  270. )
  271. dxc.exe norootsignature.cso /dumpbin /verifyrootsignature NonUniformRootSig.cso 2>nul
  272. if %errorlevel% equ 0 (
  273. echo Verifying invalid root signature for norootsignature.cso should fail but passed
  274. call :cleanup 2>nul
  275. exit /b 1
  276. )
  277. dxc.exe smoke.cso /dumpbin /setrootsignature rootsig.cso /Fo smoke.cso 1>nul
  278. if %errorlevel% neq 0 (
  279. echo Failed to setrootsignature to DXIL container that already contains root signature
  280. call :cleanup 2>nul
  281. exit /b 1
  282. )
  283. dxc.exe smoke.cso /dumpbin /setrootsignature NonUniformRootSig.cso /Fo smoke.cso 2>nul
  284. if %errorlevel% equ 0 (
  285. echo setrootsignature of invalid root signature should fail but passed
  286. call :cleanup 2>nul
  287. exit /b 1
  288. )
  289. dxc.exe %2\..\CodeGenHLSL\Samples\MiniEngine\TextVS.hlsl /Tvs_6_0 /Zi /Fo TextVS.cso 1>nul
  290. if %errorlevel% neq 0 (
  291. echo failed to compile %2\..\CodeGenHLSL\Samples\MiniEngine\TextVS.hlsl
  292. call :cleanup 2>nul
  293. exit /b 1
  294. )
  295. dxc.exe smoke.cso /dumpbin /verifyrootsignature TextVS.cso 1>nul
  296. if %errorlevel% neq 0 (
  297. echo Verifying valid replacement of root signature failed
  298. call :cleanup 2>nul
  299. exit /b 1
  300. )
  301. echo private data > private.txt
  302. dxc.exe smoke.cso /dumpbin /setprivate private.txt /Fo private.cso 1>nul
  303. if %errorlevel% neq 0 (
  304. echo Failed to set private data to DXIL container with no private data
  305. call :cleanup 2>nul
  306. exit /b 1
  307. )
  308. dxc.exe private.cso /dumpbin /setprivate private.txt /Fo private.cso 1>nul
  309. if %errorlevel% neq 0 (
  310. echo Failed to set private data to DXIL container that already contains private data
  311. call :cleanup 2>nul
  312. exit /b 1
  313. )
  314. dxc.exe private.cso /dumpbin /Qstrip_priv /Fo noprivate.cso 1>nul
  315. if %errorlevel% neq 0 (
  316. echo Failed to strip private data from DXIL container blob
  317. call :cleanup 2>nul
  318. exit /b 1
  319. )
  320. dxc.exe private.cso /dumpbin /getprivate private1.txt 1>nul
  321. if %errorlevel% neq 0 (
  322. echo Failed to get private data from DXIL container blob
  323. call :cleanup 2>nul
  324. exit /b 1
  325. )
  326. findstr "private data" %CD%\private1.txt 1>nul
  327. if %errorlevel% neq 0 (
  328. echo Failed to get private data content from DXIL container blob
  329. call :cleanup 2>nul
  330. exit /b 1
  331. )
  332. FC smoke.cso noprivate.cso 1>nul
  333. if %errorlevel% neq 0 (
  334. echo Appending and removing blob roundtrip failed.
  335. call :cleanup 2>nul
  336. exit /b 1
  337. )
  338. dxc.exe private.cso /dumpbin /Qstrip_priv /Qstrip_debug /Qstrip_rootsignature /Fo noprivdebugroot.cso 1>nul
  339. if %errorlevel% neq 0 (
  340. echo Failed to extract multiple parts from DXIL container blob
  341. call :cleanup 2>nul
  342. exit /b 1
  343. )
  344. echo Smoke test for dxc.exe shader model upgrade...
  345. dxc.exe /T ps_5_0 smoke.hlsl 1> nul
  346. if %errorlevel% neq 0 (
  347. echo Failed shader model upgrade test - %CD%\dxc.exe /T ps_5_0 %CD%\smoke.hlsl
  348. call :cleanup 2>nul
  349. exit /b 1
  350. )
  351. dxc.exe -dumpbin smoke.cso > smoke.ll
  352. if %errorlevel% neq 0 (
  353. echo Failed to dumpbin from blob.
  354. call :cleanup 2>nul
  355. exit /b 1
  356. )
  357. echo Smoke test for dxa command line program ...
  358. dxa.exe smoke.cso -listfiles 1> nul
  359. if %errorlevel% neq 0 (
  360. echo Failed to list files from blob
  361. call :cleanup 2>nul
  362. exit /b 1
  363. )
  364. dxa.exe smoke.cso -listparts 1> nul
  365. if %errorlevel% neq 0 (
  366. echo Failed to list parts from blob
  367. call :cleanup 2>nul
  368. exit /b 1
  369. )
  370. dxa.exe smoke.cso -extractpart dbgmodule -o smoke.cso.ll 1>nul
  371. if %errorlevel% neq 0 (
  372. echo Failed to extract DXIL part from the blob generated by %CD%\smoke.hlsl
  373. call :cleanup 2>nul
  374. exit /b 1
  375. )
  376. dxa.exe smoke.cso.ll -listfiles 1> nul
  377. if %errorlevel% neq 0 (
  378. echo Failed to list files from Dxil part with Dxil with Debug Info
  379. call :cleanup 2>nul
  380. exit /b 1
  381. )
  382. dxa.exe smoke.cso.ll -extractfile * 1> nul
  383. if %errorlevel% neq 0 (
  384. echo Failed to extract files from Dxil part with Dxil with Debug Info
  385. call :cleanup 2>nul
  386. exit /b 1
  387. )
  388. dxa.exe smoke.cso -extractpart module -o smoke.cso.plain.bc 1>nul
  389. if %errorlevel% neq 0 (
  390. echo Failed to extract plain module via dxa.exe smoke.cso -extractpart module -o smoke.cso.plain.bc
  391. call :cleanup 2>nul
  392. exit /b 1
  393. )
  394. dxa.exe smoke.cso.plain.bc -o smoke.rebuilt-container.cso 1>nul
  395. if %errorlevel% neq 0 (
  396. echo Failed to rebuild container from plain module via dxa.exe smoke.cso.plain.bc -o smoke.rebuilt-container.cso
  397. call :cleanup 2>nul
  398. exit /b 1
  399. )
  400. dxa.exe smoke.ll -o smoke.rebuilt-container2.cso 1>nul
  401. if %errorlevel% neq 0 (
  402. echo Failed to rebuild container from plain module via dxa.exe smoke.ll -o smoke.rebuilt-container2.cso
  403. call :cleanup 2>nul
  404. exit /b 1
  405. )
  406. call :cleanup
  407. exit /b 0
  408. :cleanup
  409. del %CD%\preprocessed.hlsl
  410. del %CD%\smoke.hlsl.c
  411. del %CD%\smoke.hlsl.d
  412. del %CD%\smoke.hlsl.e
  413. del %CD%\smoke.hlsl.h
  414. del %CD%\smoke.hlsl.strip
  415. del %CD%\smoke.cso
  416. del %CD%\NonUniform.cso
  417. del %CD%\private.cso
  418. del %CD%\private.txt
  419. del %CD%\private1.txt
  420. del %CD%\noprivate.cso
  421. del %CD%\nodebug.cso
  422. del %CD%\rootsig.cso
  423. del %CD%\NonUniformRootSig.cso
  424. del %CD%\noprivdebugroot.cso
  425. del %CD%\norootsignature.cso
  426. del %CD%\NonUniformNoRootSig.cso
  427. del %CD%\TextVS.cso
  428. del %CD%\smoke.ll
  429. del %CD%\smoke.cso.ll
  430. del %CD%\*.lld
  431. del %CD%\smoke.cso.plain.bc
  432. del %CD%\smoke.rebuilt-container.cso
  433. del %CD%\smoke.rebuilt-container2.cso
  434. exit /b 0