2
0

CompilerTest.cpp 185 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // CompilerTest.cpp //
  4. // Copyright (C) Microsoft Corporation. All rights reserved. //
  5. // This file is distributed under the University of Illinois Open Source //
  6. // License. See LICENSE.TXT for details. //
  7. // //
  8. // Provides tests for the compiler API. //
  9. // //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. #ifndef UNICODE
  12. #define UNICODE
  13. #endif
  14. #include <memory>
  15. #include <vector>
  16. #include <string>
  17. #include <map>
  18. #include <cassert>
  19. #include <sstream>
  20. #include <algorithm>
  21. #include "dxc/HLSL/DxilContainer.h"
  22. #include "dxc/Support/WinIncludes.h"
  23. #include "dxc/dxcapi.h"
  24. #include <atlfile.h>
  25. #include "HLSLTestData.h"
  26. #include "WexTestClass.h"
  27. #include "HlslTestUtils.h"
  28. #include "DxcTestUtils.h"
  29. #include "llvm/Support/raw_os_ostream.h"
  30. #include "dxc/Support/Global.h"
  31. #include "dxc/Support/dxcapi.use.h"
  32. #include "dxc/Support/microcom.h"
  33. #include "dxc/Support/HLSLOptions.h"
  34. #include "dxc/Support/Unicode.h"
  35. #include "dia2.h"
  36. #include <fstream>
  37. #include "llvm/Support/FileSystem.h"
  38. #include "llvm/Support/MSFileSystem.h"
  39. #include "llvm/Support/Path.h"
  40. #include "llvm/ADT/SmallString.h"
  41. #include "llvm/ADT/StringSwitch.h"
  42. using namespace std;
  43. using namespace hlsl_test;
  44. std::wstring BlobToUtf16(_In_ IDxcBlob *pBlob) {
  45. CComPtr<IDxcBlobEncoding> pBlobEncoding;
  46. const UINT CP_UTF16 = 1200;
  47. IFT(pBlob->QueryInterface(&pBlobEncoding));
  48. BOOL known;
  49. UINT32 codePage;
  50. IFT(pBlobEncoding->GetEncoding(&known, &codePage));
  51. std::wstring result;
  52. if (codePage == CP_UTF16) {
  53. result.resize(pBlob->GetBufferSize() + 1);
  54. memcpy((void *)result.data(), pBlob->GetBufferPointer(),
  55. pBlob->GetBufferSize());
  56. return result;
  57. } else if (codePage == CP_UTF8) {
  58. Unicode::UTF8ToUTF16String((char *)pBlob->GetBufferPointer(),
  59. pBlob->GetBufferSize(), &result);
  60. return result;
  61. } else {
  62. throw std::exception("Unsupported codepage.");
  63. }
  64. }
  65. void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const char *pVal, _Outptr_ IDxcBlobEncoding **ppBlob) {
  66. CComPtr<IDxcLibrary> library;
  67. IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
  68. IFT(library->CreateBlobWithEncodingOnHeapCopy(pVal, strlen(pVal), CP_UTF8, ppBlob));
  69. }
  70. void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, _Outptr_ IDxcBlobEncoding **ppBlob) {
  71. CComPtr<IDxcLibrary> library;
  72. IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
  73. IFT(library->CreateBlobWithEncodingOnHeapCopy(val.data(), val.size(), CP_UTF8, ppBlob));
  74. }
  75. void Utf8ToBlob(dxc::DxcDllSupport &dllSupport, const std::string &val, _Outptr_ IDxcBlob **ppBlob) {
  76. Utf8ToBlob(dllSupport, val, (IDxcBlobEncoding**)ppBlob);
  77. }
  78. void Utf16ToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, _Outptr_ IDxcBlobEncoding **ppBlob) {
  79. const UINT32 CP_UTF16 = 1200;
  80. CComPtr<IDxcLibrary> library;
  81. IFT(dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
  82. IFT(library->CreateBlobWithEncodingOnHeapCopy(val.data(), val.size() * sizeof(wchar_t), CP_UTF16, ppBlob));
  83. }
  84. void Utf16ToBlob(dxc::DxcDllSupport &dllSupport, const std::wstring &val, _Outptr_ IDxcBlob **ppBlob) {
  85. Utf16ToBlob(dllSupport, val, (IDxcBlobEncoding**)ppBlob);
  86. }
  87. void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText,
  88. LPWSTR pTargetProfile, LPCWSTR pArgs,
  89. _Outptr_ IDxcBlob **ppResult) {
  90. std::vector<std::wstring> argsW;
  91. std::vector<LPCWSTR> args;
  92. if (pArgs) {
  93. wistringstream argsS(pArgs);
  94. copy(istream_iterator<wstring, wchar_t>(argsS),
  95. istream_iterator<wstring, wchar_t>(), back_inserter(argsW));
  96. transform(argsW.begin(), argsW.end(), back_inserter(args),
  97. [](const wstring &w) { return w.data(); });
  98. }
  99. VerifyCompileOK(dllSupport, pText, pTargetProfile, args, ppResult);
  100. }
  101. void VerifyCompileOK(dxc::DxcDllSupport &dllSupport, LPCSTR pText,
  102. LPWSTR pTargetProfile, std::vector<LPCWSTR> &args,
  103. _Outptr_ IDxcBlob **ppResult) {
  104. CComPtr<IDxcCompiler> pCompiler;
  105. CComPtr<IDxcBlobEncoding> pSource;
  106. CComPtr<IDxcOperationResult> pResult;
  107. HRESULT hrCompile;
  108. *ppResult = nullptr;
  109. VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
  110. Utf8ToBlob(dllSupport, pText, &pSource);
  111. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  112. pTargetProfile, args.data(), args.size(),
  113. nullptr, 0, nullptr, &pResult));
  114. VERIFY_SUCCEEDED(pResult->GetStatus(&hrCompile));
  115. VERIFY_SUCCEEDED(hrCompile);
  116. VERIFY_SUCCEEDED(pResult->GetResult(ppResult));
  117. }
  118. // VersionSupportInfo Implementation
  119. VersionSupportInfo::VersionSupportInfo() :
  120. m_CompilerIsDebugBuild(false),
  121. m_InternalValidator(false),
  122. m_DxilMajor(0),
  123. m_DxilMinor(0),
  124. m_ValMajor(0),
  125. m_ValMinor(0)
  126. {}
  127. void VersionSupportInfo::Initialize(dxc::DxcDllSupport &dllSupport) {
  128. VERIFY_IS_TRUE(dllSupport.IsEnabled());
  129. // Default to Dxil 1.0 and internal Val 1.0
  130. m_DxilMajor = m_ValMajor = 1;
  131. m_DxilMinor = m_ValMinor = 0;
  132. m_InternalValidator = true;
  133. CComPtr<IDxcVersionInfo> pVersionInfo;
  134. UINT32 VersionFlags = 0;
  135. // If the following fails, we have Dxil 1.0 compiler
  136. if (SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcCompiler, &pVersionInfo))) {
  137. VERIFY_SUCCEEDED(pVersionInfo->GetVersion(&m_DxilMajor, &m_DxilMinor));
  138. VERIFY_SUCCEEDED(pVersionInfo->GetFlags(&VersionFlags));
  139. m_CompilerIsDebugBuild = (VersionFlags & DxcVersionInfoFlags_Debug) ? true : false;
  140. pVersionInfo.Release();
  141. }
  142. if (SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcValidator, &pVersionInfo))) {
  143. VERIFY_SUCCEEDED(pVersionInfo->GetVersion(&m_ValMajor, &m_ValMinor));
  144. VERIFY_SUCCEEDED(pVersionInfo->GetFlags(&VersionFlags));
  145. if (m_ValMinor > 0) {
  146. // flag only exists on newer validator, assume internal otherwise.
  147. m_InternalValidator = (VersionFlags & DxcVersionInfoFlags_Internal) ? true : false;
  148. } else {
  149. // With old compiler, validator is the only way to get this
  150. m_CompilerIsDebugBuild = (VersionFlags & DxcVersionInfoFlags_Debug) ? true : false;
  151. }
  152. } else {
  153. // If create instance of IDxcVersionInfo on validator failed, we have an old validator from dxil.dll
  154. m_InternalValidator = false;
  155. }
  156. }
  157. bool VersionSupportInfo::SkipIRSensitiveTest() {
  158. // Only debug builds preserve BB names.
  159. if (!m_CompilerIsDebugBuild) {
  160. WEX::Logging::Log::Comment(L"Test skipped due to name preservation requirement.");
  161. return true;
  162. }
  163. return false;
  164. }
  165. bool VersionSupportInfo::SkipDxilVersion(unsigned major, unsigned minor) {
  166. if (m_DxilMajor < major || (m_DxilMajor == major && m_DxilMinor < minor) ||
  167. m_ValMajor < major || (m_ValMajor == major && m_ValMinor < minor)) {
  168. WEX::Logging::Log::Comment(WEX::Common::String().Format(
  169. L"Test skipped because it requires Dxil %u.%u and Validator %u.%u.",
  170. major, minor, major, minor));
  171. return true;
  172. }
  173. return false;
  174. }
  175. bool VersionSupportInfo::SkipOutOfMemoryTest() {
  176. if (m_CompilerIsDebugBuild) { // same detection logic at the moment
  177. WEX::Logging::Log::Comment(L"Test skipped due to out-of-memory robustness requirement.");
  178. return true;
  179. }
  180. return false;
  181. }
  182. // Aligned to SymTagEnum.
  183. const char *SymTagEnumText[] =
  184. {
  185. "Null", // SymTagNull
  186. "Exe", // SymTagExe
  187. "Compiland", // SymTagCompiland
  188. "CompilandDetails", // SymTagCompilandDetails
  189. "CompilandEnv", // SymTagCompilandEnv
  190. "Function", // SymTagFunction
  191. "Block", // SymTagBlock
  192. "Data", // SymTagData
  193. "Annotation", // SymTagAnnotation
  194. "Label", // SymTagLabel
  195. "PublicSymbol", // SymTagPublicSymbol
  196. "UDT", // SymTagUDT
  197. "Enum", // SymTagEnum
  198. "FunctionType", // SymTagFunctionType
  199. "PointerType", // SymTagPointerType
  200. "ArrayType", // SymTagArrayType
  201. "BaseType", // SymTagBaseType
  202. "Typedef", // SymTagTypedef
  203. "BaseClass", // SymTagBaseClass
  204. "Friend", // SymTagFriend
  205. "FunctionArgType", // SymTagFunctionArgType
  206. "FuncDebugStart", // SymTagFuncDebugStart
  207. "FuncDebugEnd", // SymTagFuncDebugEnd
  208. "UsingNamespace", // SymTagUsingNamespace
  209. "VTableShape", // SymTagVTableShape
  210. "VTable", // SymTagVTable
  211. "Custom", // SymTagCustom
  212. "Thunk", // SymTagThunk
  213. "CustomType", // SymTagCustomType
  214. "ManagedType", // SymTagManagedType
  215. "Dimension", // SymTagDimension
  216. "CallSite", // SymTagCallSite
  217. "InlineSite", // SymTagInlineSite
  218. "BaseInterface", // SymTagBaseInterface
  219. "VectorType", // SymTagVectorType
  220. "MatrixType", // SymTagMatrixType
  221. "HLSLType", // SymTagHLSLType
  222. "Caller", // SymTagCaller
  223. "Callee", // SymTagCallee
  224. "Export", // SymTagExport
  225. "HeapAllocationSite", // SymTagHeapAllocationSite
  226. "CoffGroup", // SymTagCoffGroup
  227. };
  228. // Aligned to LocationType.
  229. const char *LocationTypeText[] =
  230. {
  231. "Null",
  232. "Static",
  233. "TLS",
  234. "RegRel",
  235. "ThisRel",
  236. "Enregistered",
  237. "BitField",
  238. "Slot",
  239. "IlRel",
  240. "MetaData",
  241. "Constant",
  242. };
  243. // Aligned to DataKind.
  244. const char *DataKindText[] =
  245. {
  246. "Unknown",
  247. "Local",
  248. "StaticLocal",
  249. "Param",
  250. "ObjectPtr",
  251. "FileStatic",
  252. "Global",
  253. "Member",
  254. "StaticMember",
  255. "Constant",
  256. };
  257. // Aligned to UdtKind.
  258. const char *UdtKindText[] =
  259. {
  260. "Struct",
  261. "Class",
  262. "Union",
  263. "Interface",
  264. };
  265. // BasicType is not contiguous.
  266. const char *GetBasicTypeText(enum BasicType value) {
  267. switch (value) {
  268. case btNoType: return "NoType";
  269. case btVoid: return "Void";
  270. case btChar: return "Char";
  271. case btWChar: return "WChar";
  272. case btInt: return "Int";
  273. case btUInt: return "UInt";
  274. case btFloat: return "Float";
  275. case btBCD: return "BCD";
  276. case btBool: return "Bool";
  277. case btLong: return "Long";
  278. case btULong: return "ULong";
  279. case btCurrency: return "Currency";
  280. case btDate: return "Date";
  281. case btVariant: return "Variant";
  282. case btComplex: return "Complex";
  283. case btBit: return "Bit";
  284. case btBSTR: return "BSTR";
  285. case btHresult: return "Hresult";
  286. // The following may not be present in cvconst.h
  287. //case btChar16: return "Char16";
  288. //case btChar32: return "Char32";
  289. }
  290. return "?";
  291. }
  292. class TestIncludeHandler : public IDxcIncludeHandler {
  293. DXC_MICROCOM_REF_FIELD(m_dwRef)
  294. public:
  295. DXC_MICROCOM_ADDREF_RELEASE_IMPL(m_dwRef)
  296. dxc::DxcDllSupport &m_dllSupport;
  297. HRESULT m_defaultErrorCode = E_FAIL;
  298. TestIncludeHandler(dxc::DxcDllSupport &dllSupport) : m_dwRef(0), callIndex(0), m_dllSupport(dllSupport) { }
  299. __override HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void** ppvObject) {
  300. return DoBasicQueryInterface<IDxcIncludeHandler>(this, iid, ppvObject);
  301. }
  302. struct LoadSourceCallInfo {
  303. std::wstring Filename; // Filename as written in #include statement
  304. LoadSourceCallInfo(LPCWSTR pFilename) :
  305. Filename(pFilename) { }
  306. };
  307. std::vector<LoadSourceCallInfo> CallInfos;
  308. std::wstring GetAllFileNames() const {
  309. std::wstringstream s;
  310. for (size_t i = 0; i < CallInfos.size(); ++i) {
  311. s << CallInfos[i].Filename << ';';
  312. }
  313. return s.str();
  314. }
  315. struct LoadSourceCallResult {
  316. HRESULT hr;
  317. std::string source;
  318. LoadSourceCallResult() : hr(E_FAIL) { }
  319. LoadSourceCallResult(const char *pSource) : hr(S_OK), source(pSource) { }
  320. };
  321. std::vector<LoadSourceCallResult> CallResults;
  322. size_t callIndex;
  323. __override HRESULT STDMETHODCALLTYPE LoadSource(
  324. _In_ LPCWSTR pFilename, // Filename as written in #include statement
  325. _COM_Outptr_ IDxcBlob **ppIncludeSource // Resultant source object for included file
  326. ) {
  327. CallInfos.push_back(LoadSourceCallInfo(pFilename));
  328. *ppIncludeSource = nullptr;
  329. if (callIndex >= CallResults.size()) {
  330. return m_defaultErrorCode;
  331. }
  332. if (FAILED(CallResults[callIndex].hr)) {
  333. return CallResults[callIndex++].hr;
  334. }
  335. Utf8ToBlob(m_dllSupport, CallResults[callIndex].source, ppIncludeSource);
  336. return CallResults[callIndex++].hr;
  337. }
  338. };
  339. class CompilerTest {
  340. public:
  341. BEGIN_TEST_CLASS(CompilerTest)
  342. TEST_CLASS_PROPERTY(L"Parallel", L"true")
  343. TEST_METHOD_PROPERTY(L"Priority", L"0")
  344. END_TEST_CLASS()
  345. TEST_CLASS_SETUP(InitSupport);
  346. TEST_METHOD(CompileWhenDebugThenDIPresent)
  347. TEST_METHOD(CompileDebugLines)
  348. TEST_METHOD(CompileWhenDefinesThenApplied)
  349. TEST_METHOD(CompileWhenDefinesManyThenApplied)
  350. TEST_METHOD(CompileWhenEmptyThenFails)
  351. TEST_METHOD(CompileWhenIncorrectThenFails)
  352. TEST_METHOD(CompileWhenWorksThenDisassembleWorks)
  353. TEST_METHOD(CompileWhenDebugWorksThenStripDebug)
  354. TEST_METHOD(CompileWhenWorksThenAddRemovePrivate)
  355. TEST_METHOD(CompileWithRootSignatureThenStripRootSignature)
  356. TEST_METHOD(CompileWhenIncludeThenLoadInvoked)
  357. TEST_METHOD(CompileWhenIncludeThenLoadUsed)
  358. TEST_METHOD(CompileWhenIncludeAbsoluteThenLoadAbsolute)
  359. TEST_METHOD(CompileWhenIncludeLocalThenLoadRelative)
  360. TEST_METHOD(CompileWhenIncludeSystemThenLoadNotRelative)
  361. TEST_METHOD(CompileWhenIncludeSystemMissingThenLoadAttempt)
  362. TEST_METHOD(CompileWhenIncludeFlagsThenIncludeUsed)
  363. TEST_METHOD(CompileWhenIncludeMissingThenFail)
  364. TEST_METHOD(CompileWhenIncludeHasPathThenOK)
  365. TEST_METHOD(CompileWhenODumpThenPassConfig)
  366. TEST_METHOD(CompileWhenODumpThenOptimizerMatch)
  367. TEST_METHOD(CompileWhenVdThenProducesDxilContainer)
  368. TEST_METHOD(CompileWhenNoMemThenOOM)
  369. TEST_METHOD(CompileWhenShaderModelMismatchAttributeThenFail)
  370. TEST_METHOD(CompileBadHlslThenFail)
  371. TEST_METHOD(CompileLegacyShaderModelThenFail)
  372. TEST_METHOD(CompileWhenRecursiveAlbeitStaticTermThenFail)
  373. TEST_METHOD(CompileWhenRecursiveThenFail)
  374. TEST_METHOD(CompileHlsl2015ThenFail)
  375. TEST_METHOD(CompileHlsl2016ThenOK)
  376. TEST_METHOD(CompileHlsl2017ThenOK)
  377. TEST_METHOD(CompileHlsl2018ThenFail)
  378. TEST_METHOD(DiaLoadBadBitcodeThenFail)
  379. TEST_METHOD(DiaLoadDebugThenOK)
  380. TEST_METHOD(DiaTableIndexThenOK)
  381. TEST_METHOD(PixMSAAToSample0)
  382. TEST_METHOD(PixRemoveDiscards)
  383. TEST_METHOD(PixConstantColor)
  384. TEST_METHOD(PixConstantColorInt)
  385. TEST_METHOD(PixConstantColorMRT)
  386. TEST_METHOD(PixConstantColorUAVs)
  387. TEST_METHOD(PixConstantColorOtherSIVs)
  388. TEST_METHOD(PixConstantColorFromCB)
  389. TEST_METHOD(PixConstantColorFromCBint)
  390. TEST_METHOD(CodeGenAbs1)
  391. TEST_METHOD(CodeGenAbs2)
  392. TEST_METHOD(CodeGenAllLit)
  393. TEST_METHOD(CodeGenAllocaAtEntryBlk)
  394. TEST_METHOD(CodeGenAddUint64)
  395. TEST_METHOD(CodeGenArrayArg)
  396. TEST_METHOD(CodeGenArrayArg2)
  397. TEST_METHOD(CodeGenArrayArg3)
  398. TEST_METHOD(CodeGenArrayOfStruct)
  399. TEST_METHOD(CodeGenAsUint)
  400. TEST_METHOD(CodeGenAsUint2)
  401. TEST_METHOD(CodeGenAtomic)
  402. TEST_METHOD(CodeGenAtomic2)
  403. TEST_METHOD(CodeGenAttributeAtVertex)
  404. TEST_METHOD(CodeGenBarycentrics)
  405. TEST_METHOD(CodeGenBarycentrics1)
  406. TEST_METHOD(CodeGenBarycentricsThreeSV)
  407. TEST_METHOD(CodeGenBinary1)
  408. TEST_METHOD(CodeGenBoolComb)
  409. TEST_METHOD(CodeGenBoolSvTarget)
  410. TEST_METHOD(CodeGenCalcLod2DArray)
  411. TEST_METHOD(CodeGenCall1)
  412. TEST_METHOD(CodeGenCall3)
  413. TEST_METHOD(CodeGenCast1)
  414. TEST_METHOD(CodeGenCast2)
  415. TEST_METHOD(CodeGenCast3)
  416. TEST_METHOD(CodeGenCast4)
  417. TEST_METHOD(CodeGenCast5)
  418. TEST_METHOD(CodeGenCast6)
  419. TEST_METHOD(CodeGenCast7)
  420. TEST_METHOD(CodeGenCbuf_init_static)
  421. TEST_METHOD(CodeGenCbufferCopy)
  422. TEST_METHOD(CodeGenCbufferCopy1)
  423. TEST_METHOD(CodeGenCbufferCopy2)
  424. TEST_METHOD(CodeGenCbufferCopy3)
  425. TEST_METHOD(CodeGenCbufferCopy4)
  426. TEST_METHOD(CodeGenCbuffer_unused)
  427. TEST_METHOD(CodeGenCbuffer1_50)
  428. TEST_METHOD(CodeGenCbuffer1_51)
  429. TEST_METHOD(CodeGenCbuffer2_50)
  430. TEST_METHOD(CodeGenCbuffer2_51)
  431. TEST_METHOD(CodeGenCbuffer3_50)
  432. TEST_METHOD(CodeGenCbuffer3_51)
  433. TEST_METHOD(CodeGenCbuffer5_51)
  434. TEST_METHOD(CodeGenCbuffer6_51)
  435. TEST_METHOD(CodeGenCbufferAlloc)
  436. TEST_METHOD(CodeGenCbufferAllocLegacy)
  437. TEST_METHOD(CodeGenCbufferInLoop)
  438. TEST_METHOD(CodeGenClass)
  439. TEST_METHOD(CodeGenClip)
  440. TEST_METHOD(CodeGenClipPlanes)
  441. TEST_METHOD(CodeGenConstoperand1)
  442. TEST_METHOD(CodeGenConstMat)
  443. TEST_METHOD(CodeGenConstMat2)
  444. TEST_METHOD(CodeGenConstMat3)
  445. TEST_METHOD(CodeGenConstMat4)
  446. TEST_METHOD(CodeGenDiscard)
  447. TEST_METHOD(CodeGenDivZero)
  448. TEST_METHOD(CodeGenDot1)
  449. TEST_METHOD(CodeGenDynamic_Resources)
  450. TEST_METHOD(CodeGenEffectSkip)
  451. TEST_METHOD(CodeGenEliminateDynamicIndexing)
  452. TEST_METHOD(CodeGenEliminateDynamicIndexing2)
  453. TEST_METHOD(CodeGenEliminateDynamicIndexing3)
  454. TEST_METHOD(CodeGenEliminateDynamicIndexing4)
  455. TEST_METHOD(CodeGenEliminateDynamicIndexing5)
  456. TEST_METHOD(CodeGenEliminateDynamicIndexing6)
  457. TEST_METHOD(CodeGenEmpty)
  458. TEST_METHOD(CodeGenEmptyStruct)
  459. TEST_METHOD(CodeGenEnum1)
  460. TEST_METHOD(CodeGenEnum2)
  461. TEST_METHOD(CodeGenEnum3)
  462. TEST_METHOD(CodeGenEnum4)
  463. TEST_METHOD(CodeGenEnum5)
  464. TEST_METHOD(CodeGenEnum6)
  465. TEST_METHOD(CodeGenEarlyDepthStencil)
  466. TEST_METHOD(CodeGenEval)
  467. TEST_METHOD(CodeGenEvalInvalid)
  468. TEST_METHOD(CodeGenEvalMat)
  469. TEST_METHOD(CodeGenEvalMatMember)
  470. TEST_METHOD(CodeGenEvalPos)
  471. TEST_METHOD(CodeGenExternRes)
  472. TEST_METHOD(CodeGenExpandTrig)
  473. TEST_METHOD(CodeGenFloatCast)
  474. TEST_METHOD(CodeGenFloatToBool)
  475. TEST_METHOD(CodeGenFirstbitHi)
  476. TEST_METHOD(CodeGenFirstbitLo)
  477. TEST_METHOD(CodeGenFloatMaxtessfactor)
  478. TEST_METHOD(CodeGenFModPS)
  479. TEST_METHOD(CodeGenFuncCast)
  480. TEST_METHOD(CodeGenFunctionalCast)
  481. TEST_METHOD(CodeGenGather)
  482. TEST_METHOD(CodeGenGatherCmp)
  483. TEST_METHOD(CodeGenGatherCubeOffset)
  484. TEST_METHOD(CodeGenGatherOffset)
  485. TEST_METHOD(CodeGenGepZeroIdx)
  486. TEST_METHOD(CodeGenGloballyCoherent)
  487. TEST_METHOD(CodeGenI32ColIdx)
  488. TEST_METHOD(CodeGenIcb1)
  489. TEST_METHOD(CodeGenIf1)
  490. TEST_METHOD(CodeGenIf2)
  491. TEST_METHOD(CodeGenIf3)
  492. TEST_METHOD(CodeGenIf4)
  493. TEST_METHOD(CodeGenIf5)
  494. TEST_METHOD(CodeGenIf6)
  495. TEST_METHOD(CodeGenIf7)
  496. TEST_METHOD(CodeGenIf8)
  497. TEST_METHOD(CodeGenIf9)
  498. TEST_METHOD(CodeGenImm0)
  499. TEST_METHOD(CodeGenInclude)
  500. TEST_METHOD(CodeGenIncompletePos)
  501. TEST_METHOD(CodeGenIndexableinput1)
  502. TEST_METHOD(CodeGenIndexableinput2)
  503. TEST_METHOD(CodeGenIndexableinput3)
  504. TEST_METHOD(CodeGenIndexableinput4)
  505. TEST_METHOD(CodeGenIndexableoutput1)
  506. TEST_METHOD(CodeGenIndexabletemp1)
  507. TEST_METHOD(CodeGenIndexabletemp2)
  508. TEST_METHOD(CodeGenIndexabletemp3)
  509. TEST_METHOD(CodeGenInitListType)
  510. TEST_METHOD(CodeGenInoutSE)
  511. TEST_METHOD(CodeGenInout1)
  512. TEST_METHOD(CodeGenInout2)
  513. TEST_METHOD(CodeGenInout3)
  514. TEST_METHOD(CodeGenInout4)
  515. TEST_METHOD(CodeGenInout5)
  516. TEST_METHOD(CodeGenInput1)
  517. TEST_METHOD(CodeGenInput2)
  518. TEST_METHOD(CodeGenInput3)
  519. TEST_METHOD(CodeGenIntrinsic1)
  520. TEST_METHOD(CodeGenIntrinsic2)
  521. TEST_METHOD(CodeGenIntrinsic3_even)
  522. TEST_METHOD(CodeGenIntrinsic3_integer)
  523. TEST_METHOD(CodeGenIntrinsic3_odd)
  524. TEST_METHOD(CodeGenIntrinsic3_pow2)
  525. TEST_METHOD(CodeGenIntrinsic4)
  526. TEST_METHOD(CodeGenIntrinsic4_dbg)
  527. TEST_METHOD(CodeGenIntrinsic5)
  528. TEST_METHOD(CodeGenInvalidInputOutputTypes)
  529. TEST_METHOD(CodeGenLegacyStruct)
  530. TEST_METHOD(CodeGenLibCsEntry)
  531. TEST_METHOD(CodeGenLibCsEntry2)
  532. TEST_METHOD(CodeGenLibCsEntry3)
  533. TEST_METHOD(CodeGenLibEntries)
  534. TEST_METHOD(CodeGenLibEntries2)
  535. TEST_METHOD(CodeGenLibNoAlias)
  536. TEST_METHOD(CodeGenLibResource)
  537. TEST_METHOD(CodeGenLibUnusedFunc)
  538. TEST_METHOD(CodeGenLitInParen)
  539. TEST_METHOD(CodeGenLiteralShift)
  540. TEST_METHOD(CodeGenLiveness1)
  541. TEST_METHOD(CodeGenLocalRes1)
  542. TEST_METHOD(CodeGenLocalRes4)
  543. TEST_METHOD(CodeGenLocalRes7)
  544. TEST_METHOD(CodeGenLocalRes7Dbg)
  545. TEST_METHOD(CodeGenLoop1)
  546. TEST_METHOD(CodeGenLoop2)
  547. TEST_METHOD(CodeGenLoop3)
  548. TEST_METHOD(CodeGenLoop4)
  549. TEST_METHOD(CodeGenLoop5)
  550. TEST_METHOD(CodeGenLoop6)
  551. TEST_METHOD(CodeGenMatParam)
  552. TEST_METHOD(CodeGenMatParam2)
  553. // TEST_METHOD(CodeGenMatParam3)
  554. TEST_METHOD(CodeGenMatElt)
  555. TEST_METHOD(CodeGenMatInit)
  556. TEST_METHOD(CodeGenMatMulMat)
  557. TEST_METHOD(CodeGenMatOps)
  558. TEST_METHOD(CodeGenMatInStruct)
  559. TEST_METHOD(CodeGenMatInStructRet)
  560. TEST_METHOD(CodeGenMatIn)
  561. TEST_METHOD(CodeGenMatIn1)
  562. TEST_METHOD(CodeGenMatIn2)
  563. TEST_METHOD(CodeGenMatOut)
  564. TEST_METHOD(CodeGenMatOut1)
  565. TEST_METHOD(CodeGenMatOut2)
  566. TEST_METHOD(CodeGenMatSubscript)
  567. TEST_METHOD(CodeGenMatSubscript2)
  568. TEST_METHOD(CodeGenMatSubscript3)
  569. TEST_METHOD(CodeGenMatSubscript4)
  570. TEST_METHOD(CodeGenMatSubscript5)
  571. TEST_METHOD(CodeGenMatSubscript6)
  572. TEST_METHOD(CodeGenMatSubscript7)
  573. TEST_METHOD(CodeGenMaxMin)
  574. TEST_METHOD(CodeGenMinprec1)
  575. TEST_METHOD(CodeGenMinprec2)
  576. TEST_METHOD(CodeGenMinprec3)
  577. TEST_METHOD(CodeGenMinprec4)
  578. TEST_METHOD(CodeGenMinprec5)
  579. TEST_METHOD(CodeGenMinprec6)
  580. TEST_METHOD(CodeGenMinprec7)
  581. TEST_METHOD(CodeGenModf)
  582. TEST_METHOD(CodeGenMinprecCast)
  583. TEST_METHOD(CodeGenMultiUAVLoad1)
  584. TEST_METHOD(CodeGenMultiUAVLoad2)
  585. TEST_METHOD(CodeGenMultiUAVLoad3)
  586. TEST_METHOD(CodeGenMultiUAVLoad4)
  587. TEST_METHOD(CodeGenMultiUAVLoad5)
  588. TEST_METHOD(CodeGenMultiUAVLoad6)
  589. TEST_METHOD(CodeGenMultiUAVLoad7)
  590. TEST_METHOD(CodeGenMultiStream)
  591. TEST_METHOD(CodeGenMultiStream2)
  592. TEST_METHOD(CodeGenNeg1)
  593. TEST_METHOD(CodeGenNeg2)
  594. TEST_METHOD(CodeGenNegabs1)
  595. TEST_METHOD(CodeGenNoise)
  596. TEST_METHOD(CodeGenNonUniform)
  597. TEST_METHOD(CodeGenOptForNoOpt)
  598. TEST_METHOD(CodeGenOptForNoOpt2)
  599. TEST_METHOD(CodeGenOptionGis)
  600. TEST_METHOD(CodeGenOptionWX)
  601. TEST_METHOD(CodeGenOutput1)
  602. TEST_METHOD(CodeGenOutput2)
  603. TEST_METHOD(CodeGenOutput3)
  604. TEST_METHOD(CodeGenOutput4)
  605. TEST_METHOD(CodeGenOutput5)
  606. TEST_METHOD(CodeGenOutput6)
  607. TEST_METHOD(CodeGenOutputArray)
  608. TEST_METHOD(CodeGenPassthrough1)
  609. TEST_METHOD(CodeGenPassthrough2)
  610. TEST_METHOD(CodeGenPrecise1)
  611. TEST_METHOD(CodeGenPrecise2)
  612. TEST_METHOD(CodeGenPrecise3)
  613. TEST_METHOD(CodeGenPrecise4)
  614. TEST_METHOD(CodeGenPreciseOnCall)
  615. TEST_METHOD(CodeGenPreciseOnCallNot)
  616. TEST_METHOD(CodeGenPreserveAllOutputs)
  617. TEST_METHOD(CodeGenRaceCond2)
  618. TEST_METHOD(CodeGenRaw_Buf1)
  619. TEST_METHOD(CodeGenRcp1)
  620. TEST_METHOD(CodeGenReadFromOutput)
  621. TEST_METHOD(CodeGenReadFromOutput2)
  622. TEST_METHOD(CodeGenReadFromOutput3)
  623. TEST_METHOD(CodeGenRedundantinput1)
  624. TEST_METHOD(CodeGenRes64bit)
  625. TEST_METHOD(CodeGenRovs)
  626. TEST_METHOD(CodeGenRValAssign)
  627. TEST_METHOD(CodeGenRValSubscript)
  628. TEST_METHOD(CodeGenSample1)
  629. TEST_METHOD(CodeGenSample2)
  630. TEST_METHOD(CodeGenSample3)
  631. TEST_METHOD(CodeGenSample4)
  632. TEST_METHOD(CodeGenSample5)
  633. TEST_METHOD(CodeGenSampleBias)
  634. TEST_METHOD(CodeGenSampleCmp)
  635. TEST_METHOD(CodeGenSampleCmpLZ)
  636. TEST_METHOD(CodeGenSampleCmpLZ2)
  637. TEST_METHOD(CodeGenSampleGrad)
  638. TEST_METHOD(CodeGenSampleL)
  639. TEST_METHOD(CodeGenSaturate1)
  640. TEST_METHOD(CodeGenScalarOnVecIntrinsic)
  641. TEST_METHOD(CodeGenScalarToVec)
  642. TEST_METHOD(CodeGenSelectObj)
  643. TEST_METHOD(CodeGenSelectObj2)
  644. TEST_METHOD(CodeGenSelectObj3)
  645. TEST_METHOD(CodeGenSelectObj4)
  646. TEST_METHOD(CodeGenSelectObj5)
  647. TEST_METHOD(CodeGenSelfCopy)
  648. TEST_METHOD(CodeGenSelMat)
  649. TEST_METHOD(CodeGenShaderAttr)
  650. TEST_METHOD(CodeGenShare_Mem_Dbg)
  651. TEST_METHOD(CodeGenShare_Mem_Phi)
  652. TEST_METHOD(CodeGenShare_Mem1)
  653. TEST_METHOD(CodeGenShare_Mem2)
  654. TEST_METHOD(CodeGenShare_Mem2Dim)
  655. TEST_METHOD(CodeGenShift)
  656. TEST_METHOD(CodeGenShortCircuiting0)
  657. TEST_METHOD(CodeGenShortCircuiting1)
  658. TEST_METHOD(CodeGenShortCircuiting2)
  659. TEST_METHOD(CodeGenShortCircuiting3)
  660. TEST_METHOD(CodeGenSimpleDS1)
  661. TEST_METHOD(CodeGenSimpleGS1)
  662. TEST_METHOD(CodeGenSimpleGS2)
  663. TEST_METHOD(CodeGenSimpleGS3)
  664. TEST_METHOD(CodeGenSimpleGS4)
  665. TEST_METHOD(CodeGenSimpleGS5)
  666. TEST_METHOD(CodeGenSimpleGS6)
  667. TEST_METHOD(CodeGenSimpleGS7)
  668. TEST_METHOD(CodeGenSimpleGS11)
  669. TEST_METHOD(CodeGenSimpleGS12)
  670. TEST_METHOD(CodeGenSimpleHS1)
  671. TEST_METHOD(CodeGenSimpleHS2)
  672. TEST_METHOD(CodeGenSimpleHS3)
  673. TEST_METHOD(CodeGenSimpleHS4)
  674. TEST_METHOD(CodeGenSimpleHS5)
  675. TEST_METHOD(CodeGenSimpleHS6)
  676. TEST_METHOD(CodeGenSimpleHS7)
  677. TEST_METHOD(CodeGenSimpleHS8)
  678. TEST_METHOD(CodeGenSMFail)
  679. TEST_METHOD(CodeGenSrv_Ms_Load1)
  680. TEST_METHOD(CodeGenSrv_Ms_Load2)
  681. TEST_METHOD(CodeGenSrv_Typed_Load1)
  682. TEST_METHOD(CodeGenSrv_Typed_Load2)
  683. TEST_METHOD(CodeGenStaticConstGlobal)
  684. TEST_METHOD(CodeGenStaticConstGlobal2)
  685. TEST_METHOD(CodeGenStaticGlobals)
  686. TEST_METHOD(CodeGenStaticGlobals2)
  687. TEST_METHOD(CodeGenStaticGlobals3)
  688. TEST_METHOD(CodeGenStaticGlobals4)
  689. TEST_METHOD(CodeGenStaticMatrix)
  690. TEST_METHOD(CodeGenStaticResource)
  691. TEST_METHOD(CodeGenStaticResource2)
  692. TEST_METHOD(CodeGenStruct_Buf1)
  693. TEST_METHOD(CodeGenStruct_BufHasCounter)
  694. TEST_METHOD(CodeGenStruct_BufHasCounter2)
  695. TEST_METHOD(CodeGenStructArray)
  696. TEST_METHOD(CodeGenStructCast)
  697. TEST_METHOD(CodeGenStructCast2)
  698. TEST_METHOD(CodeGenStructInBuffer)
  699. TEST_METHOD(CodeGenStructInBuffer2)
  700. TEST_METHOD(CodeGenStructInBuffer3)
  701. TEST_METHOD(CodeGenSwitchFloat)
  702. TEST_METHOD(CodeGenSwitch1)
  703. TEST_METHOD(CodeGenSwitch2)
  704. TEST_METHOD(CodeGenSwitch3)
  705. TEST_METHOD(CodeGenSwizzle1)
  706. TEST_METHOD(CodeGenSwizzle2)
  707. TEST_METHOD(CodeGenSwizzleAtomic)
  708. TEST_METHOD(CodeGenSwizzleAtomic2)
  709. TEST_METHOD(CodeGenSwizzleIndexing)
  710. TEST_METHOD(CodeGenTempDbgInfo)
  711. TEST_METHOD(CodeGenTemp1)
  712. TEST_METHOD(CodeGenTemp2)
  713. TEST_METHOD(CodeGenTexSubscript)
  714. TEST_METHOD(CodeGenUav_Raw1)
  715. TEST_METHOD(CodeGenUav_Typed_Load_Store1)
  716. TEST_METHOD(CodeGenUav_Typed_Load_Store2)
  717. TEST_METHOD(CodeGenUint64_1)
  718. TEST_METHOD(CodeGenUint64_2)
  719. TEST_METHOD(CodeGenUintSample)
  720. TEST_METHOD(CodeGenUmaxObjectAtomic)
  721. TEST_METHOD(CodeGenUnrollDbg)
  722. TEST_METHOD(CodeGenUnsignedShortHandMatrixVector)
  723. TEST_METHOD(CodeGenUnusedFunc)
  724. TEST_METHOD(CodeGenUnusedCB)
  725. TEST_METHOD(CodeGenUpdateCounter)
  726. TEST_METHOD(CodeGenUpperCaseRegister1);
  727. TEST_METHOD(CodeGenVcmp)
  728. TEST_METHOD(CodeGenVecBitCast)
  729. TEST_METHOD(CodeGenVec_Comp_Arg)
  730. TEST_METHOD(CodeGenVecCmpCond)
  731. TEST_METHOD(CodeGenVecTrunc)
  732. TEST_METHOD(CodeGenWave)
  733. TEST_METHOD(CodeGenWaveNoOpt)
  734. TEST_METHOD(CodeGenWriteMaskBuf)
  735. TEST_METHOD(CodeGenWriteMaskBuf2)
  736. TEST_METHOD(CodeGenWriteMaskBuf3)
  737. TEST_METHOD(CodeGenWriteMaskBuf4)
  738. TEST_METHOD(CodeGenWriteToInput)
  739. TEST_METHOD(CodeGenWriteToInput2)
  740. TEST_METHOD(CodeGenWriteToInput3)
  741. TEST_METHOD(CodeGenAttributes_Mod)
  742. TEST_METHOD(CodeGenConst_Exprb_Mod)
  743. TEST_METHOD(CodeGenConst_Expr_Mod)
  744. TEST_METHOD(CodeGenFunctions_Mod)
  745. TEST_METHOD(CodeGenImplicit_Casts_Mod)
  746. TEST_METHOD(CodeGenIndexing_Operator_Mod)
  747. TEST_METHOD(CodeGenIntrinsic_Examples_Mod)
  748. TEST_METHOD(CodeGenLiterals_Mod)
  749. TEST_METHOD(CodeGenMatrix_Assignments_Mod)
  750. TEST_METHOD(CodeGenMatrix_Syntax_Mod)
  751. //TEST_METHOD(CodeGenMore_Operators_Mod)
  752. //TEST_METHOD(CodeGenObject_Operators_Mod)
  753. TEST_METHOD(CodeGenPackreg_Mod)
  754. TEST_METHOD(CodeGenParameter_Types)
  755. TEST_METHOD(CodeGenScalar_Assignments_Mod)
  756. TEST_METHOD(CodeGenScalar_Operators_Assign_Mod)
  757. TEST_METHOD(CodeGenScalar_Operators_Mod)
  758. TEST_METHOD(CodeGenSemantics_Mod)
  759. //TEST_METHOD(CodeGenSpec_Mod)
  760. TEST_METHOD(CodeGenString_Mod)
  761. TEST_METHOD(CodeGenStruct_Assignments_Mod)
  762. TEST_METHOD(CodeGenStruct_AssignmentsFull_Mod)
  763. TEST_METHOD(CodeGenTemplate_Checks_Mod)
  764. TEST_METHOD(CodeGenToinclude2_Mod)
  765. TEST_METHOD(CodeGenTypemods_Syntax_Mod)
  766. TEST_METHOD(CodeGenVarmods_Syntax_Mod)
  767. TEST_METHOD(CodeGenVector_Assignments_Mod)
  768. TEST_METHOD(CodeGenVector_Syntax_Mix_Mod)
  769. TEST_METHOD(CodeGenVector_Syntax_Mod)
  770. TEST_METHOD(CodeGenBasicHLSL11_PS)
  771. TEST_METHOD(CodeGenBasicHLSL11_PS2)
  772. TEST_METHOD(CodeGenBasicHLSL11_PS3)
  773. TEST_METHOD(CodeGenBasicHLSL11_VS)
  774. TEST_METHOD(CodeGenBasicHLSL11_VS2)
  775. TEST_METHOD(CodeGenVecIndexingInput)
  776. TEST_METHOD(CodeGenVecMulMat)
  777. TEST_METHOD(CodeGenVecArrayParam)
  778. TEST_METHOD(CodeGenBindings1)
  779. TEST_METHOD(CodeGenBindings2)
  780. TEST_METHOD(CodeGenBindings3)
  781. TEST_METHOD(CodeGenResCopy)
  782. TEST_METHOD(CodeGenResourceParam)
  783. TEST_METHOD(CodeGenResourceInCB)
  784. TEST_METHOD(CodeGenResourceInCB2)
  785. TEST_METHOD(CodeGenResourceInCB3)
  786. TEST_METHOD(CodeGenResourceInCB4)
  787. TEST_METHOD(CodeGenResourceInCBV)
  788. TEST_METHOD(CodeGenResourceInCBV2)
  789. TEST_METHOD(CodeGenResourceInStruct)
  790. TEST_METHOD(CodeGenResourceInStruct2)
  791. TEST_METHOD(CodeGenResourceInStruct3)
  792. TEST_METHOD(CodeGenResourceInTB)
  793. TEST_METHOD(CodeGenResourceInTB2)
  794. TEST_METHOD(CodeGenResourceInTBV)
  795. TEST_METHOD(CodeGenResourceInTBV2)
  796. TEST_METHOD(CodeGenResourceArrayParam)
  797. TEST_METHOD(CodeGenResPhi)
  798. TEST_METHOD(CodeGenResPhi2)
  799. TEST_METHOD(CodeGenRootSigEntry)
  800. TEST_METHOD(CodeGenRootSigProfile)
  801. TEST_METHOD(CodeGenRootSigProfile2)
  802. TEST_METHOD(CodeGenRootSigProfile3)
  803. TEST_METHOD(CodeGenRootSigProfile4)
  804. TEST_METHOD(CodeGenRootSigProfile5)
  805. TEST_METHOD(CodeGenRootSigDefine1)
  806. TEST_METHOD(CodeGenRootSigDefine2)
  807. TEST_METHOD(CodeGenRootSigDefine3)
  808. TEST_METHOD(CodeGenRootSigDefine4)
  809. TEST_METHOD(CodeGenRootSigDefine5)
  810. TEST_METHOD(CodeGenRootSigDefine6)
  811. TEST_METHOD(CodeGenRootSigDefine7)
  812. TEST_METHOD(CodeGenRootSigDefine8)
  813. TEST_METHOD(CodeGenRootSigDefine9)
  814. TEST_METHOD(CodeGenRootSigDefine10)
  815. TEST_METHOD(CodeGenRootSigDefine11)
  816. TEST_METHOD(CodeGenCBufferStructArray)
  817. TEST_METHOD(CodeGenPatchLength)
  818. TEST_METHOD(PreprocessWhenValidThenOK)
  819. TEST_METHOD(WhenSigMismatchPCFunctionThenFail)
  820. // Dx11 Sample
  821. TEST_METHOD(CodeGenDX11Sample_2Dquadshaders_Blurx_Ps)
  822. TEST_METHOD(CodeGenDX11Sample_2Dquadshaders_Blury_Ps)
  823. TEST_METHOD(CodeGenDX11Sample_2Dquadshaders_Vs)
  824. TEST_METHOD(CodeGenDX11Sample_Bc6Hdecode)
  825. TEST_METHOD(CodeGenDX11Sample_Bc6Hencode_Encodeblockcs)
  826. TEST_METHOD(CodeGenDX11Sample_Bc6Hencode_Trymodeg10Cs)
  827. TEST_METHOD(CodeGenDX11Sample_Bc6Hencode_Trymodele10Cs)
  828. TEST_METHOD(CodeGenDX11Sample_Bc7Decode)
  829. TEST_METHOD(CodeGenDX11Sample_Bc7Encode_Encodeblockcs)
  830. TEST_METHOD(CodeGenDX11Sample_Bc7Encode_Trymode02Cs)
  831. TEST_METHOD(CodeGenDX11Sample_Bc7Encode_Trymode137Cs)
  832. TEST_METHOD(CodeGenDX11Sample_Bc7Encode_Trymode456Cs)
  833. TEST_METHOD(CodeGenDX11Sample_Brightpassandhorizfiltercs)
  834. TEST_METHOD(CodeGenDX11Sample_Computeshadersort11)
  835. TEST_METHOD(CodeGenDX11Sample_Computeshadersort11_Matrixtranspose)
  836. TEST_METHOD(CodeGenDX11Sample_Contacthardeningshadows11_Ps)
  837. TEST_METHOD(CodeGenDX11Sample_Contacthardeningshadows11_Sm_Vs)
  838. TEST_METHOD(CodeGenDX11Sample_Contacthardeningshadows11_Vs)
  839. TEST_METHOD(CodeGenDX11Sample_Decaltessellation11_Ds)
  840. TEST_METHOD(CodeGenDX11Sample_Decaltessellation11_Hs)
  841. TEST_METHOD(CodeGenDX11Sample_Decaltessellation11_Ps)
  842. TEST_METHOD(CodeGenDX11Sample_Decaltessellation11_Tessvs)
  843. TEST_METHOD(CodeGenDX11Sample_Decaltessellation11_Vs)
  844. TEST_METHOD(CodeGenDX11Sample_Detailtessellation11_Ds)
  845. TEST_METHOD(CodeGenDX11Sample_Detailtessellation11_Hs)
  846. TEST_METHOD(CodeGenDX11Sample_Detailtessellation11_Ps)
  847. TEST_METHOD(CodeGenDX11Sample_Detailtessellation11_Tessvs)
  848. TEST_METHOD(CodeGenDX11Sample_Detailtessellation11_Vs)
  849. TEST_METHOD(CodeGenDX11Sample_Dumptotexture)
  850. TEST_METHOD(CodeGenDX11Sample_Filtercs_Horz)
  851. TEST_METHOD(CodeGenDX11Sample_Filtercs_Vertical)
  852. TEST_METHOD(CodeGenDX11Sample_Finalpass_Cpu_Ps)
  853. TEST_METHOD(CodeGenDX11Sample_Finalpass_Ps)
  854. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Buildgridcs)
  855. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Buildgridindicescs)
  856. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Cleargridindicescs)
  857. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Densitycs_Grid)
  858. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Densitycs_Shared)
  859. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Densitycs_Simple)
  860. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Forcecs_Grid)
  861. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Forcecs_Shared)
  862. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Forcecs_Simple)
  863. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Integratecs)
  864. TEST_METHOD(CodeGenDX11Sample_Fluidcs11_Rearrangeparticlescs)
  865. TEST_METHOD(CodeGenDX11Sample_Fluidrender_Gs)
  866. TEST_METHOD(CodeGenDX11Sample_Fluidrender_Vs)
  867. TEST_METHOD(CodeGenDX11Sample_Nbodygravitycs11)
  868. TEST_METHOD(CodeGenDX11Sample_Oit_Createprefixsum_Pass0_Cs)
  869. TEST_METHOD(CodeGenDX11Sample_Oit_Createprefixsum_Pass1_Cs)
  870. TEST_METHOD(CodeGenDX11Sample_Oit_Fragmentcountps)
  871. TEST_METHOD(CodeGenDX11Sample_Oit_Ps)
  872. TEST_METHOD(CodeGenDX11Sample_Oit_Sortandrendercs)
  873. TEST_METHOD(CodeGenDX11Sample_Particledraw_Gs)
  874. TEST_METHOD(CodeGenDX11Sample_Particledraw_Vs)
  875. TEST_METHOD(CodeGenDX11Sample_Particle_Gs)
  876. TEST_METHOD(CodeGenDX11Sample_Particle_Ps)
  877. TEST_METHOD(CodeGenDX11Sample_Particle_Vs)
  878. TEST_METHOD(CodeGenDX11Sample_Pntriangles11_Ds)
  879. TEST_METHOD(CodeGenDX11Sample_Pntriangles11_Hs)
  880. TEST_METHOD(CodeGenDX11Sample_Pntriangles11_Tessvs)
  881. TEST_METHOD(CodeGenDX11Sample_Pntriangles11_Vs)
  882. TEST_METHOD(CodeGenDX11Sample_Pom_Ps)
  883. TEST_METHOD(CodeGenDX11Sample_Pom_Vs)
  884. TEST_METHOD(CodeGenDX11Sample_Psapproach_Bloomps)
  885. TEST_METHOD(CodeGenDX11Sample_Psapproach_Downscale2X2_Lumps)
  886. TEST_METHOD(CodeGenDX11Sample_Psapproach_Downscale3X3Ps)
  887. TEST_METHOD(CodeGenDX11Sample_Psapproach_Downscale3X3_Brightpassps)
  888. TEST_METHOD(CodeGenDX11Sample_Psapproach_Finalpassps)
  889. TEST_METHOD(CodeGenDX11Sample_Reduceto1Dcs)
  890. TEST_METHOD(CodeGenDX11Sample_Reducetosinglecs)
  891. TEST_METHOD(CodeGenDX11Sample_Rendervariancesceneps)
  892. TEST_METHOD(CodeGenDX11Sample_Rendervs)
  893. TEST_METHOD(CodeGenDX11Sample_Simplebezier11Ds)
  894. TEST_METHOD(CodeGenDX11Sample_Simplebezier11Hs)
  895. TEST_METHOD(CodeGenDX11Sample_Simplebezier11Ps)
  896. TEST_METHOD(CodeGenDX11Sample_Subd11_Bezierevalds)
  897. TEST_METHOD(CodeGenDX11Sample_Subd11_Meshskinningvs)
  898. TEST_METHOD(CodeGenDX11Sample_Subd11_Patchskinningvs)
  899. TEST_METHOD(CodeGenDX11Sample_Subd11_Smoothps)
  900. TEST_METHOD(CodeGenDX11Sample_Subd11_Subdtobezierhs)
  901. TEST_METHOD(CodeGenDX11Sample_Subd11_Subdtobezierhs4444)
  902. TEST_METHOD(CodeGenDX11Sample_Tessellatorcs40_Edgefactorcs)
  903. TEST_METHOD(CodeGenDX11Sample_Tessellatorcs40_Numverticesindicescs)
  904. TEST_METHOD(CodeGenDX11Sample_Tessellatorcs40_Scatteridcs)
  905. TEST_METHOD(CodeGenDX11Sample_Tessellatorcs40_Tessellateindicescs)
  906. TEST_METHOD(CodeGenDX11Sample_Tessellatorcs40_Tessellateverticescs)
  907. // Dx12 Sample
  908. TEST_METHOD(CodeGenSamplesD12_DynamicIndexing_PS)
  909. TEST_METHOD(CodeGenSamplesD12_ExecuteIndirect_CS)
  910. TEST_METHOD(CodeGenSamplesD12_MultiThreading_VS)
  911. TEST_METHOD(CodeGenSamplesD12_MultiThreading_PS)
  912. TEST_METHOD(CodeGenSamplesD12_NBodyGravity_CS)
  913. // Dx12 samples/MiniEngine.
  914. TEST_METHOD(CodeGenDx12MiniEngineAdaptexposurecs)
  915. TEST_METHOD(CodeGenDx12MiniEngineAoblurupsampleblendoutcs)
  916. TEST_METHOD(CodeGenDx12MiniEngineAoblurupsamplecs)
  917. TEST_METHOD(CodeGenDx12MiniEngineAoblurupsamplepreminblendoutcs)
  918. TEST_METHOD(CodeGenDx12MiniEngineAoblurupsamplepremincs)
  919. TEST_METHOD(CodeGenDx12MiniEngineAopreparedepthbuffers1Cs)
  920. TEST_METHOD(CodeGenDx12MiniEngineAopreparedepthbuffers2Cs)
  921. TEST_METHOD(CodeGenDx12MiniEngineAorender1Cs)
  922. TEST_METHOD(CodeGenDx12MiniEngineAorender2Cs)
  923. TEST_METHOD(CodeGenDx12MiniEngineApplybloomcs)
  924. TEST_METHOD(CodeGenDx12MiniEngineAveragelumacs)
  925. TEST_METHOD(CodeGenDx12MiniEngineBicubichorizontalupsampleps)
  926. TEST_METHOD(CodeGenDx12MiniEngineBicubicupsamplegammaps)
  927. TEST_METHOD(CodeGenDx12MiniEngineBicubicupsampleps)
  928. TEST_METHOD(CodeGenDx12MiniEngineBicubicverticalupsampleps)
  929. TEST_METHOD(CodeGenDx12MiniEngineBilinearupsampleps)
  930. TEST_METHOD(CodeGenDx12MiniEngineBloomextractanddownsamplehdrcs)
  931. TEST_METHOD(CodeGenDx12MiniEngineBloomextractanddownsampleldrcs)
  932. TEST_METHOD(CodeGenDx12MiniEngineBlurcs)
  933. TEST_METHOD(CodeGenDx12MiniEngineBuffercopyps)
  934. TEST_METHOD(CodeGenDx12MiniEngineCameramotionblurprepasscs)
  935. TEST_METHOD(CodeGenDx12MiniEngineCameramotionblurprepasslinearzcs)
  936. TEST_METHOD(CodeGenDx12MiniEngineCameravelocitycs)
  937. TEST_METHOD(CodeGenDx12MiniEngineConvertldrtodisplayaltps)
  938. TEST_METHOD(CodeGenDx12MiniEngineConvertldrtodisplayps)
  939. TEST_METHOD(CodeGenDx12MiniEngineDebugdrawhistogramcs)
  940. TEST_METHOD(CodeGenDx12MiniEngineDebugluminancehdrcs)
  941. TEST_METHOD(CodeGenDx12MiniEngineDebugluminanceldrcs)
  942. TEST_METHOD(CodeGenDx12MiniEngineDebugssaocs)
  943. TEST_METHOD(CodeGenDx12MiniEngineDepthviewerps)
  944. TEST_METHOD(CodeGenDx12MiniEngineDepthviewervs)
  945. TEST_METHOD(CodeGenDx12MiniEngineDownsamplebloomallcs)
  946. TEST_METHOD(CodeGenDx12MiniEngineDownsamplebloomcs)
  947. TEST_METHOD(CodeGenDx12MiniEngineExtractlumacs)
  948. TEST_METHOD(CodeGenDx12MiniEngineFxaapass1_Luma_Cs)
  949. TEST_METHOD(CodeGenDx12MiniEngineFxaapass1_Rgb_Cs)
  950. TEST_METHOD(CodeGenDx12MiniEngineFxaapass2Hcs)
  951. TEST_METHOD(CodeGenDx12MiniEngineFxaapass2Hdebugcs)
  952. TEST_METHOD(CodeGenDx12MiniEngineFxaapass2Vcs)
  953. TEST_METHOD(CodeGenDx12MiniEngineFxaapass2Vdebugcs)
  954. TEST_METHOD(CodeGenDx12MiniEngineFxaaresolveworkqueuecs)
  955. TEST_METHOD(CodeGenDx12MiniEngineGeneratehistogramcs)
  956. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipsgammacs)
  957. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipsgammaoddcs)
  958. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipsgammaoddxcs)
  959. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipsgammaoddycs)
  960. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipslinearcs)
  961. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipslinearoddcs)
  962. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipslinearoddxcs)
  963. TEST_METHOD(CodeGenDx12MiniEngineGeneratemipslinearoddycs)
  964. TEST_METHOD(CodeGenDx12MiniEngineLinearizedepthcs)
  965. TEST_METHOD(CodeGenDx12MiniEngineMagnifypixelsps)
  966. TEST_METHOD(CodeGenDx12MiniEngineModelviewerps)
  967. TEST_METHOD(CodeGenDx12MiniEngineModelviewervs)
  968. TEST_METHOD(CodeGenDx12MiniEngineMotionblurfinalpasscs)
  969. TEST_METHOD(CodeGenDx12MiniEngineMotionblurfinalpasstemporalcs)
  970. TEST_METHOD(CodeGenDx12MiniEngineMotionblurprepasscs)
  971. TEST_METHOD(CodeGenDx12MiniEngineParticlebincullingcs)
  972. TEST_METHOD(CodeGenDx12MiniEngineParticledepthboundscs)
  973. TEST_METHOD(CodeGenDx12MiniEngineParticledispatchindirectargscs)
  974. TEST_METHOD(CodeGenDx12MiniEngineParticlefinaldispatchindirectargscs)
  975. TEST_METHOD(CodeGenDx12MiniEngineParticleinnersortcs)
  976. TEST_METHOD(CodeGenDx12MiniEngineParticlelargebincullingcs)
  977. TEST_METHOD(CodeGenDx12MiniEngineParticleoutersortcs)
  978. TEST_METHOD(CodeGenDx12MiniEngineParticlepresortcs)
  979. TEST_METHOD(CodeGenDx12MiniEngineParticleps)
  980. TEST_METHOD(CodeGenDx12MiniEngineParticlesortindirectargscs)
  981. TEST_METHOD(CodeGenDx12MiniEngineParticlespawncs)
  982. TEST_METHOD(CodeGenDx12MiniEngineParticletilecullingcs)
  983. TEST_METHOD(CodeGenDx12MiniEngineParticletilerendercs)
  984. TEST_METHOD(CodeGenDx12MiniEngineParticletilerenderfastcs)
  985. TEST_METHOD(CodeGenDx12MiniEngineParticletilerenderfastdynamiccs)
  986. TEST_METHOD(CodeGenDx12MiniEngineParticletilerenderfastlowrescs)
  987. TEST_METHOD(CodeGenDx12MiniEngineParticletilerenderslowdynamiccs)
  988. TEST_METHOD(CodeGenDx12MiniEngineParticletilerenderslowlowrescs)
  989. TEST_METHOD(CodeGenDx12MiniEngineParticleupdatecs)
  990. TEST_METHOD(CodeGenDx12MiniEngineParticlevs)
  991. TEST_METHOD(CodeGenDx12MiniEnginePerfgraphbackgroundvs)
  992. TEST_METHOD(CodeGenDx12MiniEnginePerfgraphps)
  993. TEST_METHOD(CodeGenDx12MiniEnginePerfgraphvs)
  994. TEST_METHOD(CodeGenDx12MiniEngineScreenquadvs)
  995. TEST_METHOD(CodeGenDx12MiniEngineSharpeningupsamplegammaps)
  996. TEST_METHOD(CodeGenDx12MiniEngineSharpeningupsampleps)
  997. TEST_METHOD(CodeGenDx12MiniEngineTemporalblendcs)
  998. TEST_METHOD(CodeGenDx12MiniEngineTextantialiasps)
  999. TEST_METHOD(CodeGenDx12MiniEngineTextshadowps)
  1000. TEST_METHOD(CodeGenDx12MiniEngineTextvs)
  1001. TEST_METHOD(CodeGenDx12MiniEngineTonemap2Cs)
  1002. TEST_METHOD(CodeGenDx12MiniEngineTonemapcs)
  1003. TEST_METHOD(CodeGenDx12MiniEngineUpsampleandblurcs)
  1004. TEST_METHOD(DxilGen_StoreOutput)
  1005. TEST_METHOD(ConstantFolding)
  1006. TEST_METHOD(HoistConstantArray)
  1007. TEST_METHOD(ViewID)
  1008. TEST_METHOD(ShaderCompatSuite)
  1009. BEGIN_TEST_METHOD(SingleFileCheckTest)
  1010. TEST_METHOD_PROPERTY(L"Ignore", L"true")
  1011. END_TEST_METHOD()
  1012. dxc::DxcDllSupport m_dllSupport;
  1013. VersionSupportInfo m_ver;
  1014. void CreateBlobPinned(_In_bytecount_(size) LPCVOID data, SIZE_T size,
  1015. UINT32 codePage, _Outptr_ IDxcBlobEncoding **ppBlob) {
  1016. CComPtr<IDxcLibrary> library;
  1017. IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
  1018. IFT(library->CreateBlobWithEncodingFromPinned((LPBYTE)data, size, codePage,
  1019. ppBlob));
  1020. }
  1021. void CreateBlobFromFile(LPCWSTR name, _Outptr_ IDxcBlobEncoding **ppBlob) {
  1022. CComPtr<IDxcLibrary> library;
  1023. IFT(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &library));
  1024. const std::wstring path = hlsl_test::GetPathToHlslDataFile(name);
  1025. IFT(library->CreateBlobFromFile(path.c_str(), nullptr, ppBlob));
  1026. }
  1027. void CreateBlobFromText(_In_z_ const char *pText,
  1028. _Outptr_ IDxcBlobEncoding **ppBlob) {
  1029. CreateBlobPinned(pText, strlen(pText), CP_UTF8, ppBlob);
  1030. }
  1031. HRESULT CreateCompiler(IDxcCompiler **ppResult) {
  1032. return m_dllSupport.CreateInstance(CLSID_DxcCompiler, ppResult);
  1033. }
  1034. HRESULT CreateContainerBuilder(IDxcContainerBuilder **ppResult) {
  1035. return m_dllSupport.CreateInstance(CLSID_DxcContainerBuilder, ppResult);
  1036. }
  1037. template <typename T, typename TDefault, typename TIface>
  1038. void WriteIfValue(TIface *pSymbol, std::wstringstream &o,
  1039. TDefault defaultValue, LPCWSTR valueLabel,
  1040. HRESULT (__stdcall TIface::*pFn)(T *)) {
  1041. T value;
  1042. HRESULT hr = (pSymbol->*(pFn))(&value);
  1043. if (SUCCEEDED(hr) && value != defaultValue) {
  1044. o << L", " << valueLabel << L": " << value;
  1045. }
  1046. }
  1047. template <typename TIface>
  1048. void WriteIfValue(TIface *pSymbol, std::wstringstream &o,
  1049. LPCWSTR valueLabel, HRESULT(__stdcall TIface::*pFn)(BSTR *)) {
  1050. CComBSTR value;
  1051. HRESULT hr = (pSymbol->*(pFn))(&value);
  1052. if (SUCCEEDED(hr) && value.Length()) {
  1053. o << L", " << valueLabel << L": " << (LPCWSTR)value;
  1054. }
  1055. }
  1056. template <typename TIface>
  1057. void WriteIfValue(TIface *pSymbol, std::wstringstream &o,
  1058. LPCWSTR valueLabel, HRESULT(__stdcall TIface::*pFn)(VARIANT *)) {
  1059. CComVariant value;
  1060. HRESULT hr = (pSymbol->*(pFn))(&value);
  1061. if (SUCCEEDED(hr) && value.vt != VT_NULL && value.vt != VT_EMPTY) {
  1062. if (SUCCEEDED(value.ChangeType(VT_BSTR))) {
  1063. o << L", " << valueLabel << L": " << (LPCWSTR)value.bstrVal;
  1064. }
  1065. }
  1066. }
  1067. template <typename TIface>
  1068. void WriteIfValue(TIface *pSymbol, std::wstringstream &o,
  1069. LPCWSTR valueLabel, HRESULT(__stdcall TIface::*pFn)(IDiaSymbol **)) {
  1070. CComPtr<IDiaSymbol> value;
  1071. HRESULT hr = (pSymbol->*(pFn))(&value);
  1072. if (SUCCEEDED(hr) && value.p != nullptr) {
  1073. DWORD symId;
  1074. value->get_symIndexId(&symId);
  1075. o << L", " << valueLabel << L": id=" << symId;
  1076. }
  1077. }
  1078. std::wstring GetDebugInfoAsText(_In_ IDiaDataSource* pDataSource) {
  1079. CComPtr<IDiaSession> pSession;
  1080. CComPtr<IDiaTable> pTable;
  1081. CComPtr<IDiaEnumTables> pEnumTables;
  1082. std::wstringstream o;
  1083. VERIFY_SUCCEEDED(pDataSource->openSession(&pSession));
  1084. VERIFY_SUCCEEDED(pSession->getEnumTables(&pEnumTables));
  1085. LONG count;
  1086. VERIFY_SUCCEEDED(pEnumTables->get_Count(&count));
  1087. for (LONG i = 0; i < count; ++i) {
  1088. pTable.Release();
  1089. ULONG fetched;
  1090. VERIFY_SUCCEEDED(pEnumTables->Next(1, &pTable, &fetched));
  1091. VERIFY_ARE_EQUAL(fetched, 1);
  1092. CComBSTR tableName;
  1093. VERIFY_SUCCEEDED(pTable->get_name(&tableName));
  1094. o << L"Table: " << (LPWSTR)tableName << std::endl;
  1095. LONG rowCount;
  1096. IFT(pTable->get_Count(&rowCount));
  1097. o << L" Row count: " << rowCount << std::endl;
  1098. for (LONG rowIndex = 0; rowIndex < rowCount; ++rowIndex) {
  1099. CComPtr<IUnknown> item;
  1100. o << L'#' << rowIndex;
  1101. IFT(pTable->Item(rowIndex, &item));
  1102. CComPtr<IDiaSymbol> pSymbol;
  1103. if (SUCCEEDED(item.QueryInterface(&pSymbol))) {
  1104. DWORD symTag;
  1105. DWORD dataKind;
  1106. DWORD locationType;
  1107. DWORD registerId;
  1108. pSymbol->get_symTag(&symTag);
  1109. pSymbol->get_dataKind(&dataKind);
  1110. pSymbol->get_locationType(&locationType);
  1111. pSymbol->get_registerId(&registerId);
  1112. //pSymbol->get_value(&value);
  1113. WriteIfValue(pSymbol.p, o, 0, L"symIndexId", &IDiaSymbol::get_symIndexId);
  1114. o << L", " << SymTagEnumText[symTag];
  1115. if (dataKind != 0) o << L", " << DataKindText[dataKind];
  1116. WriteIfValue(pSymbol.p, o, L"name", &IDiaSymbol::get_name);
  1117. WriteIfValue(pSymbol.p, o, L"lexicalParent", &IDiaSymbol::get_lexicalParent);
  1118. WriteIfValue(pSymbol.p, o, L"type", &IDiaSymbol::get_type);
  1119. WriteIfValue(pSymbol.p, o, 0, L"slot", &IDiaSymbol::get_slot);
  1120. WriteIfValue(pSymbol.p, o, 0, L"platform", &IDiaSymbol::get_platform);
  1121. WriteIfValue(pSymbol.p, o, 0, L"language", &IDiaSymbol::get_language);
  1122. WriteIfValue(pSymbol.p, o, 0, L"frontEndMajor", &IDiaSymbol::get_frontEndMajor);
  1123. WriteIfValue(pSymbol.p, o, 0, L"frontEndMinor", &IDiaSymbol::get_frontEndMinor);
  1124. WriteIfValue(pSymbol.p, o, 0, L"token", &IDiaSymbol::get_token);
  1125. WriteIfValue(pSymbol.p, o, L"value", &IDiaSymbol::get_value);
  1126. WriteIfValue(pSymbol.p, o, 0, L"code", &IDiaSymbol::get_code);
  1127. WriteIfValue(pSymbol.p, o, 0, L"function", &IDiaSymbol::get_function);
  1128. WriteIfValue(pSymbol.p, o, 0, L"udtKind", &IDiaSymbol::get_udtKind);
  1129. WriteIfValue(pSymbol.p, o, 0, L"hasDebugInfo", &IDiaSymbol::get_hasDebugInfo);
  1130. WriteIfValue(pSymbol.p, o, L"compilerName", &IDiaSymbol::get_compilerName);
  1131. WriteIfValue(pSymbol.p, o, 0, L"isLocationControlFlowDependent", &IDiaSymbol::get_isLocationControlFlowDependent);
  1132. WriteIfValue(pSymbol.p, o, 0, L"numberOfRows", &IDiaSymbol::get_numberOfRows);
  1133. WriteIfValue(pSymbol.p, o, 0, L"numberOfColumns", &IDiaSymbol::get_numberOfColumns);
  1134. WriteIfValue(pSymbol.p, o, 0, L"length", &IDiaSymbol::get_length);
  1135. WriteIfValue(pSymbol.p, o, 0, L"isMatrixRowMajor", &IDiaSymbol::get_isMatrixRowMajor);
  1136. WriteIfValue(pSymbol.p, o, 0, L"builtInKind", &IDiaSymbol::get_builtInKind);
  1137. WriteIfValue(pSymbol.p, o, 0, L"textureSlot", &IDiaSymbol::get_textureSlot);
  1138. WriteIfValue(pSymbol.p, o, 0, L"memorySpaceKind", &IDiaSymbol::get_memorySpaceKind);
  1139. WriteIfValue(pSymbol.p, o, 0, L"isHLSLData", &IDiaSymbol::get_isHLSLData);
  1140. }
  1141. CComPtr<IDiaSourceFile> pSourceFile;
  1142. if (SUCCEEDED(item.QueryInterface(&pSourceFile))) {
  1143. WriteIfValue(pSourceFile.p, o, 0, L"uniqueId", &IDiaSourceFile::get_uniqueId);
  1144. WriteIfValue(pSourceFile.p, o, L"fileName", &IDiaSourceFile::get_fileName);
  1145. }
  1146. CComPtr<IDiaLineNumber> pLineNumber;
  1147. if (SUCCEEDED(item.QueryInterface(&pLineNumber))) {
  1148. WriteIfValue(pLineNumber.p, o, L"compiland", &IDiaLineNumber::get_compiland);
  1149. //WriteIfValue(pLineNumber.p, o, L"sourceFile", &IDiaLineNumber::get_sourceFile);
  1150. WriteIfValue(pLineNumber.p, o, 0, L"lineNumber", &IDiaLineNumber::get_lineNumber);
  1151. WriteIfValue(pLineNumber.p, o, 0, L"lineNumberEnd", &IDiaLineNumber::get_lineNumberEnd);
  1152. WriteIfValue(pLineNumber.p, o, 0, L"columnNumber", &IDiaLineNumber::get_columnNumber);
  1153. WriteIfValue(pLineNumber.p, o, 0, L"columnNumberEnd", &IDiaLineNumber::get_columnNumberEnd);
  1154. WriteIfValue(pLineNumber.p, o, 0, L"addressSection", &IDiaLineNumber::get_addressSection);
  1155. WriteIfValue(pLineNumber.p, o, 0, L"addressOffset", &IDiaLineNumber::get_addressOffset);
  1156. WriteIfValue(pLineNumber.p, o, 0, L"relativeVirtualAddress", &IDiaLineNumber::get_relativeVirtualAddress);
  1157. WriteIfValue(pLineNumber.p, o, 0, L"virtualAddress", &IDiaLineNumber::get_virtualAddress);
  1158. WriteIfValue(pLineNumber.p, o, 0, L"length", &IDiaLineNumber::get_length);
  1159. WriteIfValue(pLineNumber.p, o, 0, L"sourceFileId", &IDiaLineNumber::get_sourceFileId);
  1160. WriteIfValue(pLineNumber.p, o, 0, L"statement", &IDiaLineNumber::get_statement);
  1161. WriteIfValue(pLineNumber.p, o, 0, L"compilandId", &IDiaLineNumber::get_compilandId);
  1162. }
  1163. CComPtr<IDiaSectionContrib> pSectionContrib;
  1164. if (SUCCEEDED(item.QueryInterface(&pSectionContrib))) {
  1165. WriteIfValue(pSectionContrib.p, o, L"compiland", &IDiaSectionContrib::get_compiland);
  1166. WriteIfValue(pSectionContrib.p, o, 0, L"addressSection", &IDiaSectionContrib::get_addressSection);
  1167. WriteIfValue(pSectionContrib.p, o, 0, L"addressOffset", &IDiaSectionContrib::get_addressOffset);
  1168. WriteIfValue(pSectionContrib.p, o, 0, L"relativeVirtualAddress", &IDiaSectionContrib::get_relativeVirtualAddress);
  1169. WriteIfValue(pSectionContrib.p, o, 0, L"virtualAddress", &IDiaSectionContrib::get_virtualAddress);
  1170. WriteIfValue(pSectionContrib.p, o, 0, L"length", &IDiaSectionContrib::get_length);
  1171. WriteIfValue(pSectionContrib.p, o, 0, L"notPaged", &IDiaSectionContrib::get_notPaged);
  1172. WriteIfValue(pSectionContrib.p, o, 0, L"code", &IDiaSectionContrib::get_code);
  1173. WriteIfValue(pSectionContrib.p, o, 0, L"initializedData", &IDiaSectionContrib::get_initializedData);
  1174. WriteIfValue(pSectionContrib.p, o, 0, L"uninitializedData", &IDiaSectionContrib::get_uninitializedData);
  1175. WriteIfValue(pSectionContrib.p, o, 0, L"remove", &IDiaSectionContrib::get_remove);
  1176. WriteIfValue(pSectionContrib.p, o, 0, L"comdat", &IDiaSectionContrib::get_comdat);
  1177. WriteIfValue(pSectionContrib.p, o, 0, L"discardable", &IDiaSectionContrib::get_discardable);
  1178. WriteIfValue(pSectionContrib.p, o, 0, L"notCached", &IDiaSectionContrib::get_notCached);
  1179. WriteIfValue(pSectionContrib.p, o, 0, L"share", &IDiaSectionContrib::get_share);
  1180. WriteIfValue(pSectionContrib.p, o, 0, L"execute", &IDiaSectionContrib::get_execute);
  1181. WriteIfValue(pSectionContrib.p, o, 0, L"read", &IDiaSectionContrib::get_read);
  1182. WriteIfValue(pSectionContrib.p, o, 0, L"write", &IDiaSectionContrib::get_write);
  1183. WriteIfValue(pSectionContrib.p, o, 0, L"dataCrc", &IDiaSectionContrib::get_dataCrc);
  1184. WriteIfValue(pSectionContrib.p, o, 0, L"relocationsCrc", &IDiaSectionContrib::get_relocationsCrc);
  1185. WriteIfValue(pSectionContrib.p, o, 0, L"compilandId", &IDiaSectionContrib::get_compilandId);
  1186. }
  1187. CComPtr<IDiaSegment> pSegment;
  1188. if (SUCCEEDED(item.QueryInterface(&pSegment))) {
  1189. WriteIfValue(pSegment.p, o, 0, L"frame", &IDiaSegment::get_frame);
  1190. WriteIfValue(pSegment.p, o, 0, L"offset", &IDiaSegment::get_offset);
  1191. WriteIfValue(pSegment.p, o, 0, L"length", &IDiaSegment::get_length);
  1192. WriteIfValue(pSegment.p, o, 0, L"read", &IDiaSegment::get_read);
  1193. WriteIfValue(pSegment.p, o, 0, L"write", &IDiaSegment::get_write);
  1194. WriteIfValue(pSegment.p, o, 0, L"execute", &IDiaSegment::get_execute);
  1195. WriteIfValue(pSegment.p, o, 0, L"addressSection", &IDiaSegment::get_addressSection);
  1196. WriteIfValue(pSegment.p, o, 0, L"relativeVirtualAddress", &IDiaSegment::get_relativeVirtualAddress);
  1197. WriteIfValue(pSegment.p, o, 0, L"virtualAddress", &IDiaSegment::get_virtualAddress);
  1198. }
  1199. CComPtr<IDiaInjectedSource> pInjectedSource;
  1200. if (SUCCEEDED(item.QueryInterface(&pInjectedSource))) {
  1201. WriteIfValue(pInjectedSource.p, o, 0, L"crc", &IDiaInjectedSource::get_crc);
  1202. WriteIfValue(pInjectedSource.p, o, 0, L"length", &IDiaInjectedSource::get_length);
  1203. WriteIfValue(pInjectedSource.p, o, L"filename", &IDiaInjectedSource::get_filename);
  1204. WriteIfValue(pInjectedSource.p, o, L"objectFilename", &IDiaInjectedSource::get_objectFilename);
  1205. WriteIfValue(pInjectedSource.p, o, L"virtualFilename", &IDiaInjectedSource::get_virtualFilename);
  1206. WriteIfValue(pInjectedSource.p, o, 0, L"sourceCompression", &IDiaInjectedSource::get_sourceCompression);
  1207. // get_source is also available
  1208. }
  1209. CComPtr<IDiaFrameData> pFrameData;
  1210. if (SUCCEEDED(item.QueryInterface(&pFrameData))) {
  1211. }
  1212. o << std::endl;
  1213. }
  1214. }
  1215. return o.str();
  1216. }
  1217. struct LineNumber { DWORD line; DWORD rva; };
  1218. std::vector<LineNumber> ReadLineNumbers(IDiaEnumLineNumbers *pEnumLineNumbers) {
  1219. std::vector<LineNumber> lines;
  1220. CComPtr<IDiaLineNumber> pLineNumber;
  1221. DWORD lineCount;
  1222. while (SUCCEEDED(pEnumLineNumbers->Next(1, &pLineNumber, &lineCount)) && lineCount == 1)
  1223. {
  1224. DWORD line;
  1225. DWORD rva;
  1226. VERIFY_SUCCEEDED(pLineNumber->get_lineNumber(&line));
  1227. VERIFY_SUCCEEDED(pLineNumber->get_relativeVirtualAddress(&rva));
  1228. lines.push_back({ line, rva });
  1229. pLineNumber.Release();
  1230. }
  1231. return lines;
  1232. }
  1233. std::string GetOption(std::string &cmd, char *opt) {
  1234. std::string option = cmd.substr(cmd.find(opt));
  1235. option = option.substr(option.find_first_of(' '));
  1236. option = option.substr(option.find_first_not_of(' '));
  1237. return option.substr(0, option.find_first_of(' '));
  1238. }
  1239. void CodeGenTest(LPCWSTR name) {
  1240. CComPtr<IDxcCompiler> pCompiler;
  1241. CComPtr<IDxcOperationResult> pResult;
  1242. CComPtr<IDxcBlobEncoding> pSource;
  1243. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1244. CreateBlobFromFile(name, &pSource);
  1245. std::string cmdLine = GetFirstLine(name);
  1246. llvm::StringRef argsRef = cmdLine;
  1247. llvm::SmallVector<llvm::StringRef, 8> splitArgs;
  1248. argsRef.split(splitArgs, " ");
  1249. hlsl::options::MainArgs argStrings(splitArgs);
  1250. std::string errorString;
  1251. llvm::raw_string_ostream errorStream(errorString);
  1252. hlsl::options::DxcOpts opts;
  1253. IFT(ReadDxcOpts(hlsl::options::getHlslOptTable(), /*flagsToInclude*/ 0,
  1254. argStrings, opts, errorStream));
  1255. std::wstring entry =
  1256. Unicode::UTF8ToUTF16StringOrThrow(opts.EntryPoint.str().c_str());
  1257. std::wstring profile =
  1258. Unicode::UTF8ToUTF16StringOrThrow(opts.TargetProfile.str().c_str());
  1259. VERIFY_SUCCEEDED(pCompiler->Compile(
  1260. pSource, name, entry.c_str(), profile.c_str(), nullptr, 0,
  1261. opts.Defines.data(), opts.Defines.size(), nullptr, &pResult));
  1262. HRESULT result;
  1263. VERIFY_SUCCEEDED(pResult->GetStatus(&result));
  1264. if (FAILED(result)) {
  1265. CComPtr<IDxcBlobEncoding> pErr;
  1266. IFT(pResult->GetErrorBuffer(&pErr));
  1267. std::string errString(BlobToUtf8(pErr));
  1268. CA2W errStringW(errString.c_str(), CP_UTF8);
  1269. WEX::Logging::Log::Comment(L"Failed to compile - errors follow");
  1270. WEX::Logging::Log::Comment(errStringW);
  1271. }
  1272. VERIFY_SUCCEEDED(result);
  1273. CComPtr<IDxcBlob> pProgram;
  1274. VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
  1275. if (opts.IsRootSignatureProfile())
  1276. return;
  1277. CComPtr<IDxcBlobEncoding> pDisassembleBlob;
  1278. VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembleBlob));
  1279. std::string disassembleString(BlobToUtf8(pDisassembleBlob));
  1280. VERIFY_ARE_NOT_EQUAL(0, disassembleString.size());
  1281. }
  1282. void CodeGenTestCheckFullPath(LPCWSTR fullPath) {
  1283. FileRunTestResult t = FileRunTestResult::RunFromFileCommands(fullPath);
  1284. if (t.RunResult != 0) {
  1285. CA2W commentWide(t.ErrorMessage.c_str(), CP_UTF8);
  1286. WEX::Logging::Log::Comment(commentWide);
  1287. WEX::Logging::Log::Error(L"Run result is not zero");
  1288. }
  1289. }
  1290. void CodeGenTestCheck(LPCWSTR name) {
  1291. std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
  1292. CodeGenTestCheckFullPath(fullPath.c_str());
  1293. }
  1294. void CodeGenTestCheckBatch(LPCWSTR name, unsigned option) {
  1295. WEX::Logging::Log::StartGroup(name);
  1296. CodeGenTestCheckFullPath(name);
  1297. WEX::Logging::Log::EndGroup(name);
  1298. }
  1299. std::string VerifyCompileFailed(LPCSTR pText, LPWSTR pTargetProfile, LPCSTR pErrorMsg) {
  1300. return VerifyCompileFailed(pText, pTargetProfile, pErrorMsg, L"main");
  1301. }
  1302. std::string VerifyCompileFailed(LPCSTR pText, LPWSTR pTargetProfile, LPCSTR pErrorMsg, LPCWSTR pEntryPoint) {
  1303. CComPtr<IDxcCompiler> pCompiler;
  1304. CComPtr<IDxcOperationResult> pResult;
  1305. CComPtr<IDxcBlobEncoding> pSource;
  1306. CComPtr<IDxcBlobEncoding> pErrors;
  1307. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1308. CreateBlobFromText(pText, &pSource);
  1309. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", pEntryPoint,
  1310. pTargetProfile, nullptr, 0, nullptr, 0, nullptr, &pResult));
  1311. HRESULT status;
  1312. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  1313. VERIFY_FAILED(status);
  1314. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
  1315. if (pErrorMsg && *pErrorMsg) {
  1316. CheckOperationResultMsgs(pResult, &pErrorMsg, 1, false, false);
  1317. }
  1318. return BlobToUtf8(pErrors);
  1319. }
  1320. void VerifyOperationSucceeded(IDxcOperationResult *pResult) {
  1321. HRESULT result;
  1322. VERIFY_SUCCEEDED(pResult->GetStatus(&result));
  1323. if (FAILED(result)) {
  1324. CComPtr<IDxcBlobEncoding> pErrors;
  1325. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
  1326. CA2W errorsWide(BlobToUtf8(pErrors).c_str(), CP_UTF8);
  1327. WEX::Logging::Log::Comment(errorsWide);
  1328. }
  1329. VERIFY_SUCCEEDED(result);
  1330. }
  1331. std::string VerifyOperationFailed(IDxcOperationResult *pResult) {
  1332. HRESULT result;
  1333. VERIFY_SUCCEEDED(pResult->GetStatus(&result));
  1334. VERIFY_FAILED(result);
  1335. CComPtr<IDxcBlobEncoding> pErrors;
  1336. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
  1337. return BlobToUtf8(pErrors);
  1338. }
  1339. HRESULT CreateDiaSourceForCompile(const char *hlsl, IDiaDataSource **ppDiaSource)
  1340. {
  1341. if (!ppDiaSource)
  1342. return E_POINTER;
  1343. CComPtr<IDxcCompiler> pCompiler;
  1344. CComPtr<IDxcOperationResult> pResult;
  1345. CComPtr<IDxcBlobEncoding> pSource;
  1346. CComPtr<IDxcBlob> pProgram;
  1347. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1348. CreateBlobFromText(hlsl, &pSource);
  1349. LPCWSTR args[] = { L"/Zi" };
  1350. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1351. L"ps_6_0", args, _countof(args), nullptr, 0, nullptr, &pResult));
  1352. VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
  1353. // Disassemble the compiled (stripped) program.
  1354. {
  1355. CComPtr<IDxcBlobEncoding> pDisassembly;
  1356. VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembly));
  1357. std::string disText = BlobToUtf8(pDisassembly);
  1358. CA2W disTextW(disText.c_str(), CP_UTF8);
  1359. //WEX::Logging::Log::Comment(disTextW);
  1360. }
  1361. // CONSIDER: have the dia data source look for the part if passed a whole container.
  1362. CComPtr<IDiaDataSource> pDiaSource;
  1363. CComPtr<IStream> pProgramStream;
  1364. CComPtr<IDxcLibrary> pLib;
  1365. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLib));
  1366. const hlsl::DxilContainerHeader *pContainer = hlsl::IsDxilContainerLike(
  1367. pProgram->GetBufferPointer(), pProgram->GetBufferSize());
  1368. VERIFY_IS_NOT_NULL(pContainer);
  1369. hlsl::DxilPartIterator partIter =
  1370. std::find_if(hlsl::begin(pContainer), hlsl::end(pContainer),
  1371. hlsl::DxilPartIsType(hlsl::DFCC_ShaderDebugInfoDXIL));
  1372. const hlsl::DxilProgramHeader *pProgramHeader =
  1373. (const hlsl::DxilProgramHeader *)hlsl::GetDxilPartData(*partIter);
  1374. uint32_t bitcodeLength;
  1375. const char *pBitcode;
  1376. CComPtr<IDxcBlob> pProgramPdb;
  1377. hlsl::GetDxilProgramBitcode(pProgramHeader, &pBitcode, &bitcodeLength);
  1378. VERIFY_SUCCEEDED(pLib->CreateBlobFromBlob(
  1379. pProgram, pBitcode - (char *)pProgram->GetBufferPointer(), bitcodeLength,
  1380. &pProgramPdb));
  1381. // Disassemble the program with debug information.
  1382. {
  1383. CComPtr<IDxcBlobEncoding> pDbgDisassembly;
  1384. VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgramPdb, &pDbgDisassembly));
  1385. std::string disText = BlobToUtf8(pDbgDisassembly);
  1386. CA2W disTextW(disText.c_str(), CP_UTF8);
  1387. //WEX::Logging::Log::Comment(disTextW);
  1388. }
  1389. // Create a short text dump of debug information.
  1390. VERIFY_SUCCEEDED(pLib->CreateStreamFromBlobReadOnly(pProgramPdb, &pProgramStream));
  1391. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcDiaDataSource, &pDiaSource));
  1392. VERIFY_SUCCEEDED(pDiaSource->loadDataFromIStream(pProgramStream));
  1393. *ppDiaSource = pDiaSource.Detach();
  1394. return S_OK;
  1395. }
  1396. };
  1397. // Useful for debugging.
  1398. #if SUPPORT_FXC_PDB
  1399. #include <d3dcompiler.h>
  1400. #pragma comment(lib, "d3dcompiler.lib")
  1401. HRESULT GetBlobPdb(IDxcBlob *pBlob, IDxcBlob **ppDebugInfo) {
  1402. return D3DGetBlobPart(pBlob->GetBufferPointer(), pBlob->GetBufferSize(),
  1403. D3D_BLOB_PDB, 0, (ID3DBlob **)ppDebugInfo);
  1404. }
  1405. std::string FourCCStr(uint32_t val) {
  1406. std::stringstream o;
  1407. char c[5];
  1408. c[0] = val & 0xFF;
  1409. c[1] = (val & 0xFF00) >> 8;
  1410. c[2] = (val & 0xFF0000) >> 16;
  1411. c[3] = (val & 0xFF000000) >> 24;
  1412. c[4] = '\0';
  1413. o << c << " (" << std::hex << val << std::dec << ")";
  1414. return o.str();
  1415. }
  1416. std::string DumpParts(IDxcBlob *pBlob) {
  1417. std::stringstream o;
  1418. hlsl::DxilContainerHeader *pContainer = (hlsl::DxilContainerHeader *)pBlob->GetBufferPointer();
  1419. o << "Container:" << std::endl
  1420. << " Size: " << pContainer->ContainerSizeInBytes << std::endl
  1421. << " FourCC: " << FourCCStr(pContainer->HeaderFourCC) << std::endl
  1422. << " Part count: " << pContainer->PartCount << std::endl;
  1423. for (uint32_t i = 0; i < pContainer->PartCount; ++i) {
  1424. hlsl::DxilPartHeader *pPart = hlsl::GetDxilContainerPart(pContainer, i);
  1425. o << "Part " << i << std::endl
  1426. << " FourCC: " << FourCCStr(pPart->PartFourCC) << std::endl
  1427. << " Size: " << pPart->PartSize << std::endl;
  1428. }
  1429. return o.str();
  1430. }
  1431. HRESULT CreateDiaSourceFromDxbcBlob(IDxcLibrary *pLib, IDxcBlob *pDxbcBlob,
  1432. IDiaDataSource **ppDiaSource) {
  1433. HRESULT hr = S_OK;
  1434. CComPtr<IDxcBlob> pdbBlob;
  1435. CComPtr<IStream> pPdbStream;
  1436. CComPtr<IDiaDataSource> pDiaSource;
  1437. IFR(GetBlobPdb(pDxbcBlob, &pdbBlob));
  1438. IFR(pLib->CreateStreamFromBlobReadOnly(pdbBlob, &pPdbStream));
  1439. IFR(CoCreateInstance(CLSID_DiaSource, NULL, CLSCTX_INPROC_SERVER,
  1440. __uuidof(IDiaDataSource), (void **)&pDiaSource));
  1441. IFR(pDiaSource->loadDataFromIStream(pPdbStream));
  1442. *ppDiaSource = pDiaSource.Detach();
  1443. return hr;
  1444. }
  1445. #endif
  1446. bool CompilerTest::InitSupport() {
  1447. if (!m_dllSupport.IsEnabled()) {
  1448. VERIFY_SUCCEEDED(m_dllSupport.Initialize());
  1449. m_ver.Initialize(m_dllSupport);
  1450. }
  1451. return true;
  1452. }
  1453. TEST_F(CompilerTest, CompileWhenDebugThenDIPresent) {
  1454. // BUG: the first test written was of this form:
  1455. // float4 local = 0; return local;
  1456. //
  1457. // However we get no numbers because of the _wrapper form
  1458. // that exports the zero initialization from main into
  1459. // a global can't be attributed to any particular location
  1460. // within main, and everything in main is eventually folded away.
  1461. //
  1462. // Making the function do a bit more work by calling an intrinsic
  1463. // helps this case.
  1464. CComPtr<IDiaDataSource> pDiaSource;
  1465. VERIFY_SUCCEEDED(CreateDiaSourceForCompile(
  1466. "float4 main(float4 pos : SV_Position) : SV_Target {\r\n"
  1467. " float4 local = abs(pos);\r\n"
  1468. " return local;\r\n"
  1469. "}", &pDiaSource));
  1470. std::wstring diaDump = GetDebugInfoAsText(pDiaSource).c_str();
  1471. //WEX::Logging::Log::Comment(GetDebugInfoAsText(pDiaSource).c_str());
  1472. // Very basic tests - we have basic symbols, line numbers, and files with sources.
  1473. VERIFY_IS_NOT_NULL(wcsstr(diaDump.c_str(), L"symIndexId: 5, CompilandEnv, name: hlslTarget, value: ps_6_0"));
  1474. VERIFY_IS_NOT_NULL(wcsstr(diaDump.c_str(), L"lineNumber: 2"));
  1475. VERIFY_IS_NOT_NULL(wcsstr(diaDump.c_str(), L"length: 99, filename: source.hlsl"));
  1476. #if SUPPORT_FXC_PDB
  1477. // Now, fake it by loading from a .pdb!
  1478. VERIFY_SUCCEEDED(CoInitializeEx(0, COINITBASE_MULTITHREADED));
  1479. const wchar_t path[] = L"path-to-fxc-blob.bin";
  1480. pDiaSource.Release();
  1481. pProgramStream.Release();
  1482. CComPtr<IDxcBlobEncoding> fxcBlob;
  1483. CComPtr<IDxcBlob> pdbBlob;
  1484. VERIFY_SUCCEEDED(pLib->CreateBlobFromFile(path, nullptr, &fxcBlob));
  1485. std::string s = DumpParts(fxcBlob);
  1486. CA2W sW(s.c_str(), CP_UTF8);
  1487. WEX::Logging::Log::Comment(sW);
  1488. VERIFY_SUCCEEDED(CreateDiaSourceFromDxbcBlob(pLib, fxcBlob, &pDiaSource));
  1489. WEX::Logging::Log::Comment(GetDebugInfoAsText(pDiaSource).c_str());
  1490. #endif
  1491. }
  1492. TEST_F(CompilerTest, CompileDebugLines) {
  1493. CComPtr<IDiaDataSource> pDiaSource;
  1494. VERIFY_SUCCEEDED(CreateDiaSourceForCompile(
  1495. "float main(float pos : A) : SV_Target {\r\n"
  1496. " float x = abs(pos);\r\n"
  1497. " float y = sin(pos);\r\n"
  1498. " float z = x + y;\r\n"
  1499. " return z;\r\n"
  1500. "}", &pDiaSource));
  1501. const int numExpectedRVAs = 6;
  1502. auto verifyLines = [=](const std::vector<LineNumber> lines) {
  1503. VERIFY_ARE_EQUAL(lines.size(), numExpectedRVAs);
  1504. // 0: loadInput
  1505. VERIFY_ARE_EQUAL(lines[0].rva, 0);
  1506. VERIFY_ARE_EQUAL(lines[0].line, 1);
  1507. // 1: abs
  1508. VERIFY_ARE_EQUAL(lines[1].rva, 1);
  1509. VERIFY_ARE_EQUAL(lines[1].line, 2);
  1510. // 2: sin
  1511. VERIFY_ARE_EQUAL(lines[2].rva, 2);
  1512. VERIFY_ARE_EQUAL(lines[2].line, 3);
  1513. // 3: add
  1514. VERIFY_ARE_EQUAL(lines[3].rva, 3);
  1515. VERIFY_ARE_EQUAL(lines[3].line, 4);
  1516. // 4: storeOutput
  1517. VERIFY_ARE_EQUAL(lines[4].rva, 4);
  1518. VERIFY_ARE_EQUAL(lines[4].line, 5);
  1519. // 5: ret
  1520. VERIFY_ARE_EQUAL(lines[5].rva, 5);
  1521. VERIFY_ARE_EQUAL(lines[5].line, 5);
  1522. };
  1523. CComPtr<IDiaSession> pSession;
  1524. CComPtr<IDiaEnumLineNumbers> pEnumLineNumbers;
  1525. // Verify lines are ok when getting one RVA at a time.
  1526. std::vector<LineNumber> linesOneByOne;
  1527. VERIFY_SUCCEEDED(pDiaSource->openSession(&pSession));
  1528. for (int i = 0; i < numExpectedRVAs; ++i) {
  1529. VERIFY_SUCCEEDED(pSession->findLinesByRVA(i, 1, &pEnumLineNumbers));
  1530. std::vector<LineNumber> lines = ReadLineNumbers(pEnumLineNumbers);
  1531. std::copy(lines.begin(), lines.end(), std::back_inserter(linesOneByOne));
  1532. pEnumLineNumbers.Release();
  1533. }
  1534. verifyLines(linesOneByOne);
  1535. // Verify lines are ok when getting all RVAs at once.
  1536. std::vector<LineNumber> linesAllAtOnce;
  1537. pEnumLineNumbers.Release();
  1538. VERIFY_SUCCEEDED(pSession->findLinesByRVA(0, numExpectedRVAs, &pEnumLineNumbers));
  1539. linesAllAtOnce = ReadLineNumbers(pEnumLineNumbers);
  1540. verifyLines(linesAllAtOnce);
  1541. // Verify lines are ok when getting all lines through enum tables.
  1542. std::vector<LineNumber> linesFromTable;
  1543. pEnumLineNumbers.Release();
  1544. CComPtr<IDiaEnumTables> pTables;
  1545. CComPtr<IDiaTable> pTable;
  1546. VERIFY_SUCCEEDED(pSession->getEnumTables(&pTables));
  1547. DWORD celt;
  1548. while (SUCCEEDED(pTables->Next(1, &pTable, &celt)) && celt == 1)
  1549. {
  1550. if (SUCCEEDED(pTable->QueryInterface(&pEnumLineNumbers))) {
  1551. linesFromTable = ReadLineNumbers(pEnumLineNumbers);
  1552. break;
  1553. }
  1554. pTable.Release();
  1555. }
  1556. verifyLines(linesFromTable);
  1557. // Verify lines are ok when getting by address.
  1558. std::vector<LineNumber> linesByAddr;
  1559. pEnumLineNumbers.Release();
  1560. VERIFY_SUCCEEDED(pSession->findLinesByAddr(0, 0, numExpectedRVAs, &pEnumLineNumbers));
  1561. linesByAddr = ReadLineNumbers(pEnumLineNumbers);
  1562. verifyLines(linesByAddr);
  1563. }
  1564. TEST_F(CompilerTest, CompileWhenDefinesThenApplied) {
  1565. CComPtr<IDxcCompiler> pCompiler;
  1566. CComPtr<IDxcOperationResult> pResult;
  1567. CComPtr<IDxcBlobEncoding> pSource;
  1568. DxcDefine defines[] = {{L"F4", L"float4"}};
  1569. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1570. CreateBlobFromText("F4 main() : SV_Target { return 0; }", &pSource);
  1571. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1572. L"ps_6_0", nullptr, 0, defines,
  1573. _countof(defines), nullptr, &pResult));
  1574. }
  1575. TEST_F(CompilerTest, CompileWhenDefinesManyThenApplied) {
  1576. CComPtr<IDxcCompiler> pCompiler;
  1577. CComPtr<IDxcOperationResult> pResult;
  1578. CComPtr<IDxcBlobEncoding> pSource;
  1579. LPCWSTR args[] = {L"/DVAL1=1", L"/DVAL2=2", L"/DVAL3=3", L"/DVAL4=2",
  1580. L"/DVAL5=4", L"/DNVAL1", L"/DNVAL2", L"/DNVAL3",
  1581. L"/DNVAL4", L"/DNVAL5", L"/DCVAL1=1", L"/DCVAL2=2",
  1582. L"/DCVAL3=3", L"/DCVAL4=2", L"/DCVAL5=4", L"/DCVALNONE="};
  1583. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1584. CreateBlobFromText("float4 main() : SV_Target {\r\n"
  1585. "#ifndef VAL1\r\n"
  1586. "#error VAL1 not defined\r\n"
  1587. "#endif\r\n"
  1588. "#ifndef NVAL5\r\n"
  1589. "#error NVAL5 not defined\r\n"
  1590. "#endif\r\n"
  1591. "#ifndef CVALNONE\r\n"
  1592. "#error CVALNONE not defined\r\n"
  1593. "#endif\r\n"
  1594. "return 0; }",
  1595. &pSource);
  1596. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1597. L"ps_6_0", args, _countof(args), nullptr,
  1598. 0, nullptr, &pResult));
  1599. HRESULT compileStatus;
  1600. VERIFY_SUCCEEDED(pResult->GetStatus(&compileStatus));
  1601. if (FAILED(compileStatus)) {
  1602. CComPtr<IDxcBlobEncoding> pErrors;
  1603. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
  1604. OutputDebugStringA((LPCSTR)pErrors->GetBufferPointer());
  1605. }
  1606. VERIFY_SUCCEEDED(compileStatus);
  1607. }
  1608. TEST_F(CompilerTest, CompileWhenEmptyThenFails) {
  1609. CComPtr<IDxcCompiler> pCompiler;
  1610. CComPtr<IDxcOperationResult> pResult;
  1611. CComPtr<IDxcBlobEncoding> pSource;
  1612. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1613. CreateBlobFromText("float4 main() : SV_Target { return 0; }", &pSource);
  1614. // null source
  1615. VERIFY_FAILED(pCompiler->Compile(nullptr, L"source.hlsl", nullptr, nullptr,
  1616. nullptr, 0, nullptr, 0, nullptr, &pResult));
  1617. // null result
  1618. VERIFY_FAILED(pCompiler->Compile(pSource, L"source.hlsl", nullptr, nullptr,
  1619. nullptr, 0, nullptr, 0, nullptr, nullptr));
  1620. }
  1621. TEST_F(CompilerTest, CompileWhenIncorrectThenFails) {
  1622. CComPtr<IDxcCompiler> pCompiler;
  1623. CComPtr<IDxcOperationResult> pResult;
  1624. CComPtr<IDxcBlobEncoding> pSource;
  1625. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1626. CreateBlobFromText("float4_undefined main() : SV_Target { return 0; }",
  1627. &pSource);
  1628. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main", L"ps_6_0",
  1629. nullptr, 0, nullptr, 0, nullptr,
  1630. &pResult));
  1631. HRESULT result;
  1632. VERIFY_SUCCEEDED(pResult->GetStatus(&result));
  1633. VERIFY_FAILED(result);
  1634. CComPtr<IDxcBlobEncoding> pErrorBuffer;
  1635. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrorBuffer));
  1636. std::string errorString(BlobToUtf8(pErrorBuffer));
  1637. VERIFY_ARE_NOT_EQUAL(0, errorString.size());
  1638. // Useful for examining actual error message:
  1639. // CA2W errorStringW(errorString.c_str(), CP_UTF8);
  1640. // WEX::Logging::Log::Comment(errorStringW.m_psz);
  1641. }
  1642. TEST_F(CompilerTest, CompileWhenWorksThenDisassembleWorks) {
  1643. CComPtr<IDxcCompiler> pCompiler;
  1644. CComPtr<IDxcOperationResult> pResult;
  1645. CComPtr<IDxcBlobEncoding> pSource;
  1646. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1647. CreateBlobFromText("float4 main() : SV_Target { return 0; }", &pSource);
  1648. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1649. L"ps_6_0", nullptr, 0, nullptr, 0,
  1650. nullptr, &pResult));
  1651. HRESULT result;
  1652. VERIFY_SUCCEEDED(pResult->GetStatus(&result));
  1653. VERIFY_SUCCEEDED(result);
  1654. CComPtr<IDxcBlob> pProgram;
  1655. VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
  1656. CComPtr<IDxcBlobEncoding> pDisassembleBlob;
  1657. VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembleBlob));
  1658. std::string disassembleString(BlobToUtf8(pDisassembleBlob));
  1659. VERIFY_ARE_NOT_EQUAL(0, disassembleString.size());
  1660. // Useful for examining disassembly:
  1661. // CA2W disassembleStringW(disassembleString.c_str(), CP_UTF8);
  1662. // WEX::Logging::Log::Comment(disassembleStringW.m_psz);
  1663. }
  1664. TEST_F(CompilerTest, CompileWhenDebugWorksThenStripDebug) {
  1665. CComPtr<IDxcCompiler> pCompiler;
  1666. CComPtr<IDxcOperationResult> pResult;
  1667. CComPtr<IDxcBlobEncoding> pSource;
  1668. CComPtr<IDxcBlob> pProgram;
  1669. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1670. CreateBlobFromText("float4 main(float4 pos : SV_Position) : SV_Target {\r\n"
  1671. " float4 local = abs(pos);\r\n"
  1672. " return local;\r\n"
  1673. "}",
  1674. &pSource);
  1675. LPCWSTR args[] = {L"/Zi"};
  1676. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1677. L"ps_6_0", args, _countof(args), nullptr,
  1678. 0, nullptr, &pResult));
  1679. VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
  1680. // Check if it contains debug blob
  1681. hlsl::DxilContainerHeader *pHeader =
  1682. (hlsl::DxilContainerHeader *)(pProgram->GetBufferPointer());
  1683. hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
  1684. pHeader, hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL);
  1685. VERIFY_IS_NOT_NULL(pPartHeader);
  1686. // Check debug info part does not exist after strip debug info
  1687. CComPtr<IDxcBlob> pNewProgram;
  1688. CComPtr<IDxcContainerBuilder> pBuilder;
  1689. VERIFY_SUCCEEDED(CreateContainerBuilder(&pBuilder));
  1690. VERIFY_SUCCEEDED(pBuilder->Load(pProgram));
  1691. VERIFY_SUCCEEDED(pBuilder->RemovePart(hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL));
  1692. pResult.Release();
  1693. VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
  1694. VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
  1695. pHeader = (hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
  1696. pPartHeader = hlsl::GetDxilPartByType(
  1697. pHeader, hlsl::DxilFourCC::DFCC_ShaderDebugInfoDXIL);
  1698. VERIFY_IS_NULL(pPartHeader);
  1699. }
  1700. TEST_F(CompilerTest, CompileWhenWorksThenAddRemovePrivate) {
  1701. CComPtr<IDxcCompiler> pCompiler;
  1702. CComPtr<IDxcOperationResult> pResult;
  1703. CComPtr<IDxcBlobEncoding> pSource;
  1704. CComPtr<IDxcBlob> pProgram;
  1705. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1706. CreateBlobFromText("float4 main() : SV_Target {\r\n"
  1707. " return 0;\r\n"
  1708. "}",
  1709. &pSource);
  1710. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1711. L"ps_6_0", nullptr, 0, nullptr, 0,
  1712. nullptr, &pResult));
  1713. VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
  1714. // Append private data blob
  1715. CComPtr<IDxcContainerBuilder> pBuilder;
  1716. VERIFY_SUCCEEDED(CreateContainerBuilder(&pBuilder));
  1717. std::string privateTxt("private data");
  1718. CComPtr<IDxcBlobEncoding> pPrivate;
  1719. CreateBlobFromText(privateTxt.c_str(), &pPrivate);
  1720. VERIFY_SUCCEEDED(pBuilder->Load(pProgram));
  1721. VERIFY_SUCCEEDED(pBuilder->AddPart(hlsl::DxilFourCC::DFCC_PrivateData, pPrivate));
  1722. pResult.Release();
  1723. VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
  1724. CComPtr<IDxcBlob> pNewProgram;
  1725. VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
  1726. hlsl::DxilContainerHeader *pContainerHeader =
  1727. (hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
  1728. hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
  1729. pContainerHeader, hlsl::DxilFourCC::DFCC_PrivateData);
  1730. VERIFY_IS_NOT_NULL(pPartHeader);
  1731. // compare data
  1732. std::string privatePart((const char *)(pPartHeader + 1), privateTxt.size());
  1733. VERIFY_IS_TRUE(strcmp(privatePart.c_str(), privateTxt.c_str()) == 0);
  1734. // Remove private data blob
  1735. pBuilder.Release();
  1736. VERIFY_SUCCEEDED(CreateContainerBuilder(&pBuilder));
  1737. VERIFY_SUCCEEDED(pBuilder->Load(pNewProgram));
  1738. VERIFY_SUCCEEDED(pBuilder->RemovePart(hlsl::DxilFourCC::DFCC_PrivateData));
  1739. pResult.Release();
  1740. VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
  1741. pNewProgram.Release();
  1742. VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
  1743. pContainerHeader =
  1744. (hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
  1745. pPartHeader = hlsl::GetDxilPartByType(
  1746. pContainerHeader, hlsl::DxilFourCC::DFCC_PrivateData);
  1747. VERIFY_IS_NULL(pPartHeader);
  1748. }
  1749. TEST_F(CompilerTest, CompileWithRootSignatureThenStripRootSignature) {
  1750. CComPtr<IDxcCompiler> pCompiler;
  1751. CComPtr<IDxcOperationResult> pResult;
  1752. CComPtr<IDxcBlobEncoding> pSource;
  1753. CComPtr<IDxcBlob> pProgram;
  1754. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1755. CreateBlobFromText("[RootSignature(\"\")] \r\n"
  1756. "float4 main(float a : A) : SV_Target {\r\n"
  1757. " return a;\r\n"
  1758. "}",
  1759. &pSource);
  1760. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1761. L"ps_6_0", nullptr, 0, nullptr,
  1762. 0, nullptr, &pResult));
  1763. VERIFY_IS_NOT_NULL(pResult);
  1764. HRESULT status;
  1765. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  1766. VERIFY_SUCCEEDED(status);
  1767. VERIFY_SUCCEEDED(pResult->GetResult(&pProgram));
  1768. VERIFY_IS_NOT_NULL(pProgram);
  1769. hlsl::DxilContainerHeader *pContainerHeader =
  1770. (hlsl::DxilContainerHeader *)(pProgram->GetBufferPointer());
  1771. hlsl::DxilPartHeader *pPartHeader = hlsl::GetDxilPartByType(
  1772. pContainerHeader, hlsl::DxilFourCC::DFCC_RootSignature);
  1773. VERIFY_IS_NOT_NULL(pPartHeader);
  1774. // Remove root signature
  1775. CComPtr<IDxcBlob> pNewProgram;
  1776. CComPtr<IDxcContainerBuilder> pBuilder;
  1777. VERIFY_SUCCEEDED(CreateContainerBuilder(&pBuilder));
  1778. VERIFY_SUCCEEDED(pBuilder->Load(pProgram));
  1779. VERIFY_SUCCEEDED(pBuilder->RemovePart(hlsl::DxilFourCC::DFCC_RootSignature));
  1780. pResult.Release();
  1781. VERIFY_SUCCEEDED(pBuilder->SerializeContainer(&pResult));
  1782. VERIFY_SUCCEEDED(pResult->GetResult(&pNewProgram));
  1783. pContainerHeader = (hlsl::DxilContainerHeader *)(pNewProgram->GetBufferPointer());
  1784. pPartHeader = hlsl::GetDxilPartByType(pContainerHeader,
  1785. hlsl::DxilFourCC::DFCC_RootSignature);
  1786. VERIFY_IS_NULL(pPartHeader);
  1787. }
  1788. TEST_F(CompilerTest, CompileWhenIncludeThenLoadInvoked) {
  1789. CComPtr<IDxcCompiler> pCompiler;
  1790. CComPtr<IDxcOperationResult> pResult;
  1791. CComPtr<IDxcBlobEncoding> pSource;
  1792. CComPtr<TestIncludeHandler> pInclude;
  1793. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1794. CreateBlobFromText(
  1795. "#include \"helper.h\"\r\n"
  1796. "float4 main() : SV_Target { return 0; }", &pSource);
  1797. pInclude = new TestIncludeHandler(m_dllSupport);
  1798. pInclude->CallResults.emplace_back("");
  1799. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1800. L"ps_6_0", nullptr, 0, nullptr, 0, pInclude, &pResult));
  1801. VerifyOperationSucceeded(pResult);
  1802. VERIFY_ARE_EQUAL_WSTR(L"./helper.h;", pInclude->GetAllFileNames().c_str());
  1803. }
  1804. TEST_F(CompilerTest, CompileWhenIncludeThenLoadUsed) {
  1805. CComPtr<IDxcCompiler> pCompiler;
  1806. CComPtr<IDxcOperationResult> pResult;
  1807. CComPtr<IDxcBlobEncoding> pSource;
  1808. CComPtr<TestIncludeHandler> pInclude;
  1809. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1810. CreateBlobFromText(
  1811. "#include \"helper.h\"\r\n"
  1812. "float4 main() : SV_Target { return ZERO; }", &pSource);
  1813. pInclude = new TestIncludeHandler(m_dllSupport);
  1814. pInclude->CallResults.emplace_back("#define ZERO 0");
  1815. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1816. L"ps_6_0", nullptr, 0, nullptr, 0, pInclude, &pResult));
  1817. VerifyOperationSucceeded(pResult);
  1818. VERIFY_ARE_EQUAL_WSTR(L"./helper.h;", pInclude->GetAllFileNames().c_str());
  1819. }
  1820. TEST_F(CompilerTest, CompileWhenIncludeAbsoluteThenLoadAbsolute) {
  1821. CComPtr<IDxcCompiler> pCompiler;
  1822. CComPtr<IDxcOperationResult> pResult;
  1823. CComPtr<IDxcBlobEncoding> pSource;
  1824. CComPtr<TestIncludeHandler> pInclude;
  1825. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1826. CreateBlobFromText(
  1827. "#include \"C:\\helper.h\"\r\n"
  1828. "float4 main() : SV_Target { return ZERO; }", &pSource);
  1829. pInclude = new TestIncludeHandler(m_dllSupport);
  1830. pInclude->CallResults.emplace_back("#define ZERO 0");
  1831. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1832. L"ps_6_0", nullptr, 0, nullptr, 0, pInclude, &pResult));
  1833. VerifyOperationSucceeded(pResult);
  1834. VERIFY_ARE_EQUAL_WSTR(L"C:\\helper.h;", pInclude->GetAllFileNames().c_str());
  1835. }
  1836. TEST_F(CompilerTest, CompileWhenIncludeLocalThenLoadRelative) {
  1837. CComPtr<IDxcCompiler> pCompiler;
  1838. CComPtr<IDxcOperationResult> pResult;
  1839. CComPtr<IDxcBlobEncoding> pSource;
  1840. CComPtr<TestIncludeHandler> pInclude;
  1841. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1842. CreateBlobFromText(
  1843. "#include \"..\\helper.h\"\r\n"
  1844. "float4 main() : SV_Target { return ZERO; }", &pSource);
  1845. pInclude = new TestIncludeHandler(m_dllSupport);
  1846. pInclude->CallResults.emplace_back("#define ZERO 0");
  1847. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1848. L"ps_6_0", nullptr, 0, nullptr, 0, pInclude, &pResult));
  1849. VerifyOperationSucceeded(pResult);
  1850. VERIFY_ARE_EQUAL_WSTR(L"./..\\helper.h;", pInclude->GetAllFileNames().c_str());
  1851. }
  1852. TEST_F(CompilerTest, CompileWhenIncludeSystemThenLoadNotRelative) {
  1853. CComPtr<IDxcCompiler> pCompiler;
  1854. CComPtr<IDxcOperationResult> pResult;
  1855. CComPtr<IDxcBlobEncoding> pSource;
  1856. CComPtr<TestIncludeHandler> pInclude;
  1857. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1858. CreateBlobFromText(
  1859. "#include \"subdir/other/file.h\"\r\n"
  1860. "float4 main() : SV_Target { return ZERO; }", &pSource);
  1861. LPCWSTR args[] = {
  1862. L"-Ifoo"
  1863. };
  1864. pInclude = new TestIncludeHandler(m_dllSupport);
  1865. pInclude->CallResults.emplace_back("#include <helper.h>");
  1866. pInclude->CallResults.emplace_back("#define ZERO 0");
  1867. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1868. L"ps_6_0", args, _countof(args), nullptr, 0, pInclude, &pResult));
  1869. VerifyOperationSucceeded(pResult);
  1870. VERIFY_ARE_EQUAL_WSTR(L"./subdir/other/file.h;./foo\\helper.h;", pInclude->GetAllFileNames().c_str());
  1871. }
  1872. TEST_F(CompilerTest, CompileWhenIncludeSystemMissingThenLoadAttempt) {
  1873. CComPtr<IDxcCompiler> pCompiler;
  1874. CComPtr<IDxcOperationResult> pResult;
  1875. CComPtr<IDxcBlobEncoding> pSource;
  1876. CComPtr<TestIncludeHandler> pInclude;
  1877. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1878. CreateBlobFromText(
  1879. "#include \"subdir/other/file.h\"\r\n"
  1880. "float4 main() : SV_Target { return ZERO; }", &pSource);
  1881. pInclude = new TestIncludeHandler(m_dllSupport);
  1882. pInclude->CallResults.emplace_back("#include <helper.h>");
  1883. pInclude->CallResults.emplace_back("#define ZERO 0");
  1884. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1885. L"ps_6_0", nullptr, 0, nullptr, 0, pInclude, &pResult));
  1886. std::string failLog(VerifyOperationFailed(pResult));
  1887. VERIFY_ARE_NOT_EQUAL(std::string::npos, failLog.find("<angled>")); // error message should prompt to use <angled> rather than "quotes"
  1888. VERIFY_ARE_EQUAL_WSTR(L"./subdir/other/file.h;./subdir/other/helper.h;", pInclude->GetAllFileNames().c_str());
  1889. }
  1890. TEST_F(CompilerTest, CompileWhenIncludeFlagsThenIncludeUsed) {
  1891. CComPtr<IDxcCompiler> pCompiler;
  1892. CComPtr<IDxcOperationResult> pResult;
  1893. CComPtr<IDxcBlobEncoding> pSource;
  1894. CComPtr<TestIncludeHandler> pInclude;
  1895. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1896. CreateBlobFromText(
  1897. "#include <helper.h>\r\n"
  1898. "float4 main() : SV_Target { return ZERO; }", &pSource);
  1899. pInclude = new TestIncludeHandler(m_dllSupport);
  1900. pInclude->CallResults.emplace_back("#define ZERO 0");
  1901. LPCWSTR args[] = {
  1902. L"-I\\\\server\\share"
  1903. };
  1904. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1905. L"ps_6_0", args, _countof(args), nullptr, 0, pInclude, &pResult));
  1906. VerifyOperationSucceeded(pResult);
  1907. VERIFY_ARE_EQUAL_WSTR(L"\\\\server\\share\\helper.h;", pInclude->GetAllFileNames().c_str());
  1908. }
  1909. TEST_F(CompilerTest, CompileWhenIncludeMissingThenFail) {
  1910. CComPtr<IDxcCompiler> pCompiler;
  1911. CComPtr<IDxcOperationResult> pResult;
  1912. CComPtr<IDxcBlobEncoding> pSource;
  1913. CComPtr<TestIncludeHandler> pInclude;
  1914. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1915. CreateBlobFromText(
  1916. "#include \"file.h\"\r\n"
  1917. "float4 main() : SV_Target { return 0; }", &pSource);
  1918. pInclude = new TestIncludeHandler(m_dllSupport);
  1919. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1920. L"ps_6_0", nullptr, 0, nullptr, 0, pInclude, &pResult));
  1921. HRESULT hr;
  1922. VERIFY_SUCCEEDED(pResult->GetStatus(&hr));
  1923. VERIFY_FAILED(hr);
  1924. }
  1925. TEST_F(CompilerTest, CompileWhenIncludeHasPathThenOK) {
  1926. CComPtr<IDxcCompiler> pCompiler;
  1927. LPCWSTR Source = L"c:\\temp\\OddIncludes\\main.hlsl";
  1928. LPCWSTR Args[] = { L"/I", L"c:\\temp" };
  1929. LPCWSTR ArgsUp[] = { L"/I", L"c:\\Temp" };
  1930. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1931. bool useUpValues[] = { false, true };
  1932. for (bool useUp : useUpValues) {
  1933. CComPtr<IDxcOperationResult> pResult;
  1934. CComPtr<IDxcBlobEncoding> pSource;
  1935. #if TEST_ON_DISK
  1936. CComPtr<IDxcLibrary> pLibrary;
  1937. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
  1938. VERIFY_SUCCEEDED(pLibrary->CreateIncludeHandler(&pInclude));
  1939. VERIFY_SUCCEEDED(pLibrary->CreateBlobFromFile(Source, nullptr, &pSource));
  1940. #else
  1941. CComPtr<TestIncludeHandler> pInclude;
  1942. pInclude = new TestIncludeHandler(m_dllSupport);
  1943. pInclude->CallResults.emplace_back("// Empty");
  1944. CreateBlobFromText("#include \"include.hlsl\"\r\n"
  1945. "float4 main() : SV_Target { return 0; }",
  1946. &pSource);
  1947. #endif
  1948. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, Source, L"main",
  1949. L"ps_6_0", useUp ? ArgsUp : Args, _countof(Args), nullptr, 0, pInclude, &pResult));
  1950. HRESULT hr;
  1951. VERIFY_SUCCEEDED(pResult->GetStatus(&hr));
  1952. VERIFY_SUCCEEDED(hr);
  1953. }
  1954. }
  1955. static const char EmptyCompute[] = "[numthreads(8,8,1)] void main() { }";
  1956. TEST_F(CompilerTest, CompileWhenODumpThenPassConfig) {
  1957. CComPtr<IDxcCompiler> pCompiler;
  1958. CComPtr<IDxcOperationResult> pResult;
  1959. CComPtr<IDxcBlobEncoding> pSource;
  1960. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1961. CreateBlobFromText(EmptyCompute, &pSource);
  1962. LPCWSTR Args[] = { L"/Odump" };
  1963. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1964. L"cs_6_0", Args, _countof(Args), nullptr, 0, nullptr, &pResult));
  1965. VerifyOperationSucceeded(pResult);
  1966. CComPtr<IDxcBlob> pResultBlob;
  1967. VERIFY_SUCCEEDED(pResult->GetResult(&pResultBlob));
  1968. string passes((char *)pResultBlob->GetBufferPointer(), pResultBlob->GetBufferSize());
  1969. VERIFY_ARE_NOT_EQUAL(string::npos, passes.find("inline"));
  1970. }
  1971. TEST_F(CompilerTest, CompileWhenVdThenProducesDxilContainer) {
  1972. CComPtr<IDxcCompiler> pCompiler;
  1973. CComPtr<IDxcOperationResult> pResult;
  1974. CComPtr<IDxcBlobEncoding> pSource;
  1975. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  1976. CreateBlobFromText(EmptyCompute, &pSource);
  1977. LPCWSTR Args[] = { L"/Vd" };
  1978. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  1979. L"cs_6_0", Args, _countof(Args), nullptr, 0, nullptr, &pResult));
  1980. VerifyOperationSucceeded(pResult);
  1981. CComPtr<IDxcBlob> pResultBlob;
  1982. VERIFY_SUCCEEDED(pResult->GetResult(&pResultBlob));
  1983. VERIFY_IS_TRUE(hlsl::IsValidDxilContainer(reinterpret_cast<hlsl::DxilContainerHeader *>(pResultBlob->GetBufferPointer()), pResultBlob->GetBufferSize()));
  1984. }
  1985. TEST_F(CompilerTest, CompileWhenODumpThenOptimizerMatch) {
  1986. LPCWSTR OptLevels[] = { L"/Od", L"/O1", L"/O2" };
  1987. CComPtr<IDxcCompiler> pCompiler;
  1988. CComPtr<IDxcOptimizer> pOptimizer;
  1989. CComPtr<IDxcAssembler> pAssembler;
  1990. CComPtr<IDxcValidator> pValidator;
  1991. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcAssembler, &pAssembler));
  1992. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
  1993. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcOptimizer, &pOptimizer));
  1994. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcValidator, &pValidator));
  1995. for (LPCWSTR OptLevel : OptLevels) {
  1996. CComPtr<IDxcOperationResult> pResult;
  1997. CComPtr<IDxcBlobEncoding> pSource;
  1998. CComPtr<IDxcBlob> pHighLevelBlob;
  1999. CComPtr<IDxcBlob> pOptimizedModule;
  2000. CComPtr<IDxcBlob> pAssembledBlob;
  2001. // Could use EmptyCompute and cs_6_0, but there is an issue where properties
  2002. // don't round-trip properly at high-level, so validation fails because
  2003. // dimensions are set to zero. Workaround by using pixel shader instead.
  2004. LPCWSTR Target = L"ps_6_0";
  2005. CreateBlobFromText("float4 main() : SV_Target { return 0; }", &pSource);
  2006. LPCWSTR Args[2] = { OptLevel, L"/Odump" };
  2007. // Get the passes for this optimization level.
  2008. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2009. Target, Args, _countof(Args), nullptr, 0, nullptr, &pResult));
  2010. VerifyOperationSucceeded(pResult);
  2011. CComPtr<IDxcBlob> pResultBlob;
  2012. VERIFY_SUCCEEDED(pResult->GetResult(&pResultBlob));
  2013. string passes((char *)pResultBlob->GetBufferPointer(), pResultBlob->GetBufferSize());
  2014. // Get wchar_t version and prepend hlsl-hlensure, to do a split high-level/opt compilation pass.
  2015. CA2W passesW(passes.c_str(), CP_UTF8);
  2016. std::vector<LPCWSTR> Options;
  2017. Options.push_back(L"-hlsl-hlensure");
  2018. wchar_t *pPassesBuffer = passesW.m_psz;
  2019. while (*pPassesBuffer) {
  2020. // Skip comment lines.
  2021. if (*pPassesBuffer == L'#') {
  2022. while (*pPassesBuffer && *pPassesBuffer != '\n' && *pPassesBuffer != '\r') {
  2023. ++pPassesBuffer;
  2024. }
  2025. while (*pPassesBuffer == '\n' || *pPassesBuffer == '\r') {
  2026. ++pPassesBuffer;
  2027. }
  2028. continue;
  2029. }
  2030. // Every other line is an option. Find the end of the line/buffer and terminate it.
  2031. Options.push_back(pPassesBuffer);
  2032. while (*pPassesBuffer && *pPassesBuffer != '\n' && *pPassesBuffer != '\r') {
  2033. ++pPassesBuffer;
  2034. }
  2035. while (*pPassesBuffer == '\n' || *pPassesBuffer == '\r') {
  2036. *pPassesBuffer = L'\0';
  2037. ++pPassesBuffer;
  2038. }
  2039. }
  2040. // Now compile directly.
  2041. pResult.Release();
  2042. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2043. Target, Args, 1, nullptr, 0, nullptr, &pResult));
  2044. VerifyOperationSucceeded(pResult);
  2045. // Now compile via a high-level compile followed by the optimization passes.
  2046. pResult.Release();
  2047. Args[_countof(Args)-1] = L"/fcgl";
  2048. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2049. Target, Args, _countof(Args), nullptr, 0, nullptr, &pResult));
  2050. VerifyOperationSucceeded(pResult);
  2051. VERIFY_SUCCEEDED(pResult->GetResult(&pHighLevelBlob));
  2052. VERIFY_SUCCEEDED(pOptimizer->RunOptimizer(pHighLevelBlob, Options.data(),
  2053. Options.size(), &pOptimizedModule,
  2054. nullptr));
  2055. // At the very least, the module should be valid.
  2056. pResult.Release();
  2057. VERIFY_SUCCEEDED(pAssembler->AssembleToContainer(pOptimizedModule, &pResult));
  2058. VerifyOperationSucceeded(pResult);
  2059. VERIFY_SUCCEEDED(pResult->GetResult(&pAssembledBlob));
  2060. pResult.Release();
  2061. VERIFY_SUCCEEDED(pValidator->Validate(pAssembledBlob, DxcValidatorFlags_Default, &pResult));
  2062. VerifyOperationSucceeded(pResult);
  2063. }
  2064. }
  2065. static const UINT CaptureStacks = 1; // Set to 1 to enable captures
  2066. static const UINT StackFrameCount = 12;
  2067. static const UINT StackFrameCountForRefs = 4;
  2068. struct InstrumentedHeapMalloc : public IMalloc {
  2069. private:
  2070. HANDLE m_Handle; // Heap handle.
  2071. ULONG m_RefCount = 0; // Reference count. Used for reference leaks, not for lifetime.
  2072. ULONG m_AllocCount = 0; // Total # of alloc and realloc requests.
  2073. ULONG m_AllocSize = 0; // Total # of alloc and realloc bytes.
  2074. ULONG m_Size = 0; // Current # of alloc'ed bytes.
  2075. ULONG m_FailAlloc = 0; // If nonzero, the alloc/realloc call to fail.
  2076. // Each allocation also tracks the following information:
  2077. // - allocation callstack
  2078. // - deallocation callstack
  2079. // - prior/next blocks in a list of allocated blocks
  2080. LIST_ENTRY AllocList;
  2081. struct PtrData {
  2082. LIST_ENTRY Entry;
  2083. PVOID AllocFrames[CaptureStacks ? StackFrameCount * CaptureStacks : 1];
  2084. PVOID FreeFrames[CaptureStacks ? StackFrameCount * CaptureStacks : 1];
  2085. UINT64 AllocAtCount;
  2086. DWORD AllocFrameCount;
  2087. DWORD FreeFrameCount;
  2088. SIZE_T Size;
  2089. PtrData *Self;
  2090. };
  2091. PtrData *DataFromPtr(void *p) {
  2092. if (p == nullptr) return nullptr;
  2093. PtrData *R = ((PtrData *)p) - 1;
  2094. if (R != R->Self) {
  2095. VERIFY_FAIL(); // p is invalid or underrun
  2096. }
  2097. return R;
  2098. }
  2099. public:
  2100. InstrumentedHeapMalloc() : m_Handle(nullptr) {
  2101. ResetCounts();
  2102. }
  2103. ~InstrumentedHeapMalloc() {
  2104. if (m_Handle)
  2105. HeapDestroy(m_Handle);
  2106. }
  2107. void ResetHeap() {
  2108. if (m_Handle) {
  2109. HeapDestroy(m_Handle);
  2110. m_Handle = nullptr;
  2111. }
  2112. m_Handle = HeapCreate(HEAP_NO_SERIALIZE, 0, 0);
  2113. }
  2114. ULONG GetRefCount() const { return m_RefCount; }
  2115. ULONG GetAllocCount() const { return m_AllocCount; }
  2116. ULONG GetAllocSize() const { return m_AllocSize; }
  2117. ULONG GetSize() const { return m_Size; }
  2118. void ResetCounts() {
  2119. m_RefCount = m_AllocCount = m_AllocSize = m_Size = 0;
  2120. AllocList.Blink = AllocList.Flink = &AllocList;
  2121. }
  2122. void SetFailAlloc(ULONG index) {
  2123. m_FailAlloc = index;
  2124. }
  2125. ULONG STDMETHODCALLTYPE AddRef() {
  2126. return ++m_RefCount;
  2127. }
  2128. ULONG STDMETHODCALLTYPE Release() {
  2129. if (m_RefCount == 0) VERIFY_FAIL();
  2130. return --m_RefCount;
  2131. }
  2132. STDMETHODIMP QueryInterface(REFIID iid, void** ppvObject) {
  2133. return DoBasicQueryInterface<IMalloc>(this, iid, ppvObject);
  2134. }
  2135. virtual void *STDMETHODCALLTYPE Alloc(_In_ SIZE_T cb) {
  2136. ++m_AllocCount;
  2137. if (m_FailAlloc && m_AllocCount >= m_FailAlloc) {
  2138. return nullptr; // breakpoint for i failure - m_FailAlloc == 1+VAL
  2139. }
  2140. m_AllocSize += cb;
  2141. m_Size += cb;
  2142. PtrData *P = (PtrData *)HeapAlloc(m_Handle, HEAP_ZERO_MEMORY, sizeof(PtrData) + cb);
  2143. P->Entry.Flink = AllocList.Flink;
  2144. P->Entry.Blink = &AllocList;
  2145. AllocList.Flink->Blink = &(P->Entry);
  2146. AllocList.Flink = &(P->Entry);
  2147. // breakpoint for i failure on NN alloc - m_FailAlloc == 1+VAL && m_AllocCount == NN
  2148. // breakpoint for happy path for NN alloc - m_AllocCount == NN
  2149. P->AllocAtCount = m_AllocCount;
  2150. if (CaptureStacks)
  2151. P->AllocFrameCount = CaptureStackBackTrace(1, StackFrameCount, P->AllocFrames, nullptr);
  2152. P->Size = cb;
  2153. P->Self = P;
  2154. return P + 1;
  2155. }
  2156. virtual void *STDMETHODCALLTYPE Realloc(_In_opt_ void *pv, _In_ SIZE_T cb) {
  2157. SIZE_T priorSize = pv == nullptr ? (SIZE_T)0 : GetSize(pv);
  2158. void *R = Alloc(cb);
  2159. if (!R)
  2160. return nullptr;
  2161. SIZE_T copySize = std::min(cb, priorSize);
  2162. memcpy(R, pv, copySize);
  2163. Free(pv);
  2164. return R;
  2165. }
  2166. virtual void STDMETHODCALLTYPE Free(_In_opt_ void *pv) {
  2167. if (!pv)
  2168. return;
  2169. PtrData *P = DataFromPtr(pv);
  2170. if (P->FreeFrameCount)
  2171. VERIFY_FAIL(); // double-free detected
  2172. m_Size -= P->Size;
  2173. P->Entry.Flink->Blink = P->Entry.Blink;
  2174. P->Entry.Blink->Flink = P->Entry.Flink;
  2175. if (CaptureStacks)
  2176. P->FreeFrameCount =
  2177. CaptureStackBackTrace(1, StackFrameCount, P->FreeFrames, nullptr);
  2178. }
  2179. virtual SIZE_T STDMETHODCALLTYPE GetSize(
  2180. /* [annotation][in] */
  2181. _In_opt_ _Post_writable_byte_size_(return) void *pv)
  2182. {
  2183. if (pv == nullptr) return 0;
  2184. return DataFromPtr(pv)->Size;
  2185. }
  2186. virtual int STDMETHODCALLTYPE DidAlloc(
  2187. _In_opt_ void *pv) {
  2188. return -1; // don't know
  2189. }
  2190. virtual void STDMETHODCALLTYPE HeapMinimize(void) {}
  2191. };
  2192. TEST_F(CompilerTest, CompileWhenNoMemThenOOM) {
  2193. WEX::TestExecution::SetVerifyOutput verifySettings(WEX::TestExecution::VerifyOutputSettings::LogOnlyFailures);
  2194. CComPtr<IDxcBlobEncoding> pSource;
  2195. CreateBlobFromText(EmptyCompute, &pSource);
  2196. InstrumentedHeapMalloc InstrMalloc;
  2197. CComPtr<IDxcCompiler> pCompiler;
  2198. CComPtr<IDxcOperationResult> pResult;
  2199. ULONG allocCount = 0;
  2200. ULONG allocSize = 0;
  2201. ULONG initialRefCount;
  2202. InstrMalloc.ResetHeap();
  2203. VERIFY_IS_TRUE(m_dllSupport.HasCreateWithMalloc());
  2204. // Verify a simple object creation.
  2205. initialRefCount = InstrMalloc.GetRefCount();
  2206. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance2(&InstrMalloc, CLSID_DxcCompiler, &pCompiler));
  2207. pCompiler.Release();
  2208. VERIFY_IS_TRUE(0 == InstrMalloc.GetSize());
  2209. VERIFY_ARE_EQUAL(initialRefCount, InstrMalloc.GetRefCount());
  2210. InstrMalloc.ResetCounts();
  2211. InstrMalloc.ResetHeap();
  2212. // First time, run to completion and capture stats.
  2213. initialRefCount = InstrMalloc.GetRefCount();
  2214. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance2(&InstrMalloc, CLSID_DxcCompiler, &pCompiler));
  2215. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2216. L"cs_6_0", nullptr, 0, nullptr, 0, nullptr, &pResult));
  2217. allocCount = InstrMalloc.GetAllocCount();
  2218. allocSize = InstrMalloc.GetAllocSize();
  2219. HRESULT hrWithMemory;
  2220. VERIFY_SUCCEEDED(pResult->GetStatus(&hrWithMemory));
  2221. VERIFY_SUCCEEDED(hrWithMemory);
  2222. pCompiler.Release();
  2223. pResult.Release();
  2224. VERIFY_IS_TRUE(allocSize > allocCount);
  2225. // Ensure that after all resources are released, there are no outstanding
  2226. // allocations or references.
  2227. //
  2228. // First leak is in ((InstrumentedHeapMalloc::PtrData *)InstrMalloc.AllocList.Flink)
  2229. VERIFY_IS_TRUE(0 == InstrMalloc.GetSize());
  2230. VERIFY_ARE_EQUAL(initialRefCount, InstrMalloc.GetRefCount());
  2231. // In Debug, for the typical configuration, debug iterators will be used;
  2232. // this causes a problem where std::string is specified as noexcept, and yet
  2233. // a sentinel is allocated that may fail and throw.
  2234. // Skip the failure tests in Debug, run them in Release.
  2235. // To run this in Debug without debug iterators, add the following line to the root CMakeLists.txt
  2236. // add_definitions(/D_ITERATOR_DEBUG_LEVEL=0)
  2237. if (m_ver.SkipOutOfMemoryTest()) return;
  2238. // Now, fail each allocation and make sure we get an error.
  2239. for (ULONG i = 0; i <= allocCount; ++i) {
  2240. // LogCommentFmt(L"alloc fail %u", i);
  2241. bool isLast = i == allocCount;
  2242. InstrMalloc.ResetCounts();
  2243. InstrMalloc.ResetHeap();
  2244. InstrMalloc.SetFailAlloc(i + 1);
  2245. HRESULT hrOp = m_dllSupport.CreateInstance2(&InstrMalloc, CLSID_DxcCompiler, &pCompiler);
  2246. if (SUCCEEDED(hrOp)) {
  2247. hrOp = pCompiler->Compile(pSource, L"source.hlsl", L"main", L"cs_6_0",
  2248. nullptr, 0, nullptr, 0, nullptr, &pResult);
  2249. if (SUCCEEDED(hrOp)) {
  2250. pResult->GetStatus(&hrOp);
  2251. }
  2252. }
  2253. if (FAILED(hrOp)) {
  2254. // This is true in *almost* every case. When the OOM happens during stream
  2255. // handling, there is no specific error set; by the time it's detected,
  2256. // it propagates as E_FAIL.
  2257. //VERIFY_ARE_EQUAL(hrOp, E_OUTOFMEMORY);
  2258. VERIFY_IS_TRUE(hrOp == E_OUTOFMEMORY || hrOp == E_FAIL);
  2259. }
  2260. if (isLast)
  2261. VERIFY_SUCCEEDED(hrOp);
  2262. else
  2263. VERIFY_FAILED(hrOp);
  2264. pCompiler.Release();
  2265. pResult.Release();
  2266. VERIFY_IS_TRUE(0 == InstrMalloc.GetSize()); // breakpoint for i failure - i == val
  2267. VERIFY_ARE_EQUAL(initialRefCount, InstrMalloc.GetRefCount());
  2268. }
  2269. }
  2270. TEST_F(CompilerTest, CompileWhenShaderModelMismatchAttributeThenFail) {
  2271. CComPtr<IDxcCompiler> pCompiler;
  2272. CComPtr<IDxcOperationResult> pResult;
  2273. CComPtr<IDxcBlobEncoding> pSource;
  2274. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  2275. CreateBlobFromText(EmptyCompute, &pSource);
  2276. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2277. L"ps_6_0", nullptr, 0, nullptr, 0, nullptr, &pResult));
  2278. std::string failLog(VerifyOperationFailed(pResult));
  2279. VERIFY_ARE_NOT_EQUAL(string::npos, failLog.find("attribute numthreads only valid for CS"));
  2280. }
  2281. TEST_F(CompilerTest, CompileBadHlslThenFail) {
  2282. CComPtr<IDxcCompiler> pCompiler;
  2283. CComPtr<IDxcOperationResult> pResult;
  2284. CComPtr<IDxcBlobEncoding> pSource;
  2285. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  2286. CreateBlobFromText(
  2287. "bad hlsl", &pSource);
  2288. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2289. L"ps_6_0", nullptr, 0, nullptr, 0, nullptr, &pResult));
  2290. HRESULT status;
  2291. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  2292. VERIFY_FAILED(status);
  2293. }
  2294. TEST_F(CompilerTest, CompileLegacyShaderModelThenFail) {
  2295. VerifyCompileFailed(
  2296. "float4 main(float4 pos : SV_Position) : SV_Target { return pos; }", L"ps_5_1", nullptr);
  2297. }
  2298. TEST_F(CompilerTest, CompileWhenRecursiveAlbeitStaticTermThenFail) {
  2299. // This shader will compile under fxc because if execution is
  2300. // simulated statically, it does terminate. dxc changes this behavior
  2301. // to avoid imposing the requirement on the compiler.
  2302. const char ShaderText[] =
  2303. "static int i = 10;\r\n"
  2304. "float4 f(); // Forward declaration\r\n"
  2305. "float4 g() { if (i > 10) { i--; return f(); } else return 0; } // Recursive call to 'f'\r\n"
  2306. "float4 f() { return g(); } // First call to 'g'\r\n"
  2307. "float4 VS() : SV_Position{\r\n"
  2308. " return f(); // First call to 'f'\r\n"
  2309. "}\r\n";
  2310. VerifyCompileFailed(ShaderText, L"vs_6_0", "recursive functions not allowed", L"VS");
  2311. }
  2312. TEST_F(CompilerTest, CompileWhenRecursiveThenFail) {
  2313. const char ShaderTextSimple[] =
  2314. "float4 f(); // Forward declaration\r\n"
  2315. "float4 g() { return f(); } // Recursive call to 'f'\r\n"
  2316. "float4 f() { return g(); } // First call to 'g'\r\n"
  2317. "float4 main() : SV_Position{\r\n"
  2318. " return f(); // First call to 'f'\r\n"
  2319. "}\r\n";
  2320. VerifyCompileFailed(ShaderTextSimple, L"vs_6_0", "recursive functions not allowed");
  2321. const char ShaderTextIndirect[] =
  2322. "float4 f(); // Forward declaration\r\n"
  2323. "float4 g() { return f(); } // Recursive call to 'f'\r\n"
  2324. "float4 f() { return g(); } // First call to 'g'\r\n"
  2325. "float4 main() : SV_Position{\r\n"
  2326. " return f(); // First call to 'f'\r\n"
  2327. "}\r\n";
  2328. VerifyCompileFailed(ShaderTextIndirect, L"vs_6_0", "recursive functions not allowed");
  2329. const char ShaderTextSelf[] =
  2330. "float4 main() : SV_Position{\r\n"
  2331. " return main();\r\n"
  2332. "}\r\n";
  2333. VerifyCompileFailed(ShaderTextSelf, L"vs_6_0", "recursive functions not allowed");
  2334. const char ShaderTextMissing[] =
  2335. "float4 mainz() : SV_Position{\r\n"
  2336. " return 1;\r\n"
  2337. "}\r\n";
  2338. VerifyCompileFailed(ShaderTextMissing, L"vs_6_0", "missing entry point definition");
  2339. }
  2340. TEST_F(CompilerTest, CompileHlsl2015ThenFail) {
  2341. CComPtr<IDxcCompiler> pCompiler;
  2342. CComPtr<IDxcOperationResult> pResult;
  2343. CComPtr<IDxcBlobEncoding> pSource;
  2344. CComPtr<IDxcBlobEncoding> pErrors;
  2345. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  2346. CreateBlobFromText("float4 main(float4 pos : SV_Position) : SV_Target { return pos; }", &pSource);
  2347. LPCWSTR args[2] = { L"-HV", L"2015" };
  2348. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2349. L"ps_6_0", args, 2, nullptr, 0, nullptr, &pResult));
  2350. HRESULT status;
  2351. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  2352. VERIFY_ARE_EQUAL(status, E_INVALIDARG);
  2353. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
  2354. LPCSTR pErrorMsg = "HLSL Version 2015 is only supported for language services";
  2355. CheckOperationResultMsgs(pResult, &pErrorMsg, 1, false, false);
  2356. }
  2357. TEST_F(CompilerTest, CompileHlsl2016ThenOK) {
  2358. CComPtr<IDxcCompiler> pCompiler;
  2359. CComPtr<IDxcOperationResult> pResult;
  2360. CComPtr<IDxcBlobEncoding> pSource;
  2361. CComPtr<IDxcBlobEncoding> pErrors;
  2362. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  2363. CreateBlobFromText("float4 main(float4 pos : SV_Position) : SV_Target { return pos; }", &pSource);
  2364. LPCWSTR args[2] = { L"-HV", L"2016" };
  2365. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2366. L"ps_6_0", args, 2, nullptr, 0, nullptr, &pResult));
  2367. HRESULT status;
  2368. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  2369. VERIFY_SUCCEEDED(status);
  2370. }
  2371. TEST_F(CompilerTest, CompileHlsl2017ThenOK) {
  2372. CComPtr<IDxcCompiler> pCompiler;
  2373. CComPtr<IDxcOperationResult> pResult;
  2374. CComPtr<IDxcBlobEncoding> pSource;
  2375. CComPtr<IDxcBlobEncoding> pErrors;
  2376. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  2377. CreateBlobFromText("float4 main(float4 pos : SV_Position) : SV_Target { return pos; }", &pSource);
  2378. LPCWSTR args[2] = { L"-HV", L"2017" };
  2379. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2380. L"ps_6_0", args, 2, nullptr, 0, nullptr, &pResult));
  2381. HRESULT status;
  2382. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  2383. VERIFY_SUCCEEDED(status);
  2384. }
  2385. TEST_F(CompilerTest, CompileHlsl2018ThenFail) {
  2386. CComPtr<IDxcCompiler> pCompiler;
  2387. CComPtr<IDxcOperationResult> pResult;
  2388. CComPtr<IDxcBlobEncoding> pSource;
  2389. CComPtr<IDxcBlobEncoding> pErrors;
  2390. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  2391. CreateBlobFromText("float4 main(float4 pos : SV_Position) : SV_Target { return pos; }", &pSource);
  2392. LPCWSTR args[2] = { L"-HV", L"2018" };
  2393. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  2394. L"ps_6_0", args, 2, nullptr, 0, nullptr, &pResult));
  2395. HRESULT status;
  2396. VERIFY_SUCCEEDED(pResult->GetStatus(&status));
  2397. VERIFY_ARE_EQUAL(status, E_INVALIDARG);
  2398. VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&pErrors));
  2399. LPCSTR pErrorMsg = "Unknown HLSL version";
  2400. CheckOperationResultMsgs(pResult, &pErrorMsg, 1, false, false);
  2401. }
  2402. TEST_F(CompilerTest, DiaLoadBadBitcodeThenFail) {
  2403. CComPtr<IDxcBlob> pBadBitcode;
  2404. CComPtr<IDiaDataSource> pDiaSource;
  2405. CComPtr<IStream> pStream;
  2406. CComPtr<IDxcLibrary> pLib;
  2407. Utf8ToBlob(m_dllSupport, "badcode", &pBadBitcode);
  2408. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLib));
  2409. VERIFY_SUCCEEDED(pLib->CreateStreamFromBlobReadOnly(pBadBitcode, &pStream));
  2410. VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcDiaDataSource, &pDiaSource));
  2411. VERIFY_FAILED(pDiaSource->loadDataFromIStream(pStream));
  2412. }
  2413. static void CompileTestAndLoadDia(dxc::DxcDllSupport &dllSupport, IDiaDataSource **ppDataSource) {
  2414. CComPtr<IDxcBlob> pContainer;
  2415. CComPtr<IDxcBlob> pDebugContent;
  2416. CComPtr<IDiaDataSource> pDiaSource;
  2417. CComPtr<IStream> pStream;
  2418. CComPtr<IDxcLibrary> pLib;
  2419. CComPtr<IDxcContainerReflection> pReflection;
  2420. UINT32 index;
  2421. VerifyCompileOK(dllSupport, EmptyCompute, L"cs_6_0", L"/Zi", &pContainer);
  2422. VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcLibrary, &pLib));
  2423. VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcContainerReflection, &pReflection));
  2424. VERIFY_SUCCEEDED(pReflection->Load(pContainer));
  2425. VERIFY_SUCCEEDED(pReflection->FindFirstPartKind(hlsl::DFCC_ShaderDebugInfoDXIL, &index));
  2426. VERIFY_SUCCEEDED(pReflection->GetPartContent(index, &pDebugContent));
  2427. VERIFY_SUCCEEDED(pLib->CreateStreamFromBlobReadOnly(pDebugContent, &pStream));
  2428. VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcDiaDataSource, &pDiaSource));
  2429. VERIFY_SUCCEEDED(pDiaSource->loadDataFromIStream(pStream));
  2430. if (ppDataSource) {
  2431. *ppDataSource = pDiaSource.Detach();
  2432. }
  2433. }
  2434. TEST_F(CompilerTest, DiaLoadDebugThenOK) {
  2435. CompileTestAndLoadDia(m_dllSupport, nullptr);
  2436. }
  2437. TEST_F(CompilerTest, DiaTableIndexThenOK) {
  2438. CComPtr<IDiaDataSource> pDiaSource;
  2439. CComPtr<IDiaSession> pDiaSession;
  2440. CComPtr<IDiaEnumTables> pEnumTables;
  2441. CComPtr<IDiaTable> pTable;
  2442. VARIANT vtIndex;
  2443. CompileTestAndLoadDia(m_dllSupport, &pDiaSource);
  2444. VERIFY_SUCCEEDED(pDiaSource->openSession(&pDiaSession));
  2445. VERIFY_SUCCEEDED(pDiaSession->getEnumTables(&pEnumTables));
  2446. vtIndex.vt = VT_EMPTY;
  2447. VERIFY_FAILED(pEnumTables->Item(vtIndex, &pTable));
  2448. vtIndex.vt = VT_I4;
  2449. vtIndex.intVal = 1;
  2450. VERIFY_SUCCEEDED(pEnumTables->Item(vtIndex, &pTable));
  2451. VERIFY_IS_NOT_NULL(pTable.p);
  2452. pTable.Release();
  2453. vtIndex.vt = VT_UI4;
  2454. vtIndex.uintVal = 1;
  2455. VERIFY_SUCCEEDED(pEnumTables->Item(vtIndex, &pTable));
  2456. VERIFY_IS_NOT_NULL(pTable.p);
  2457. pTable.Release();
  2458. vtIndex.uintVal = 100;
  2459. VERIFY_FAILED(pEnumTables->Item(vtIndex, &pTable));
  2460. }
  2461. TEST_F(CompilerTest, PixMSAAToSample0) {
  2462. CodeGenTestCheck(L"pix\\msaaLoad.hlsl");
  2463. }
  2464. TEST_F(CompilerTest, PixRemoveDiscards) {
  2465. CodeGenTestCheck(L"pix\\removeDiscards.hlsl");
  2466. }
  2467. TEST_F(CompilerTest, PixConstantColor) {
  2468. CodeGenTestCheck(L"pix\\constantcolor.hlsl");
  2469. }
  2470. TEST_F(CompilerTest, PixConstantColorInt) {
  2471. CodeGenTestCheck(L"pix\\constantcolorint.hlsl");
  2472. }
  2473. TEST_F(CompilerTest, PixConstantColorMRT) {
  2474. CodeGenTestCheck(L"pix\\constantcolorMRT.hlsl");
  2475. }
  2476. TEST_F(CompilerTest, PixConstantColorUAVs) {
  2477. CodeGenTestCheck(L"pix\\constantcolorUAVs.hlsl");
  2478. }
  2479. TEST_F(CompilerTest, PixConstantColorOtherSIVs) {
  2480. CodeGenTestCheck(L"pix\\constantcolorOtherSIVs.hlsl");
  2481. }
  2482. TEST_F(CompilerTest, PixConstantColorFromCB) {
  2483. CodeGenTestCheck(L"pix\\constantcolorFromCB.hlsl");
  2484. }
  2485. TEST_F(CompilerTest, PixConstantColorFromCBint) {
  2486. CodeGenTestCheck(L"pix\\constantcolorFromCBint.hlsl");
  2487. }
  2488. TEST_F(CompilerTest, CodeGenAbs1) {
  2489. CodeGenTestCheck(L"..\\CodeGenHLSL\\abs1.hlsl");
  2490. }
  2491. TEST_F(CompilerTest, CodeGenAbs2) {
  2492. CodeGenTest(L"..\\CodeGenHLSL\\abs2.hlsl");
  2493. }
  2494. TEST_F(CompilerTest, CodeGenAllLit) {
  2495. CodeGenTest(L"..\\CodeGenHLSL\\all_lit.hlsl");
  2496. }
  2497. TEST_F(CompilerTest, CodeGenAllocaAtEntryBlk) {
  2498. CodeGenTest(L"..\\CodeGenHLSL\\alloca_at_entry_blk.hlsl");
  2499. }
  2500. TEST_F(CompilerTest, CodeGenAddUint64) {
  2501. CodeGenTestCheck(L"..\\CodeGenHLSL\\AddUint64.hlsl");
  2502. }
  2503. TEST_F(CompilerTest, CodeGenArrayArg){
  2504. CodeGenTest(L"..\\CodeGenHLSL\\arrayArg.hlsl");
  2505. }
  2506. TEST_F(CompilerTest, CodeGenArrayArg2){
  2507. CodeGenTest(L"..\\CodeGenHLSL\\arrayArg2.hlsl");
  2508. }
  2509. TEST_F(CompilerTest, CodeGenArrayArg3){
  2510. CodeGenTest(L"..\\CodeGenHLSL\\arrayArg3.hlsl");
  2511. }
  2512. TEST_F(CompilerTest, CodeGenArrayOfStruct){
  2513. CodeGenTest(L"..\\CodeGenHLSL\\arrayOfStruct.hlsl");
  2514. }
  2515. TEST_F(CompilerTest, CodeGenAsUint) {
  2516. CodeGenTestCheck(L"..\\CodeGenHLSL\\asuint.hlsl");
  2517. }
  2518. TEST_F(CompilerTest, CodeGenAsUint2) {
  2519. CodeGenTestCheck(L"..\\CodeGenHLSL\\asuint2.hlsl");
  2520. }
  2521. TEST_F(CompilerTest, CodeGenAtomic) {
  2522. CodeGenTestCheck(L"..\\CodeGenHLSL\\atomic.hlsl");
  2523. }
  2524. TEST_F(CompilerTest, CodeGenAtomic2) {
  2525. CodeGenTestCheck(L"..\\CodeGenHLSL\\atomic2.hlsl");
  2526. }
  2527. TEST_F(CompilerTest, CodeGenAttributeAtVertex) {
  2528. if (m_ver.SkipDxilVersion(1,1)) return;
  2529. CodeGenTestCheck(L"..\\CodeGenHLSL\\attributeAtVertex.hlsl");
  2530. }
  2531. TEST_F(CompilerTest, CodeGenBarycentrics) {
  2532. if (m_ver.SkipDxilVersion(1,1)) return;
  2533. CodeGenTestCheck(L"..\\CodeGenHLSL\\barycentrics.hlsl");
  2534. }
  2535. TEST_F(CompilerTest, CodeGenBarycentrics1) {
  2536. if (m_ver.SkipDxilVersion(1,1)) return;
  2537. CodeGenTestCheck(L"..\\CodeGenHLSL\\barycentrics1.hlsl");
  2538. }
  2539. TEST_F(CompilerTest, CodeGenBarycentricsThreeSV) {
  2540. if (m_ver.SkipDxilVersion(1,1)) return;
  2541. CodeGenTestCheck(L"..\\CodeGenHLSL\\barycentricsThreeSV.hlsl");
  2542. }
  2543. TEST_F(CompilerTest, CodeGenBinary1) {
  2544. CodeGenTest(L"..\\CodeGenHLSL\\binary1.hlsl");
  2545. }
  2546. TEST_F(CompilerTest, CodeGenBoolComb) {
  2547. CodeGenTest(L"..\\CodeGenHLSL\\boolComb.hlsl");
  2548. }
  2549. TEST_F(CompilerTest, CodeGenBoolSvTarget) {
  2550. CodeGenTestCheck(L"..\\CodeGenHLSL\\boolSvTarget.hlsl");
  2551. }
  2552. TEST_F(CompilerTest, CodeGenCalcLod2DArray) {
  2553. CodeGenTestCheck(L"..\\CodeGenHLSL\\calcLod2DArray.hlsl");
  2554. }
  2555. TEST_F(CompilerTest, CodeGenCall1) {
  2556. CodeGenTest(L"..\\CodeGenHLSL\\call1.hlsl");
  2557. }
  2558. TEST_F(CompilerTest, CodeGenCall3) {
  2559. CodeGenTest(L"..\\CodeGenHLSL\\call3.hlsl");
  2560. }
  2561. TEST_F(CompilerTest, CodeGenCast1) {
  2562. CodeGenTest(L"..\\CodeGenHLSL\\cast1.hlsl");
  2563. }
  2564. TEST_F(CompilerTest, CodeGenCast2) {
  2565. CodeGenTest(L"..\\CodeGenHLSL\\cast2.hlsl");
  2566. }
  2567. TEST_F(CompilerTest, CodeGenCast3) {
  2568. CodeGenTest(L"..\\CodeGenHLSL\\cast3.hlsl");
  2569. }
  2570. TEST_F(CompilerTest, CodeGenCast4) {
  2571. CodeGenTest(L"..\\CodeGenHLSL\\cast4.hlsl");
  2572. }
  2573. TEST_F(CompilerTest, CodeGenCast5) {
  2574. CodeGenTestCheck(L"..\\CodeGenHLSL\\cast5.hlsl");
  2575. }
  2576. TEST_F(CompilerTest, CodeGenCast6) {
  2577. CodeGenTestCheck(L"..\\CodeGenHLSL\\cast6.hlsl");
  2578. }
  2579. TEST_F(CompilerTest, CodeGenCast7) {
  2580. CodeGenTestCheck(L"..\\CodeGenHLSL\\cast7.hlsl");
  2581. }
  2582. TEST_F(CompilerTest, CodeGenCbuf_init_static) {
  2583. CodeGenTest(L"..\\CodeGenHLSL\\cbuf_init_static.hlsl");
  2584. }
  2585. TEST_F(CompilerTest, CodeGenCbufferCopy) {
  2586. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer_copy.hlsl");
  2587. }
  2588. TEST_F(CompilerTest, CodeGenCbufferCopy1) {
  2589. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer_copy1.hlsl");
  2590. }
  2591. TEST_F(CompilerTest, CodeGenCbufferCopy2) {
  2592. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer_copy2.hlsl");
  2593. }
  2594. TEST_F(CompilerTest, CodeGenCbufferCopy3) {
  2595. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer_copy3.hlsl");
  2596. }
  2597. TEST_F(CompilerTest, CodeGenCbufferCopy4) {
  2598. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer_copy4.hlsl");
  2599. }
  2600. TEST_F(CompilerTest, CodeGenCbuffer_unused) {
  2601. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer_unused.hlsl");
  2602. }
  2603. TEST_F(CompilerTest, CodeGenCbuffer1_50) {
  2604. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer1.50.hlsl");
  2605. }
  2606. TEST_F(CompilerTest, CodeGenCbuffer1_51) {
  2607. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer1.51.hlsl");
  2608. }
  2609. TEST_F(CompilerTest, CodeGenCbuffer2_50) {
  2610. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer2.50.hlsl");
  2611. }
  2612. TEST_F(CompilerTest, CodeGenCbuffer2_51) {
  2613. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer2.51.hlsl");
  2614. }
  2615. TEST_F(CompilerTest, CodeGenCbuffer3_50) {
  2616. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer3.50.hlsl");
  2617. }
  2618. TEST_F(CompilerTest, CodeGenCbuffer3_51) {
  2619. CodeGenTest(L"..\\CodeGenHLSL\\cbuffer3.51.hlsl");
  2620. }
  2621. TEST_F(CompilerTest, CodeGenCbuffer5_51) {
  2622. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer5.51.hlsl");
  2623. }
  2624. TEST_F(CompilerTest, CodeGenCbuffer6_51) {
  2625. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer6.51.hlsl");
  2626. }
  2627. TEST_F(CompilerTest, CodeGenCbufferAlloc) {
  2628. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbufferAlloc.hlsl");
  2629. }
  2630. TEST_F(CompilerTest, CodeGenCbufferAllocLegacy) {
  2631. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbufferAlloc_legacy.hlsl");
  2632. }
  2633. TEST_F(CompilerTest, CodeGenCbufferInLoop) {
  2634. CodeGenTest(L"..\\CodeGenHLSL\\cbufferInLoop.hlsl");
  2635. }
  2636. TEST_F(CompilerTest, CodeGenClass) {
  2637. CodeGenTestCheck(L"..\\CodeGenHLSL\\class.hlsl");
  2638. }
  2639. TEST_F(CompilerTest, CodeGenClip) {
  2640. CodeGenTestCheck(L"..\\CodeGenHLSL\\clip.hlsl");
  2641. }
  2642. TEST_F(CompilerTest, CodeGenClipPlanes) {
  2643. CodeGenTestCheck(L"..\\CodeGenHLSL\\clip_planes.hlsl");
  2644. }
  2645. TEST_F(CompilerTest, CodeGenConstoperand1) {
  2646. CodeGenTest(L"..\\CodeGenHLSL\\constoperand1.hlsl");
  2647. }
  2648. TEST_F(CompilerTest, CodeGenConstMat) {
  2649. CodeGenTestCheck(L"..\\CodeGenHLSL\\constMat.hlsl");
  2650. }
  2651. TEST_F(CompilerTest, CodeGenConstMat2) {
  2652. CodeGenTestCheck(L"..\\CodeGenHLSL\\constMat2.hlsl");
  2653. }
  2654. TEST_F(CompilerTest, CodeGenConstMat3) {
  2655. CodeGenTestCheck(L"..\\CodeGenHLSL\\constMat3.hlsl");
  2656. }
  2657. TEST_F(CompilerTest, CodeGenConstMat4) {
  2658. CodeGenTestCheck(L"..\\CodeGenHLSL\\constMat4.hlsl");
  2659. }
  2660. TEST_F(CompilerTest, CodeGenDiscard) {
  2661. CodeGenTestCheck(L"..\\CodeGenHLSL\\discard.hlsl");
  2662. }
  2663. TEST_F(CompilerTest, CodeGenDivZero) {
  2664. CodeGenTestCheck(L"..\\CodeGenHLSL\\divZero.hlsl");
  2665. }
  2666. TEST_F(CompilerTest, CodeGenDot1) {
  2667. CodeGenTest(L"..\\CodeGenHLSL\\dot1.hlsl");
  2668. }
  2669. TEST_F(CompilerTest, CodeGenDynamic_Resources) {
  2670. CodeGenTestCheck(L"..\\CodeGenHLSL\\dynamic-resources.hlsl");
  2671. }
  2672. TEST_F(CompilerTest, CodeGenEffectSkip) {
  2673. CodeGenTestCheck(L"..\\CodeGenHLSL\\effect_skip.hlsl");
  2674. }
  2675. TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing) {
  2676. CodeGenTestCheck(L"eliminate_dynamic_output.hlsl");
  2677. }
  2678. TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing2) {
  2679. CodeGenTestCheck(L"eliminate_dynamic_output2.hlsl");
  2680. }
  2681. TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing3) {
  2682. CodeGenTestCheck(L"eliminate_dynamic_output3.hlsl");
  2683. }
  2684. TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing4) {
  2685. CodeGenTestCheck(L"eliminate_dynamic_output4.hlsl");
  2686. }
  2687. TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing5) {
  2688. CodeGenTestCheck(L"eliminate_dynamic_output5.hlsl");
  2689. }
  2690. TEST_F(CompilerTest, CodeGenEliminateDynamicIndexing6) {
  2691. CodeGenTestCheck(L"eliminate_dynamic_output6.hlsl");
  2692. }
  2693. TEST_F(CompilerTest, CodeGenEmpty) {
  2694. CodeGenTest(L"..\\CodeGenHLSL\\empty.hlsl");
  2695. }
  2696. TEST_F(CompilerTest, CodeGenEmptyStruct) {
  2697. CodeGenTestCheck(L"..\\CodeGenHLSL\\emptyStruct.hlsl");
  2698. }
  2699. TEST_F(CompilerTest, CodeGenEnum1) {
  2700. CodeGenTestCheck(L"..\\CodeGenHLSL\\enum1.hlsl");
  2701. }
  2702. TEST_F(CompilerTest, CodeGenEnum2) {
  2703. CodeGenTestCheck(L"..\\CodeGenHLSL\\enum2.hlsl");
  2704. }
  2705. TEST_F(CompilerTest, CodeGenEnum3) {
  2706. if (m_ver.SkipDxilVersion(1,1)) return;
  2707. CodeGenTestCheck(L"..\\CodeGenHLSL\\enum3.hlsl");
  2708. }
  2709. TEST_F(CompilerTest, CodeGenEnum4) {
  2710. CodeGenTestCheck(L"..\\CodeGenHLSL\\enum4.hlsl");
  2711. }
  2712. TEST_F(CompilerTest, CodeGenEnum5) {
  2713. CodeGenTestCheck(L"..\\CodeGenHLSL\\enum5.hlsl");
  2714. }
  2715. TEST_F(CompilerTest, CodeGenEnum6) {
  2716. CodeGenTestCheck(L"..\\CodeGenHLSL\\enum6.hlsl");
  2717. }
  2718. TEST_F(CompilerTest, CodeGenEarlyDepthStencil) {
  2719. CodeGenTestCheck(L"..\\CodeGenHLSL\\earlyDepthStencil.hlsl");
  2720. }
  2721. TEST_F(CompilerTest, CodeGenEval) {
  2722. CodeGenTestCheck(L"..\\CodeGenHLSL\\eval.hlsl");
  2723. }
  2724. TEST_F(CompilerTest, CodeGenEvalInvalid) {
  2725. CodeGenTestCheck(L"..\\CodeGenHLSL\\evalInvalid.hlsl");
  2726. }
  2727. TEST_F(CompilerTest, CodeGenEvalMat) {
  2728. CodeGenTestCheck(L"..\\CodeGenHLSL\\evalMat.hlsl");
  2729. }
  2730. TEST_F(CompilerTest, CodeGenEvalMatMember) {
  2731. CodeGenTestCheck(L"..\\CodeGenHLSL\\evalMatMember.hlsl");
  2732. }
  2733. TEST_F(CompilerTest, CodeGenEvalPos) {
  2734. CodeGenTestCheck(L"..\\CodeGenHLSL\\evalPos.hlsl");
  2735. }
  2736. TEST_F(CompilerTest, CodeGenExternRes) {
  2737. CodeGenTestCheck(L"..\\CodeGenHLSL\\extern_res.hlsl");
  2738. }
  2739. TEST_F(CompilerTest, CodeGenExpandTrig) {
  2740. CodeGenTestCheck(L"expand_trig\\acos.hlsl");
  2741. CodeGenTestCheck(L"expand_trig\\acos_h.hlsl");
  2742. CodeGenTestCheck(L"expand_trig\\asin.hlsl");
  2743. CodeGenTestCheck(L"expand_trig\\asin_h.hlsl");
  2744. CodeGenTestCheck(L"expand_trig\\atan.hlsl");
  2745. CodeGenTestCheck(L"expand_trig\\atan_h.hlsl");
  2746. CodeGenTestCheck(L"expand_trig\\hcos.hlsl");
  2747. CodeGenTestCheck(L"expand_trig\\hcos_h.hlsl");
  2748. CodeGenTestCheck(L"expand_trig\\hsin.hlsl");
  2749. CodeGenTestCheck(L"expand_trig\\hsin_h.hlsl");
  2750. CodeGenTestCheck(L"expand_trig\\htan.hlsl");
  2751. CodeGenTestCheck(L"expand_trig\\htan_h.hlsl");
  2752. CodeGenTestCheck(L"expand_trig\\tan.hlsl");
  2753. CodeGenTestCheck(L"expand_trig\\keep_precise.0.hlsl");
  2754. CodeGenTestCheck(L"expand_trig\\keep_precise.1.hlsl");
  2755. }
  2756. TEST_F(CompilerTest, CodeGenFloatCast) {
  2757. CodeGenTestCheck(L"..\\CodeGenHLSL\\float_cast.hlsl");
  2758. }
  2759. TEST_F(CompilerTest, CodeGenFloatToBool) {
  2760. CodeGenTestCheck(L"..\\CodeGenHLSL\\float_to_bool.hlsl");
  2761. }
  2762. TEST_F(CompilerTest, CodeGenFirstbitHi) {
  2763. CodeGenTestCheck(L"..\\CodeGenHLSL\\firstbitHi.hlsl");
  2764. CodeGenTestCheck(L"..\\CodeGenHLSL\\firstbitshi_const.hlsl");
  2765. }
  2766. TEST_F(CompilerTest, CodeGenFirstbitLo) {
  2767. CodeGenTestCheck(L"..\\CodeGenHLSL\\firstbitLo.hlsl");
  2768. }
  2769. TEST_F(CompilerTest, CodeGenFloatMaxtessfactor) {
  2770. CodeGenTestCheck(L"..\\CodeGenHLSL\\FloatMaxtessfactorHs.hlsl");
  2771. }
  2772. TEST_F(CompilerTest, CodeGenFModPS) {
  2773. CodeGenTestCheck(L"..\\CodeGenHLSL\\fmodPS.hlsl");
  2774. }
  2775. TEST_F(CompilerTest, CodeGenFuncCast) {
  2776. CodeGenTestCheck(L"..\\CodeGenHLSL\\func_cast.hlsl");
  2777. }
  2778. TEST_F(CompilerTest, CodeGenFunctionalCast) {
  2779. CodeGenTestCheck(L"..\\CodeGenHLSL\\functionalCast.hlsl");
  2780. }
  2781. TEST_F(CompilerTest, CodeGenGather) {
  2782. CodeGenTestCheck(L"..\\CodeGenHLSL\\gather.hlsl");
  2783. }
  2784. TEST_F(CompilerTest, CodeGenGatherCmp) {
  2785. CodeGenTestCheck(L"..\\CodeGenHLSL\\gatherCmp.hlsl");
  2786. }
  2787. TEST_F(CompilerTest, CodeGenGatherCubeOffset) {
  2788. CodeGenTestCheck(L"..\\CodeGenHLSL\\gatherCubeOffset.hlsl");
  2789. }
  2790. TEST_F(CompilerTest, CodeGenGatherOffset) {
  2791. CodeGenTestCheck(L"..\\CodeGenHLSL\\gatherOffset.hlsl");
  2792. }
  2793. TEST_F(CompilerTest, CodeGenGepZeroIdx) {
  2794. CodeGenTestCheck(L"..\\CodeGenHLSL\\gep_zero_idx.hlsl");
  2795. }
  2796. TEST_F(CompilerTest, CodeGenGloballyCoherent) {
  2797. CodeGenTestCheck(L"..\\CodeGenHLSL\\globallycoherent.hlsl");
  2798. }
  2799. TEST_F(CompilerTest, CodeGenI32ColIdx) {
  2800. CodeGenTest(L"..\\CodeGenHLSL\\i32colIdx.hlsl");
  2801. }
  2802. TEST_F(CompilerTest, CodeGenIcb1) {
  2803. CodeGenTest(L"..\\CodeGenHLSL\\icb1.hlsl");
  2804. }
  2805. TEST_F(CompilerTest, CodeGenIf1) { CodeGenTestCheck(L"..\\CodeGenHLSL\\if1.hlsl"); }
  2806. TEST_F(CompilerTest, CodeGenIf2) { CodeGenTestCheck(L"..\\CodeGenHLSL\\if2.hlsl"); }
  2807. TEST_F(CompilerTest, CodeGenIf3) { CodeGenTest(L"..\\CodeGenHLSL\\if3.hlsl"); }
  2808. TEST_F(CompilerTest, CodeGenIf4) { CodeGenTest(L"..\\CodeGenHLSL\\if4.hlsl"); }
  2809. TEST_F(CompilerTest, CodeGenIf5) { CodeGenTest(L"..\\CodeGenHLSL\\if5.hlsl"); }
  2810. TEST_F(CompilerTest, CodeGenIf6) { CodeGenTest(L"..\\CodeGenHLSL\\if6.hlsl"); }
  2811. TEST_F(CompilerTest, CodeGenIf7) { CodeGenTest(L"..\\CodeGenHLSL\\if7.hlsl"); }
  2812. TEST_F(CompilerTest, CodeGenIf8) { CodeGenTest(L"..\\CodeGenHLSL\\if8.hlsl"); }
  2813. TEST_F(CompilerTest, CodeGenIf9) { CodeGenTestCheck(L"..\\CodeGenHLSL\\if9.hlsl"); }
  2814. TEST_F(CompilerTest, CodeGenImm0) {
  2815. CodeGenTestCheck(L"..\\CodeGenHLSL\\imm0.hlsl");
  2816. }
  2817. TEST_F(CompilerTest, CodeGenInclude) {
  2818. CodeGenTestCheck(L"..\\CodeGenHLSL\\Include.hlsl");
  2819. }
  2820. TEST_F(CompilerTest, CodeGenIncompletePos) {
  2821. CodeGenTestCheck(L"..\\CodeGenHLSL\\incompletePos.hlsl");
  2822. }
  2823. TEST_F(CompilerTest, CodeGenIndexableinput1) {
  2824. CodeGenTest(L"..\\CodeGenHLSL\\indexableinput1.hlsl");
  2825. }
  2826. TEST_F(CompilerTest, CodeGenIndexableinput2) {
  2827. CodeGenTest(L"..\\CodeGenHLSL\\indexableinput2.hlsl");
  2828. }
  2829. TEST_F(CompilerTest, CodeGenIndexableinput3) {
  2830. CodeGenTest(L"..\\CodeGenHLSL\\indexableinput3.hlsl");
  2831. }
  2832. TEST_F(CompilerTest, CodeGenIndexableinput4) {
  2833. CodeGenTest(L"..\\CodeGenHLSL\\indexableinput4.hlsl");
  2834. }
  2835. TEST_F(CompilerTest, CodeGenIndexableoutput1) {
  2836. CodeGenTest(L"..\\CodeGenHLSL\\indexableoutput1.hlsl");
  2837. }
  2838. TEST_F(CompilerTest, CodeGenIndexabletemp1) {
  2839. CodeGenTest(L"..\\CodeGenHLSL\\indexabletemp1.hlsl");
  2840. }
  2841. TEST_F(CompilerTest, CodeGenIndexabletemp2) {
  2842. CodeGenTest(L"..\\CodeGenHLSL\\indexabletemp2.hlsl");
  2843. }
  2844. TEST_F(CompilerTest, CodeGenIndexabletemp3) {
  2845. CodeGenTest(L"..\\CodeGenHLSL\\indexabletemp3.hlsl");
  2846. }
  2847. TEST_F(CompilerTest, CodeGenInitListType) {
  2848. CodeGenTestCheck(L"..\\CodeGenHLSL\\initlist_type.hlsl");
  2849. }
  2850. TEST_F(CompilerTest, CodeGenInoutSE) {
  2851. CodeGenTestCheck(L"..\\CodeGenHLSL\\inout_se.hlsl");
  2852. }
  2853. TEST_F(CompilerTest, CodeGenInout1) {
  2854. CodeGenTestCheck(L"..\\CodeGenHLSL\\inout1.hlsl");
  2855. }
  2856. TEST_F(CompilerTest, CodeGenInout2) {
  2857. CodeGenTestCheck(L"..\\CodeGenHLSL\\inout2.hlsl");
  2858. }
  2859. TEST_F(CompilerTest, CodeGenInout3) {
  2860. CodeGenTestCheck(L"..\\CodeGenHLSL\\inout3.hlsl");
  2861. }
  2862. TEST_F(CompilerTest, CodeGenInout4) {
  2863. CodeGenTestCheck(L"..\\CodeGenHLSL\\inout4.hlsl");
  2864. }
  2865. TEST_F(CompilerTest, CodeGenInout5) {
  2866. CodeGenTestCheck(L"..\\CodeGenHLSL\\inout5.hlsl");
  2867. }
  2868. TEST_F(CompilerTest, CodeGenInput1) {
  2869. CodeGenTestCheck(L"..\\CodeGenHLSL\\input1.hlsl");
  2870. }
  2871. TEST_F(CompilerTest, CodeGenInput2) {
  2872. CodeGenTest(L"..\\CodeGenHLSL\\input2.hlsl");
  2873. }
  2874. TEST_F(CompilerTest, CodeGenInput3) {
  2875. CodeGenTest(L"..\\CodeGenHLSL\\input3.hlsl");
  2876. }
  2877. TEST_F(CompilerTest, CodeGenIntrinsic1) {
  2878. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic1.hlsl");
  2879. }
  2880. TEST_F(CompilerTest, CodeGenIntrinsic2) {
  2881. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic2.hlsl");
  2882. }
  2883. TEST_F(CompilerTest, CodeGenIntrinsic3_even) {
  2884. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic3_even.hlsl");
  2885. }
  2886. TEST_F(CompilerTest, CodeGenIntrinsic3_integer) {
  2887. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic3_integer.hlsl");
  2888. }
  2889. TEST_F(CompilerTest, CodeGenIntrinsic3_odd) {
  2890. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic3_odd.hlsl");
  2891. }
  2892. TEST_F(CompilerTest, CodeGenIntrinsic3_pow2) {
  2893. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic3_pow2.hlsl");
  2894. }
  2895. TEST_F(CompilerTest, CodeGenIntrinsic4) {
  2896. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic4.hlsl");
  2897. }
  2898. TEST_F(CompilerTest, CodeGenIntrinsic4_dbg) {
  2899. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic4_dbg.hlsl");
  2900. }
  2901. TEST_F(CompilerTest, CodeGenIntrinsic5) {
  2902. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic5.hlsl");
  2903. }
  2904. TEST_F(CompilerTest, CodeGenInvalidInputOutputTypes) {
  2905. CodeGenTestCheck(L"..\\CodeGenHLSL\\invalid_input_output_types.hlsl");
  2906. }
  2907. TEST_F(CompilerTest, CodeGenLegacyStruct) {
  2908. CodeGenTestCheck(L"..\\CodeGenHLSL\\legacy_struct.hlsl");
  2909. }
  2910. TEST_F(CompilerTest, CodeGenLibCsEntry) {
  2911. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_cs_entry.hlsl");
  2912. }
  2913. TEST_F(CompilerTest, CodeGenLibCsEntry2) {
  2914. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_cs_entry2.hlsl");
  2915. }
  2916. TEST_F(CompilerTest, CodeGenLibCsEntry3) {
  2917. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_cs_entry3.hlsl");
  2918. }
  2919. TEST_F(CompilerTest, CodeGenLibEntries) {
  2920. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_entries.hlsl");
  2921. }
  2922. TEST_F(CompilerTest, CodeGenLibEntries2) {
  2923. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_entries2.hlsl");
  2924. }
  2925. TEST_F(CompilerTest, CodeGenLibNoAlias) {
  2926. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_no_alias.hlsl");
  2927. }
  2928. TEST_F(CompilerTest, CodeGenLibResource) {
  2929. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_resource.hlsl");
  2930. }
  2931. TEST_F(CompilerTest, CodeGenLibUnusedFunc) {
  2932. CodeGenTestCheck(L"..\\CodeGenHLSL\\lib_unused_func.hlsl");
  2933. }
  2934. TEST_F(CompilerTest, CodeGenLitInParen) {
  2935. CodeGenTestCheck(L"..\\CodeGenHLSL\\lit_in_paren.hlsl");
  2936. }
  2937. TEST_F(CompilerTest, CodeGenLiteralShift) {
  2938. CodeGenTestCheck(L"..\\CodeGenHLSL\\literalShift.hlsl");
  2939. }
  2940. TEST_F(CompilerTest, CodeGenLiveness1) {
  2941. CodeGenTest(L"..\\CodeGenHLSL\\liveness1.hlsl");
  2942. }
  2943. TEST_F(CompilerTest, CodeGenLoop1) {
  2944. CodeGenTestCheck(L"..\\CodeGenHLSL\\loop1.hlsl");
  2945. }
  2946. TEST_F(CompilerTest, CodeGenLocalRes1) {
  2947. CodeGenTestCheck(L"..\\CodeGenHLSL\\local_resource1.hlsl");
  2948. }
  2949. TEST_F(CompilerTest, CodeGenLocalRes4) {
  2950. CodeGenTestCheck(L"..\\CodeGenHLSL\\local_resource4.hlsl");
  2951. }
  2952. TEST_F(CompilerTest, CodeGenLocalRes7) {
  2953. CodeGenTestCheck(L"..\\CodeGenHLSL\\local_resource7.hlsl");
  2954. }
  2955. TEST_F(CompilerTest, CodeGenLocalRes7Dbg) {
  2956. CodeGenTestCheck(L"..\\CodeGenHLSL\\local_resource7_dbg.hlsl");
  2957. }
  2958. TEST_F(CompilerTest, CodeGenLoop2) {
  2959. CodeGenTestCheck(L"..\\CodeGenHLSL\\loop2.hlsl");
  2960. }
  2961. TEST_F(CompilerTest, CodeGenLoop3) {
  2962. CodeGenTestCheck(L"..\\CodeGenHLSL\\loop3.hlsl");
  2963. }
  2964. TEST_F(CompilerTest, CodeGenLoop4) {
  2965. CodeGenTest(L"..\\CodeGenHLSL\\loop4.hlsl");
  2966. }
  2967. TEST_F(CompilerTest, CodeGenLoop5) {
  2968. CodeGenTest(L"..\\CodeGenHLSL\\loop5.hlsl");
  2969. }
  2970. TEST_F(CompilerTest, CodeGenLoop6) {
  2971. CodeGenTestCheck(L"..\\CodeGenHLSL\\loop6.hlsl");
  2972. }
  2973. TEST_F(CompilerTest, CodeGenMatParam) {
  2974. CodeGenTestCheck(L"..\\CodeGenHLSL\\mat_param.hlsl");
  2975. }
  2976. TEST_F(CompilerTest, CodeGenMatParam2) {
  2977. CodeGenTestCheck(L"..\\CodeGenHLSL\\mat_param2.hlsl");
  2978. }
  2979. //TEST_F(CompilerTest, CodeGenMatParam3) {
  2980. // CodeGenTestCheck(L"..\\CodeGenHLSL\\mat_param3.hlsl");
  2981. //}
  2982. TEST_F(CompilerTest, CodeGenMatElt) {
  2983. CodeGenTestCheck(L"..\\CodeGenHLSL\\matElt.hlsl");
  2984. }
  2985. TEST_F(CompilerTest, CodeGenMatInit) {
  2986. CodeGenTest(L"..\\CodeGenHLSL\\matInit.hlsl");
  2987. }
  2988. TEST_F(CompilerTest, CodeGenMatMulMat) {
  2989. CodeGenTest(L"..\\CodeGenHLSL\\matMulMat.hlsl");
  2990. }
  2991. TEST_F(CompilerTest, CodeGenMatOps) {
  2992. // TODO: change to CodeGenTestCheck
  2993. CodeGenTest(L"..\\CodeGenHLSL\\matOps.hlsl");
  2994. }
  2995. TEST_F(CompilerTest, CodeGenMatInStruct) {
  2996. CodeGenTestCheck(L"..\\CodeGenHLSL\\matrix_in_struct.hlsl");
  2997. }
  2998. TEST_F(CompilerTest, CodeGenMatInStructRet) {
  2999. CodeGenTestCheck(L"..\\CodeGenHLSL\\matrix_in_struct_ret.hlsl");
  3000. }
  3001. TEST_F(CompilerTest, CodeGenMatIn) {
  3002. CodeGenTest(L"..\\CodeGenHLSL\\matrixIn.hlsl");
  3003. }
  3004. TEST_F(CompilerTest, CodeGenMatIn1) {
  3005. if (m_ver.SkipIRSensitiveTest()) return;
  3006. CodeGenTestCheck(L"..\\CodeGenHLSL\\matrixIn1.hlsl");
  3007. }
  3008. TEST_F(CompilerTest, CodeGenMatIn2) {
  3009. if (m_ver.SkipIRSensitiveTest()) return;
  3010. CodeGenTestCheck(L"..\\CodeGenHLSL\\matrixIn2.hlsl");
  3011. }
  3012. TEST_F(CompilerTest, CodeGenMatOut) {
  3013. CodeGenTest(L"..\\CodeGenHLSL\\matrixOut.hlsl");
  3014. }
  3015. TEST_F(CompilerTest, CodeGenMatOut1) {
  3016. CodeGenTestCheck(L"..\\CodeGenHLSL\\matrixOut1.hlsl");
  3017. }
  3018. TEST_F(CompilerTest, CodeGenMatOut2) {
  3019. CodeGenTestCheck(L"..\\CodeGenHLSL\\matrixOut2.hlsl");
  3020. }
  3021. TEST_F(CompilerTest, CodeGenMatSubscript) {
  3022. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript.hlsl");
  3023. }
  3024. TEST_F(CompilerTest, CodeGenMatSubscript2) {
  3025. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript2.hlsl");
  3026. }
  3027. TEST_F(CompilerTest, CodeGenMatSubscript3) {
  3028. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript3.hlsl");
  3029. }
  3030. TEST_F(CompilerTest, CodeGenMatSubscript4) {
  3031. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript4.hlsl");
  3032. }
  3033. TEST_F(CompilerTest, CodeGenMatSubscript5) {
  3034. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript5.hlsl");
  3035. }
  3036. TEST_F(CompilerTest, CodeGenMatSubscript6) {
  3037. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript6.hlsl");
  3038. }
  3039. TEST_F(CompilerTest, CodeGenMatSubscript7) {
  3040. CodeGenTestCheck(L"..\\CodeGenHLSL\\matSubscript7.hlsl");
  3041. }
  3042. TEST_F(CompilerTest, CodeGenMaxMin) {
  3043. CodeGenTestCheck(L"..\\CodeGenHLSL\\max_min.hlsl");
  3044. }
  3045. TEST_F(CompilerTest, CodeGenMinprec1) {
  3046. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec1.hlsl");
  3047. }
  3048. TEST_F(CompilerTest, CodeGenMinprec2) {
  3049. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec2.hlsl");
  3050. }
  3051. TEST_F(CompilerTest, CodeGenMinprec3) {
  3052. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec3.hlsl");
  3053. }
  3054. TEST_F(CompilerTest, CodeGenMinprec4) {
  3055. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec4.hlsl");
  3056. }
  3057. TEST_F(CompilerTest, CodeGenMinprec5) {
  3058. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec5.hlsl");
  3059. }
  3060. TEST_F(CompilerTest, CodeGenMinprec6) {
  3061. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec6.hlsl");
  3062. }
  3063. TEST_F(CompilerTest, CodeGenMinprec7) {
  3064. CodeGenTestCheck(L"..\\CodeGenHLSL\\minprec7.hlsl");
  3065. }
  3066. TEST_F(CompilerTest, CodeGenModf) {
  3067. CodeGenTestCheck(L"..\\CodeGenHLSL\\modf.hlsl");
  3068. }
  3069. TEST_F(CompilerTest, CodeGenMinprecCast) {
  3070. CodeGenTest(L"..\\CodeGenHLSL\\minprec_cast.hlsl");
  3071. }
  3072. TEST_F(CompilerTest, CodeGenMultiUAVLoad1) {
  3073. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad1.hlsl");
  3074. }
  3075. TEST_F(CompilerTest, CodeGenMultiUAVLoad2) {
  3076. if (m_ver.SkipDxilVersion(1,1)) return;
  3077. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad2.hlsl");
  3078. }
  3079. TEST_F(CompilerTest, CodeGenMultiUAVLoad3) {
  3080. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad3.hlsl");
  3081. }
  3082. TEST_F(CompilerTest, CodeGenMultiUAVLoad4) {
  3083. if (m_ver.SkipDxilVersion(1,1)) return;
  3084. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad4.hlsl");
  3085. }
  3086. TEST_F(CompilerTest, CodeGenMultiUAVLoad5) {
  3087. if (m_ver.SkipDxilVersion(1,1)) return;
  3088. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad5.hlsl");
  3089. }
  3090. TEST_F(CompilerTest, CodeGenMultiUAVLoad6) {
  3091. if (m_ver.SkipDxilVersion(1,1)) return;
  3092. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad6.hlsl");
  3093. }
  3094. TEST_F(CompilerTest, CodeGenMultiUAVLoad7) {
  3095. if (m_ver.SkipDxilVersion(1,1)) return;
  3096. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiUAVLoad7.hlsl");
  3097. }
  3098. TEST_F(CompilerTest, CodeGenMultiStream) {
  3099. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiStreamGS.hlsl");
  3100. }
  3101. TEST_F(CompilerTest, CodeGenMultiStream2) {
  3102. CodeGenTestCheck(L"..\\CodeGenHLSL\\multiStreamGS2.hlsl");
  3103. }
  3104. TEST_F(CompilerTest, CodeGenNeg1) {
  3105. CodeGenTest(L"..\\CodeGenHLSL\\neg1.hlsl");
  3106. }
  3107. TEST_F(CompilerTest, CodeGenNeg2) {
  3108. CodeGenTest(L"..\\CodeGenHLSL\\neg2.hlsl");
  3109. }
  3110. TEST_F(CompilerTest, CodeGenNegabs1) {
  3111. CodeGenTest(L"..\\CodeGenHLSL\\negabs1.hlsl");
  3112. }
  3113. TEST_F(CompilerTest, CodeGenNoise) {
  3114. CodeGenTestCheck(L"..\\CodeGenHLSL\\noise.hlsl");
  3115. }
  3116. TEST_F(CompilerTest, CodeGenNonUniform) {
  3117. CodeGenTestCheck(L"..\\CodeGenHLSL\\NonUniform.hlsl");
  3118. }
  3119. TEST_F(CompilerTest, CodeGenOptForNoOpt) {
  3120. CodeGenTestCheck(L"..\\CodeGenHLSL\\optForNoOpt.hlsl");
  3121. }
  3122. TEST_F(CompilerTest, CodeGenOptForNoOpt2) {
  3123. CodeGenTestCheck(L"..\\CodeGenHLSL\\optForNoOpt2.hlsl");
  3124. }
  3125. TEST_F(CompilerTest, CodeGenOptionGis) {
  3126. CodeGenTestCheck(L"..\\CodeGenHLSL\\option_gis.hlsl");
  3127. }
  3128. TEST_F(CompilerTest, CodeGenOptionWX) {
  3129. CodeGenTestCheck(L"..\\CodeGenHLSL\\option_WX.hlsl");
  3130. }
  3131. TEST_F(CompilerTest, CodeGenOutput1) {
  3132. CodeGenTestCheck(L"..\\CodeGenHLSL\\output1.hlsl");
  3133. }
  3134. TEST_F(CompilerTest, CodeGenOutput2) {
  3135. CodeGenTestCheck(L"..\\CodeGenHLSL\\output2.hlsl");
  3136. }
  3137. TEST_F(CompilerTest, CodeGenOutput3) {
  3138. CodeGenTestCheck(L"..\\CodeGenHLSL\\output3.hlsl");
  3139. }
  3140. TEST_F(CompilerTest, CodeGenOutput4) {
  3141. CodeGenTestCheck(L"..\\CodeGenHLSL\\output4.hlsl");
  3142. }
  3143. TEST_F(CompilerTest, CodeGenOutput5) {
  3144. CodeGenTestCheck(L"..\\CodeGenHLSL\\output5.hlsl");
  3145. }
  3146. TEST_F(CompilerTest, CodeGenOutput6) {
  3147. CodeGenTestCheck(L"..\\CodeGenHLSL\\output6.hlsl");
  3148. }
  3149. TEST_F(CompilerTest, CodeGenOutputArray) {
  3150. CodeGenTestCheck(L"..\\CodeGenHLSL\\outputArray.hlsl");
  3151. }
  3152. TEST_F(CompilerTest, CodeGenPassthrough1) {
  3153. CodeGenTest(L"..\\CodeGenHLSL\\passthrough1.hlsl");
  3154. }
  3155. TEST_F(CompilerTest, CodeGenPassthrough2) {
  3156. CodeGenTest(L"..\\CodeGenHLSL\\passthrough2.hlsl");
  3157. }
  3158. TEST_F(CompilerTest, CodeGenPrecise1) {
  3159. CodeGenTestCheck(L"..\\CodeGenHLSL\\precise1.hlsl");
  3160. }
  3161. TEST_F(CompilerTest, CodeGenPrecise2) {
  3162. CodeGenTestCheck(L"..\\CodeGenHLSL\\precise2.hlsl");
  3163. }
  3164. TEST_F(CompilerTest, CodeGenPrecise3) {
  3165. CodeGenTestCheck(L"..\\CodeGenHLSL\\precise3.hlsl");
  3166. }
  3167. TEST_F(CompilerTest, CodeGenPrecise4) {
  3168. CodeGenTestCheck(L"..\\CodeGenHLSL\\precise4.hlsl");
  3169. }
  3170. TEST_F(CompilerTest, CodeGenPreciseOnCall) {
  3171. CodeGenTestCheck(L"..\\CodeGenHLSL\\precise_call.hlsl");
  3172. }
  3173. TEST_F(CompilerTest, CodeGenPreciseOnCallNot) {
  3174. CodeGenTestCheck(L"..\\CodeGenHLSL\\precise_call_not.hlsl");
  3175. }
  3176. TEST_F(CompilerTest, CodeGenPreserveAllOutputs) {
  3177. CodeGenTestCheck(L"preserve_all_outputs_1.hlsl");
  3178. CodeGenTestCheck(L"preserve_all_outputs_2.hlsl");
  3179. CodeGenTestCheck(L"preserve_all_outputs_3.hlsl");
  3180. CodeGenTestCheck(L"preserve_all_outputs_4.hlsl");
  3181. CodeGenTestCheck(L"preserve_all_outputs_5.hlsl");
  3182. CodeGenTestCheck(L"preserve_all_outputs_6.hlsl");
  3183. CodeGenTestCheck(L"preserve_all_outputs_7.hlsl");
  3184. }
  3185. TEST_F(CompilerTest, CodeGenRaceCond2) {
  3186. CodeGenTest(L"..\\CodeGenHLSL\\RaceCond2.hlsl");
  3187. }
  3188. TEST_F(CompilerTest, CodeGenRaw_Buf1) {
  3189. CodeGenTest(L"..\\CodeGenHLSL\\raw_buf1.hlsl");
  3190. }
  3191. TEST_F(CompilerTest, CodeGenRcp1) {
  3192. CodeGenTest(L"..\\CodeGenHLSL\\rcp1.hlsl");
  3193. }
  3194. TEST_F(CompilerTest, CodeGenReadFromOutput) {
  3195. CodeGenTestCheck(L"..\\CodeGenHLSL\\readFromOutput.hlsl");
  3196. }
  3197. TEST_F(CompilerTest, CodeGenReadFromOutput2) {
  3198. CodeGenTestCheck(L"..\\CodeGenHLSL\\readFromOutput2.hlsl");
  3199. }
  3200. TEST_F(CompilerTest, CodeGenReadFromOutput3) {
  3201. CodeGenTestCheck(L"..\\CodeGenHLSL\\readFromOutput3.hlsl");
  3202. }
  3203. TEST_F(CompilerTest, CodeGenRedundantinput1) {
  3204. CodeGenTest(L"..\\CodeGenHLSL\\redundantinput1.hlsl");
  3205. }
  3206. TEST_F(CompilerTest, CodeGenRes64bit) {
  3207. CodeGenTestCheck(L"..\\CodeGenHLSL\\res64bit.hlsl");
  3208. }
  3209. TEST_F(CompilerTest, CodeGenRovs) {
  3210. CodeGenTestCheck(L"..\\CodeGenHLSL\\rovs.hlsl");
  3211. }
  3212. TEST_F(CompilerTest, CodeGenRValAssign) {
  3213. CodeGenTestCheck(L"..\\CodeGenHLSL\\rval_assign.hlsl");
  3214. }
  3215. TEST_F(CompilerTest, CodeGenRValSubscript) {
  3216. CodeGenTestCheck(L"..\\CodeGenHLSL\\RValSubscript.hlsl");
  3217. }
  3218. TEST_F(CompilerTest, CodeGenSample1) {
  3219. CodeGenTestCheck(L"..\\CodeGenHLSL\\sample1.hlsl");
  3220. }
  3221. TEST_F(CompilerTest, CodeGenSample2) {
  3222. CodeGenTest(L"..\\CodeGenHLSL\\sample2.hlsl");
  3223. }
  3224. TEST_F(CompilerTest, CodeGenSample3) {
  3225. CodeGenTest(L"..\\CodeGenHLSL\\sample3.hlsl");
  3226. }
  3227. TEST_F(CompilerTest, CodeGenSample4) {
  3228. CodeGenTest(L"..\\CodeGenHLSL\\sample4.hlsl");
  3229. }
  3230. TEST_F(CompilerTest, CodeGenSample5) {
  3231. CodeGenTest(L"..\\CodeGenHLSL\\sample5.hlsl");
  3232. }
  3233. TEST_F(CompilerTest, CodeGenSampleBias) {
  3234. CodeGenTestCheck(L"..\\CodeGenHLSL\\sampleBias.hlsl");
  3235. }
  3236. TEST_F(CompilerTest, CodeGenSampleCmp) {
  3237. CodeGenTestCheck(L"..\\CodeGenHLSL\\sampleCmp.hlsl");
  3238. }
  3239. TEST_F(CompilerTest, CodeGenSampleCmpLZ) {
  3240. CodeGenTestCheck(L"..\\CodeGenHLSL\\sampleCmpLZ.hlsl");
  3241. }
  3242. TEST_F(CompilerTest, CodeGenSampleCmpLZ2) {
  3243. CodeGenTestCheck(L"..\\CodeGenHLSL\\sampleCmpLZ2.hlsl");
  3244. }
  3245. TEST_F(CompilerTest, CodeGenSampleGrad) {
  3246. CodeGenTestCheck(L"..\\CodeGenHLSL\\sampleGrad.hlsl");
  3247. }
  3248. TEST_F(CompilerTest, CodeGenSampleL) {
  3249. CodeGenTestCheck(L"..\\CodeGenHLSL\\sampleL.hlsl");
  3250. }
  3251. TEST_F(CompilerTest, CodeGenSaturate1) {
  3252. CodeGenTest(L"..\\CodeGenHLSL\\saturate1.hlsl");
  3253. }
  3254. TEST_F(CompilerTest, CodeGenScalarOnVecIntrinsic) {
  3255. CodeGenTest(L"..\\CodeGenHLSL\\scalarOnVecIntrisic.hlsl");
  3256. }
  3257. TEST_F(CompilerTest, CodeGenScalarToVec) {
  3258. CodeGenTest(L"..\\CodeGenHLSL\\scalarToVec.hlsl");
  3259. }
  3260. TEST_F(CompilerTest, CodeGenSelectObj) {
  3261. CodeGenTestCheck(L"..\\CodeGenHLSL\\selectObj.hlsl");
  3262. }
  3263. TEST_F(CompilerTest, CodeGenSelectObj2) {
  3264. CodeGenTestCheck(L"..\\CodeGenHLSL\\selectObj2.hlsl");
  3265. }
  3266. TEST_F(CompilerTest, CodeGenSelectObj3) {
  3267. CodeGenTestCheck(L"..\\CodeGenHLSL\\selectObj3.hlsl");
  3268. }
  3269. TEST_F(CompilerTest, CodeGenSelectObj4) {
  3270. CodeGenTestCheck(L"..\\CodeGenHLSL\\selectObj4.hlsl");
  3271. }
  3272. TEST_F(CompilerTest, CodeGenSelectObj5) {
  3273. CodeGenTestCheck(L"..\\CodeGenHLSL\\selectObj5.hlsl");
  3274. }
  3275. TEST_F(CompilerTest, CodeGenSelfCopy) {
  3276. CodeGenTest(L"..\\CodeGenHLSL\\self_copy.hlsl");
  3277. }
  3278. TEST_F(CompilerTest, CodeGenSelMat) {
  3279. CodeGenTestCheck(L"..\\CodeGenHLSL\\selMat.hlsl");
  3280. }
  3281. TEST_F(CompilerTest, CodeGenShaderAttr) {
  3282. CodeGenTestCheck(L"..\\CodeGenHLSL\\shader_attr.hlsl");
  3283. }
  3284. TEST_F(CompilerTest, CodeGenShare_Mem_Dbg) {
  3285. CodeGenTestCheck(L"..\\CodeGenHLSL\\share_mem_dbg.hlsl");
  3286. }
  3287. TEST_F(CompilerTest, CodeGenShare_Mem_Phi) {
  3288. CodeGenTestCheck(L"..\\CodeGenHLSL\\share_mem_phi.hlsl");
  3289. }
  3290. TEST_F(CompilerTest, CodeGenShare_Mem1) {
  3291. CodeGenTestCheck(L"..\\CodeGenHLSL\\share_mem1.hlsl");
  3292. }
  3293. TEST_F(CompilerTest, CodeGenShare_Mem2) {
  3294. CodeGenTestCheck(L"..\\CodeGenHLSL\\share_mem2.hlsl");
  3295. }
  3296. TEST_F(CompilerTest, CodeGenShare_Mem2Dim) {
  3297. CodeGenTestCheck(L"..\\CodeGenHLSL\\share_mem2Dim.hlsl");
  3298. }
  3299. TEST_F(CompilerTest, CodeGenShift) {
  3300. CodeGenTestCheck(L"..\\CodeGenHLSL\\shift.hlsl");
  3301. }
  3302. TEST_F(CompilerTest, CodeGenShortCircuiting0) {
  3303. CodeGenTestCheck(L"..\\CodeGenHLSL\\short_circuiting0.hlsl");
  3304. }
  3305. TEST_F(CompilerTest, CodeGenShortCircuiting1) {
  3306. CodeGenTestCheck(L"..\\CodeGenHLSL\\short_circuiting1.hlsl");
  3307. }
  3308. TEST_F(CompilerTest, CodeGenShortCircuiting2) {
  3309. CodeGenTestCheck(L"..\\CodeGenHLSL\\short_circuiting2.hlsl");
  3310. }
  3311. TEST_F(CompilerTest, CodeGenShortCircuiting3) {
  3312. CodeGenTestCheck(L"..\\CodeGenHLSL\\short_circuiting3.hlsl");
  3313. }
  3314. TEST_F(CompilerTest, CodeGenSimpleDS1) {
  3315. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleDS1.hlsl");
  3316. }
  3317. TEST_F(CompilerTest, CodeGenSimpleGS1) {
  3318. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS1.hlsl");
  3319. }
  3320. TEST_F(CompilerTest, CodeGenSimpleGS2) {
  3321. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS2.hlsl");
  3322. }
  3323. TEST_F(CompilerTest, CodeGenSimpleGS3) {
  3324. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS3.hlsl");
  3325. }
  3326. TEST_F(CompilerTest, CodeGenSimpleGS4) {
  3327. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS4.hlsl");
  3328. }
  3329. TEST_F(CompilerTest, CodeGenSimpleGS5) {
  3330. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS5.hlsl");
  3331. }
  3332. TEST_F(CompilerTest, CodeGenSimpleGS6) {
  3333. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS6.hlsl");
  3334. }
  3335. TEST_F(CompilerTest, CodeGenSimpleGS7) {
  3336. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS7.hlsl");
  3337. }
  3338. TEST_F(CompilerTest, CodeGenSimpleGS11) {
  3339. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS11.hlsl");
  3340. }
  3341. TEST_F(CompilerTest, CodeGenSimpleGS12) {
  3342. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleGS12.hlsl");
  3343. }
  3344. TEST_F(CompilerTest, CodeGenSimpleHS1) {
  3345. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS1.hlsl");
  3346. }
  3347. TEST_F(CompilerTest, CodeGenSimpleHS2) {
  3348. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS2.hlsl");
  3349. }
  3350. TEST_F(CompilerTest, CodeGenSimpleHS3) {
  3351. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS3.hlsl");
  3352. }
  3353. TEST_F(CompilerTest, CodeGenSimpleHS4) {
  3354. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS4.hlsl");
  3355. }
  3356. TEST_F(CompilerTest, CodeGenSimpleHS5) {
  3357. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS5.hlsl");
  3358. }
  3359. TEST_F(CompilerTest, CodeGenSimpleHS6) {
  3360. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS6.hlsl");
  3361. }
  3362. TEST_F(CompilerTest, CodeGenSimpleHS7) {
  3363. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS7.hlsl");
  3364. }
  3365. TEST_F(CompilerTest, CodeGenSimpleHS8) {
  3366. CodeGenTestCheck(L"..\\CodeGenHLSL\\SimpleHS8.hlsl");
  3367. }
  3368. TEST_F(CompilerTest, CodeGenSMFail) {
  3369. CodeGenTestCheck(L"sm-fail.hlsl");
  3370. }
  3371. TEST_F(CompilerTest, CodeGenSrv_Ms_Load1) {
  3372. CodeGenTestCheck(L"..\\CodeGenHLSL\\srv_ms_load1.hlsl");
  3373. }
  3374. TEST_F(CompilerTest, CodeGenSrv_Ms_Load2) {
  3375. CodeGenTestCheck(L"..\\CodeGenHLSL\\srv_ms_load2.hlsl");
  3376. }
  3377. TEST_F(CompilerTest, CodeGenSrv_Typed_Load1) {
  3378. CodeGenTest(L"..\\CodeGenHLSL\\srv_typed_load1.hlsl");
  3379. }
  3380. TEST_F(CompilerTest, CodeGenSrv_Typed_Load2) {
  3381. CodeGenTest(L"..\\CodeGenHLSL\\srv_typed_load2.hlsl");
  3382. }
  3383. TEST_F(CompilerTest, CodeGenStaticConstGlobal) {
  3384. CodeGenTestCheck(L"..\\CodeGenHLSL\\static_const_global.hlsl");
  3385. }
  3386. TEST_F(CompilerTest, CodeGenStaticConstGlobal2) {
  3387. CodeGenTestCheck(L"..\\CodeGenHLSL\\static_const_global2.hlsl");
  3388. }
  3389. TEST_F(CompilerTest, CodeGenStaticGlobals) {
  3390. CodeGenTestCheck(L"..\\CodeGenHLSL\\staticGlobals.hlsl");
  3391. }
  3392. TEST_F(CompilerTest, CodeGenStaticGlobals2) {
  3393. CodeGenTest(L"..\\CodeGenHLSL\\staticGlobals2.hlsl");
  3394. }
  3395. TEST_F(CompilerTest, CodeGenStaticGlobals3) {
  3396. CodeGenTestCheck(L"..\\CodeGenHLSL\\staticGlobals3.hlsl");
  3397. }
  3398. TEST_F(CompilerTest, CodeGenStaticGlobals4) {
  3399. CodeGenTest(L"..\\CodeGenHLSL\\staticGlobals4.hlsl");
  3400. }
  3401. TEST_F(CompilerTest, CodeGenStaticMatrix) {
  3402. CodeGenTestCheck(L"..\\CodeGenHLSL\\static_matrix.hlsl");
  3403. }
  3404. TEST_F(CompilerTest, CodeGenStaticResource) {
  3405. CodeGenTest(L"..\\CodeGenHLSL\\static_resource.hlsl");
  3406. }
  3407. TEST_F(CompilerTest, CodeGenStaticResource2) {
  3408. CodeGenTest(L"..\\CodeGenHLSL\\static_resource2.hlsl");
  3409. }
  3410. TEST_F(CompilerTest, CodeGenStruct_Buf1) {
  3411. CodeGenTest(L"..\\CodeGenHLSL\\struct_buf1.hlsl");
  3412. }
  3413. TEST_F(CompilerTest, CodeGenStruct_BufHasCounter) {
  3414. CodeGenTestCheck(L"..\\CodeGenHLSL\\struct_bufHasCounter.hlsl");
  3415. }
  3416. TEST_F(CompilerTest, CodeGenStruct_BufHasCounter2) {
  3417. CodeGenTestCheck(L"..\\CodeGenHLSL\\struct_bufHasCounter2.hlsl");
  3418. }
  3419. TEST_F(CompilerTest, CodeGenStructArray) {
  3420. CodeGenTest(L"..\\CodeGenHLSL\\structArray.hlsl");
  3421. }
  3422. TEST_F(CompilerTest, CodeGenStructCast) {
  3423. CodeGenTest(L"..\\CodeGenHLSL\\StructCast.hlsl");
  3424. }
  3425. TEST_F(CompilerTest, CodeGenStructCast2) {
  3426. CodeGenTest(L"..\\CodeGenHLSL\\StructCast2.hlsl");
  3427. }
  3428. TEST_F(CompilerTest, CodeGenStructInBuffer) {
  3429. CodeGenTest(L"..\\CodeGenHLSL\\structInBuffer.hlsl");
  3430. }
  3431. TEST_F(CompilerTest, CodeGenStructInBuffer2) {
  3432. CodeGenTest(L"..\\CodeGenHLSL\\structInBuffer2.hlsl");
  3433. }
  3434. TEST_F(CompilerTest, CodeGenStructInBuffer3) {
  3435. CodeGenTestCheck(L"..\\CodeGenHLSL\\structInBuffer3.hlsl");
  3436. }
  3437. TEST_F(CompilerTest, CodeGenSwitchFloat) {
  3438. CodeGenTestCheck(L"..\\CodeGenHLSL\\switch_float.hlsl");
  3439. }
  3440. TEST_F(CompilerTest, CodeGenSwitch1) {
  3441. CodeGenTestCheck(L"..\\CodeGenHLSL\\switch1.hlsl");
  3442. }
  3443. TEST_F(CompilerTest, CodeGenSwitch2) {
  3444. CodeGenTest(L"..\\CodeGenHLSL\\switch2.hlsl");
  3445. }
  3446. TEST_F(CompilerTest, CodeGenSwitch3) {
  3447. CodeGenTest(L"..\\CodeGenHLSL\\switch3.hlsl");
  3448. }
  3449. TEST_F(CompilerTest, CodeGenSwizzle1) {
  3450. CodeGenTest(L"..\\CodeGenHLSL\\swizzle1.hlsl");
  3451. }
  3452. TEST_F(CompilerTest, CodeGenSwizzle2) {
  3453. CodeGenTest(L"..\\CodeGenHLSL\\swizzle2.hlsl");
  3454. }
  3455. TEST_F(CompilerTest, CodeGenSwizzleAtomic) {
  3456. CodeGenTestCheck(L"..\\CodeGenHLSL\\swizzleAtomic.hlsl");
  3457. }
  3458. TEST_F(CompilerTest, CodeGenSwizzleAtomic2) {
  3459. CodeGenTestCheck(L"..\\CodeGenHLSL\\swizzleAtomic2.hlsl");
  3460. }
  3461. TEST_F(CompilerTest, CodeGenSwizzleIndexing) {
  3462. CodeGenTestCheck(L"..\\CodeGenHLSL\\swizzleIndexing.hlsl");
  3463. }
  3464. TEST_F(CompilerTest, CodeGenTemp1) {
  3465. CodeGenTest(L"..\\CodeGenHLSL\\temp1.hlsl");
  3466. }
  3467. TEST_F(CompilerTest, CodeGenTemp2) {
  3468. CodeGenTest(L"..\\CodeGenHLSL\\temp2.hlsl");
  3469. }
  3470. TEST_F(CompilerTest, CodeGenTempDbgInfo) {
  3471. CodeGenTestCheck(L"..\\CodeGenHLSL\\temp_dbg_info.hlsl");
  3472. }
  3473. TEST_F(CompilerTest, CodeGenTexSubscript) {
  3474. CodeGenTestCheck(L"..\\CodeGenHLSL\\TexSubscript.hlsl");
  3475. }
  3476. TEST_F(CompilerTest, CodeGenUav_Raw1){
  3477. CodeGenTestCheck(L"..\\CodeGenHLSL\\uav_raw1.hlsl");
  3478. }
  3479. TEST_F(CompilerTest, CodeGenUav_Typed_Load_Store1) {
  3480. CodeGenTest(L"..\\CodeGenHLSL\\uav_typed_load_store1.hlsl");
  3481. }
  3482. TEST_F(CompilerTest, CodeGenUav_Typed_Load_Store2) {
  3483. CodeGenTest(L"..\\CodeGenHLSL\\uav_typed_load_store2.hlsl");
  3484. }
  3485. TEST_F(CompilerTest, CodeGenUint64_1) {
  3486. CodeGenTestCheck(L"..\\CodeGenHLSL\\uint64_1.hlsl");
  3487. }
  3488. TEST_F(CompilerTest, CodeGenUint64_2) {
  3489. if (m_ver.SkipDxilVersion(1,1)) return;
  3490. CodeGenTestCheck(L"..\\CodeGenHLSL\\uint64_2.hlsl");
  3491. }
  3492. TEST_F(CompilerTest, CodeGenUintSample) {
  3493. CodeGenTestCheck(L"..\\CodeGenHLSL\\uintSample.hlsl");
  3494. }
  3495. TEST_F(CompilerTest, CodeGenUmaxObjectAtomic) {
  3496. CodeGenTestCheck(L"..\\CodeGenHLSL\\umaxObjectAtomic.hlsl");
  3497. }
  3498. TEST_F(CompilerTest, CodeGenUnrollDbg) {
  3499. CodeGenTest(L"..\\CodeGenHLSL\\unroll_dbg.hlsl");
  3500. }
  3501. TEST_F(CompilerTest, CodeGenUnsignedShortHandMatrixVector) {
  3502. CodeGenTestCheck(L"..\\CodeGenHLSL\\unsignedShortHandMatrixVector.hlsl");
  3503. }
  3504. TEST_F(CompilerTest, CodeGenUnusedFunc) {
  3505. CodeGenTestCheck(L"..\\CodeGenHLSL\\unused_func.hlsl");
  3506. }
  3507. TEST_F(CompilerTest, CodeGenUnusedCB) {
  3508. CodeGenTestCheck(L"..\\CodeGenHLSL\\unusedCB.hlsl");
  3509. }
  3510. TEST_F(CompilerTest, CodeGenUpdateCounter) {
  3511. CodeGenTestCheck(L"..\\CodeGenHLSL\\updateCounter.hlsl");
  3512. }
  3513. TEST_F(CompilerTest, CodeGenUpperCaseRegister1) {
  3514. CodeGenTestCheck(L"..\\CodeGenHLSL\\uppercase-register1.hlsl");
  3515. }
  3516. TEST_F(CompilerTest, CodeGenVcmp) {
  3517. CodeGenTestCheck(L"..\\CodeGenHLSL\\vcmp.hlsl");
  3518. }
  3519. TEST_F(CompilerTest, CodeGenVecBitCast) {
  3520. CodeGenTest(L"..\\CodeGenHLSL\\vec_bitcast.hlsl");
  3521. }
  3522. TEST_F(CompilerTest, CodeGenVec_Comp_Arg){
  3523. CodeGenTest(L"..\\CodeGenHLSL\\vec_comp_arg.hlsl");
  3524. }
  3525. TEST_F(CompilerTest, CodeGenVecCmpCond) {
  3526. CodeGenTestCheck(L"..\\CodeGenHLSL\\vecCmpCond.hlsl");
  3527. }
  3528. TEST_F(CompilerTest, CodeGenVecTrunc) {
  3529. CodeGenTestCheck(L"..\\CodeGenHLSL\\vecTrunc.hlsl");
  3530. }
  3531. TEST_F(CompilerTest, CodeGenWave) {
  3532. CodeGenTestCheck(L"..\\CodeGenHLSL\\wave.hlsl");
  3533. }
  3534. TEST_F(CompilerTest, CodeGenWaveNoOpt) {
  3535. CodeGenTestCheck(L"..\\CodeGenHLSL\\wave_no_opt.hlsl");
  3536. }
  3537. TEST_F(CompilerTest, CodeGenWriteMaskBuf) {
  3538. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeMaskBuf.hlsl");
  3539. }
  3540. TEST_F(CompilerTest, CodeGenWriteMaskBuf2) {
  3541. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeMaskBuf2.hlsl");
  3542. }
  3543. TEST_F(CompilerTest, CodeGenWriteMaskBuf3) {
  3544. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeMaskBuf3.hlsl");
  3545. }
  3546. TEST_F(CompilerTest, CodeGenWriteMaskBuf4) {
  3547. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeMaskBuf4.hlsl");
  3548. }
  3549. TEST_F(CompilerTest, CodeGenWriteToInput) {
  3550. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeToInput.hlsl");
  3551. }
  3552. TEST_F(CompilerTest, CodeGenWriteToInput2) {
  3553. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeToInput2.hlsl");
  3554. }
  3555. TEST_F(CompilerTest, CodeGenWriteToInput3) {
  3556. CodeGenTestCheck(L"..\\CodeGenHLSL\\writeToInput3.hlsl");
  3557. }
  3558. TEST_F(CompilerTest, CodeGenAttributes_Mod) {
  3559. CodeGenTest(L"..\\CodeGenHLSL\\attributes_Mod.hlsl");
  3560. }
  3561. TEST_F(CompilerTest, CodeGenConst_Exprb_Mod) {
  3562. CodeGenTest(L"..\\CodeGenHLSL\\const-exprB_Mod.hlsl");
  3563. }
  3564. TEST_F(CompilerTest, CodeGenConst_Expr_Mod) {
  3565. CodeGenTest(L"..\\CodeGenHLSL\\const-expr_Mod.hlsl");
  3566. }
  3567. TEST_F(CompilerTest, CodeGenFunctions_Mod){
  3568. CodeGenTest(L"..\\CodeGenHLSL\\functions_Mod.hlsl");
  3569. }
  3570. TEST_F(CompilerTest, CodeGenImplicit_Casts_Mod) {
  3571. CodeGenTest(L"..\\CodeGenHLSL\\implicit-casts_Mod.hlsl");
  3572. }
  3573. TEST_F(CompilerTest, CodeGenIndexing_Operator_Mod) {
  3574. CodeGenTest(L"..\\CodeGenHLSL\\indexing-operator_Mod.hlsl");
  3575. }
  3576. TEST_F(CompilerTest, CodeGenIntrinsic_Examples_Mod) {
  3577. CodeGenTestCheck(L"..\\CodeGenHLSL\\intrinsic-examples_Mod.hlsl");
  3578. }
  3579. TEST_F(CompilerTest, CodeGenLiterals_Mod) {
  3580. CodeGenTest(L"..\\CodeGenHLSL\\literals_Mod.hlsl");
  3581. }
  3582. TEST_F(CompilerTest, CodeGenMatrix_Assignments_Mod) {
  3583. CodeGenTest(L"..\\CodeGenHLSL\\matrix-assignments_Mod.hlsl");
  3584. }
  3585. TEST_F(CompilerTest, CodeGenMatrix_Syntax_Mod) {
  3586. CodeGenTest(L"..\\CodeGenHLSL\\matrix-syntax_Mod.hlsl");
  3587. }
  3588. //TEST_F(CompilerTest, CodeGenMore_Operators_Mod){
  3589. // CodeGenTest(L"..\\CodeGenHLSL\\more-operators_Mod.hlsl");
  3590. //}
  3591. // TODO: enable this after support local/parameter resource.
  3592. //TEST_F(CompilerTest, CodeGenObject_Operators_Mod) {
  3593. // CodeGenTest(L"..\\CodeGenHLSL\\object-operators_Mod.hlsl");
  3594. //}
  3595. TEST_F(CompilerTest, CodeGenPackreg_Mod) {
  3596. CodeGenTest(L"..\\CodeGenHLSL\\packreg_Mod.hlsl");
  3597. }
  3598. TEST_F(CompilerTest, CodeGenParameter_Types) {
  3599. CodeGenTestCheck(L"..\\CodeGenHLSL\\parameter_types.hlsl");
  3600. }
  3601. TEST_F(CompilerTest, CodeGenScalar_Assignments_Mod) {
  3602. CodeGenTest(L"..\\CodeGenHLSL\\scalar-assignments_Mod.hlsl");
  3603. }
  3604. TEST_F(CompilerTest, CodeGenScalar_Operators_Assign_Mod) {
  3605. CodeGenTest(L"..\\CodeGenHLSL\\scalar-operators-assign_Mod.hlsl");
  3606. }
  3607. TEST_F(CompilerTest, CodeGenScalar_Operators_Mod) {
  3608. CodeGenTest(L"..\\CodeGenHLSL\\scalar-operators_Mod.hlsl");
  3609. }
  3610. TEST_F(CompilerTest, CodeGenSemantics_Mod) {
  3611. CodeGenTest(L"..\\CodeGenHLSL\\semantics_Mod.hlsl");
  3612. }
  3613. // TEST_F(CompilerTest, CodeGenSpec_Mod){
  3614. // CodeGenTest(L"..\\CodeGenHLSL\\spec_Mod.hlsl");
  3615. //}
  3616. TEST_F(CompilerTest, CodeGenString_Mod) {
  3617. CodeGenTest(L"..\\CodeGenHLSL\\string_Mod.hlsl");
  3618. }
  3619. TEST_F(CompilerTest, CodeGenStruct_Assignments_Mod) {
  3620. CodeGenTest(L"..\\CodeGenHLSL\\struct-assignments_Mod.hlsl");
  3621. }
  3622. TEST_F(CompilerTest, CodeGenStruct_AssignmentsFull_Mod){
  3623. CodeGenTest(L"..\\CodeGenHLSL\\struct-assignmentsFull_Mod.hlsl");
  3624. }
  3625. TEST_F(CompilerTest, CodeGenTemplate_Checks_Mod) {
  3626. CodeGenTestCheck(L"..\\CodeGenHLSL\\template-checks_Mod.hlsl");
  3627. }
  3628. TEST_F(CompilerTest, CodeGenToinclude2_Mod) {
  3629. CodeGenTest(L"..\\CodeGenHLSL\\toinclude2_Mod.hlsl");
  3630. }
  3631. TEST_F(CompilerTest, CodeGenTypemods_Syntax_Mod) {
  3632. CodeGenTest(L"..\\CodeGenHLSL\\typemods-syntax_Mod.hlsl");
  3633. }
  3634. TEST_F(CompilerTest, CodeGenVarmods_Syntax_Mod) {
  3635. CodeGenTest(L"..\\CodeGenHLSL\\varmods-syntax_Mod.hlsl");
  3636. }
  3637. TEST_F(CompilerTest, CodeGenVector_Assignments_Mod) {
  3638. CodeGenTest(L"..\\CodeGenHLSL\\vector-assignments_Mod.hlsl");
  3639. }
  3640. TEST_F(CompilerTest, CodeGenVector_Syntax_Mix_Mod) {
  3641. CodeGenTest(L"..\\CodeGenHLSL\\vector-syntax-mix_Mod.hlsl");
  3642. }
  3643. TEST_F(CompilerTest, CodeGenVector_Syntax_Mod) {
  3644. CodeGenTest(L"..\\CodeGenHLSL\\vector-syntax_Mod.hlsl");
  3645. }
  3646. TEST_F(CompilerTest, CodeGenBasicHLSL11_PS) {
  3647. CodeGenTestCheck(L"..\\CodeGenHLSL\\BasicHLSL11_PS.hlsl");
  3648. }
  3649. TEST_F(CompilerTest, CodeGenBasicHLSL11_PS2) {
  3650. CodeGenTestCheck(L"..\\CodeGenHLSL\\BasicHLSL11_PS2.hlsl");
  3651. }
  3652. TEST_F(CompilerTest, CodeGenBasicHLSL11_PS3) {
  3653. CodeGenTestCheck(L"..\\CodeGenHLSL\\BasicHLSL11_PS3.hlsl");
  3654. }
  3655. TEST_F(CompilerTest, CodeGenBasicHLSL11_VS) {
  3656. CodeGenTestCheck(L"..\\CodeGenHLSL\\BasicHLSL11_VS.hlsl");
  3657. }
  3658. TEST_F(CompilerTest, CodeGenBasicHLSL11_VS2) {
  3659. CodeGenTestCheck(L"..\\CodeGenHLSL\\BasicHLSL11_VS2.hlsl");
  3660. }
  3661. TEST_F(CompilerTest, CodeGenVecIndexingInput) {
  3662. CodeGenTestCheck(L"..\\CodeGenHLSL\\vecIndexingInput.hlsl");
  3663. }
  3664. TEST_F(CompilerTest, CodeGenVecMulMat) {
  3665. CodeGenTest(L"..\\CodeGenHLSL\\vecMulMat.hlsl");
  3666. }
  3667. TEST_F(CompilerTest, CodeGenVecArrayParam) {
  3668. CodeGenTestCheck(L"..\\CodeGenHLSL\\vector_array_param.hlsl");
  3669. }
  3670. TEST_F(CompilerTest, CodeGenBindings1) {
  3671. CodeGenTestCheck(L"..\\CodeGenHLSL\\bindings1.hlsl");
  3672. }
  3673. TEST_F(CompilerTest, CodeGenBindings2) {
  3674. CodeGenTestCheck(L"..\\CodeGenHLSL\\bindings2.hlsl");
  3675. }
  3676. TEST_F(CompilerTest, CodeGenBindings3) {
  3677. CodeGenTestCheck(L"..\\CodeGenHLSL\\bindings2.hlsl");
  3678. }
  3679. TEST_F(CompilerTest, CodeGenResCopy) {
  3680. CodeGenTestCheck(L"..\\CodeGenHLSL\\resCopy.hlsl");
  3681. }
  3682. TEST_F(CompilerTest, CodeGenResourceInStruct) {
  3683. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-struct.hlsl");
  3684. }
  3685. TEST_F(CompilerTest, CodeGenResourceParam) {
  3686. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource_param.hlsl");
  3687. }
  3688. TEST_F(CompilerTest, CodeGenResourceInCB) {
  3689. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-cb.hlsl");
  3690. }
  3691. TEST_F(CompilerTest, CodeGenResourceInCBV) {
  3692. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-cbv.hlsl");
  3693. }
  3694. TEST_F(CompilerTest, CodeGenResourceInTB) {
  3695. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-tb.hlsl");
  3696. }
  3697. TEST_F(CompilerTest, CodeGenResourceInTBV) {
  3698. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-tbv.hlsl");
  3699. }
  3700. TEST_F(CompilerTest, CodeGenResourceInStruct2) {
  3701. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-struct2.hlsl");
  3702. }
  3703. TEST_F(CompilerTest, CodeGenResourceInStruct3) {
  3704. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-struct3.hlsl");
  3705. }
  3706. TEST_F(CompilerTest, CodeGenResourceInCB2) {
  3707. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-cb2.hlsl");
  3708. }
  3709. TEST_F(CompilerTest, CodeGenResourceInCB3) {
  3710. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-cb3.hlsl");
  3711. }
  3712. TEST_F(CompilerTest, CodeGenResourceInCB4) {
  3713. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-cb4.hlsl");
  3714. }
  3715. TEST_F(CompilerTest, CodeGenResourceInCBV2) {
  3716. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-cbv2.hlsl");
  3717. }
  3718. TEST_F(CompilerTest, CodeGenResourceInTB2) {
  3719. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-tb2.hlsl");
  3720. }
  3721. TEST_F(CompilerTest, CodeGenResourceInTBV2) {
  3722. CodeGenTestCheck(L"..\\CodeGenHLSL\\resource-in-tbv2.hlsl");
  3723. }
  3724. TEST_F(CompilerTest, CodeGenResourceArrayParam) {
  3725. CodeGenTest(L"..\\CodeGenHLSL\\resource-array-param.hlsl");
  3726. }
  3727. TEST_F(CompilerTest, CodeGenResPhi) {
  3728. CodeGenTestCheck(L"..\\CodeGenHLSL\\resPhi.hlsl");
  3729. }
  3730. TEST_F(CompilerTest, CodeGenResPhi2) {
  3731. CodeGenTestCheck(L"..\\CodeGenHLSL\\resPhi2.hlsl");
  3732. }
  3733. TEST_F(CompilerTest, CodeGenRootSigEntry) {
  3734. CodeGenTest(L"..\\CodeGenHLSL\\rootSigEntry.hlsl");
  3735. }
  3736. TEST_F(CompilerTest, CodeGenRootSigProfile) {
  3737. CodeGenTest(L"..\\CodeGenHLSL\\rootSigProfile.hlsl");
  3738. }
  3739. TEST_F(CompilerTest, CodeGenRootSigProfile2) {
  3740. // TODO: Verify the result when reflect the structures.
  3741. CodeGenTest(L"..\\CodeGenHLSL\\rootSigProfile2.hlsl");
  3742. }
  3743. TEST_F(CompilerTest, CodeGenRootSigProfile3) {
  3744. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigProfile3.hlsl");
  3745. }
  3746. TEST_F(CompilerTest, CodeGenRootSigProfile4) {
  3747. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigProfile4.hlsl");
  3748. }
  3749. TEST_F(CompilerTest, CodeGenRootSigProfile5) {
  3750. CodeGenTest(L"..\\CodeGenHLSL\\rootSigProfile5.hlsl");
  3751. }
  3752. TEST_F(CompilerTest, CodeGenRootSigDefine1) {
  3753. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine1.hlsl");
  3754. }
  3755. TEST_F(CompilerTest, CodeGenRootSigDefine2) {
  3756. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine2.hlsl");
  3757. }
  3758. TEST_F(CompilerTest, CodeGenRootSigDefine3) {
  3759. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine3.hlsl");
  3760. }
  3761. TEST_F(CompilerTest, CodeGenRootSigDefine4) {
  3762. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine4.hlsl");
  3763. }
  3764. TEST_F(CompilerTest, CodeGenRootSigDefine5) {
  3765. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine5.hlsl");
  3766. }
  3767. TEST_F(CompilerTest, CodeGenRootSigDefine6) {
  3768. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine6.hlsl");
  3769. }
  3770. TEST_F(CompilerTest, CodeGenRootSigDefine7) {
  3771. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine7.hlsl");
  3772. }
  3773. TEST_F(CompilerTest, CodeGenRootSigDefine8) {
  3774. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine8.hlsl");
  3775. }
  3776. TEST_F(CompilerTest, CodeGenRootSigDefine9) {
  3777. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine9.hlsl");
  3778. }
  3779. TEST_F(CompilerTest, CodeGenRootSigDefine10) {
  3780. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine10.hlsl");
  3781. }
  3782. TEST_F(CompilerTest, CodeGenRootSigDefine11) {
  3783. CodeGenTestCheck(L"..\\CodeGenHLSL\\rootSigDefine11.hlsl");
  3784. }
  3785. TEST_F(CompilerTest, CodeGenCBufferStructArray) {
  3786. CodeGenTestCheck(L"..\\CodeGenHLSL\\cbuffer-structarray.hlsl");
  3787. }
  3788. TEST_F(CompilerTest, CodeGenPatchLength) {
  3789. CodeGenTestCheck(L"..\\CodeGenHLSL\\PatchLength1.hlsl");
  3790. }
  3791. // Dx11 Sample
  3792. TEST_F(CompilerTest, CodeGenDX11Sample_2Dquadshaders_Blurx_Ps){
  3793. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\2DQuadShaders_BlurX_PS.hlsl");
  3794. }
  3795. TEST_F(CompilerTest, CodeGenDX11Sample_2Dquadshaders_Blury_Ps){
  3796. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\2DQuadShaders_BlurY_PS.hlsl");
  3797. }
  3798. TEST_F(CompilerTest, CodeGenDX11Sample_2Dquadshaders_Vs){
  3799. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\2DQuadShaders_VS.hlsl");
  3800. }
  3801. TEST_F(CompilerTest, CodeGenDX11Sample_Bc6Hdecode){
  3802. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC6HDecode.hlsl");
  3803. }
  3804. TEST_F(CompilerTest, CodeGenDX11Sample_Bc6Hencode_Encodeblockcs){
  3805. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC6HEncode_EncodeBlockCS.hlsl");
  3806. }
  3807. TEST_F(CompilerTest, CodeGenDX11Sample_Bc6Hencode_Trymodeg10Cs){
  3808. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC6HEncode_TryModeG10CS.hlsl");
  3809. }
  3810. TEST_F(CompilerTest, CodeGenDX11Sample_Bc6Hencode_Trymodele10Cs){
  3811. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC6HEncode_TryModeLE10CS.hlsl");
  3812. }
  3813. TEST_F(CompilerTest, CodeGenDX11Sample_Bc7Decode){
  3814. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC7Decode.hlsl");
  3815. }
  3816. TEST_F(CompilerTest, CodeGenDX11Sample_Bc7Encode_Encodeblockcs){
  3817. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC7Encode_EncodeBlockCS.hlsl");
  3818. }
  3819. TEST_F(CompilerTest, CodeGenDX11Sample_Bc7Encode_Trymode02Cs){
  3820. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC7Encode_TryMode02CS.hlsl");
  3821. }
  3822. TEST_F(CompilerTest, CodeGenDX11Sample_Bc7Encode_Trymode137Cs){
  3823. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC7Encode_TryMode137CS.hlsl");
  3824. }
  3825. TEST_F(CompilerTest, CodeGenDX11Sample_Bc7Encode_Trymode456Cs){
  3826. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BC7Encode_TryMode456CS.hlsl");
  3827. }
  3828. TEST_F(CompilerTest, CodeGenDX11Sample_Brightpassandhorizfiltercs){
  3829. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\BrightPassAndHorizFilterCS.hlsl");
  3830. }
  3831. TEST_F(CompilerTest, CodeGenDX11Sample_Computeshadersort11){
  3832. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ComputeShaderSort11.hlsl");
  3833. }
  3834. TEST_F(CompilerTest, CodeGenDX11Sample_Computeshadersort11_Matrixtranspose){
  3835. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ComputeShaderSort11_MatrixTranspose.hlsl");
  3836. }
  3837. TEST_F(CompilerTest, CodeGenDX11Sample_Contacthardeningshadows11_Ps){
  3838. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ContactHardeningShadows11_PS.hlsl");
  3839. }
  3840. TEST_F(CompilerTest, CodeGenDX11Sample_Contacthardeningshadows11_Sm_Vs){
  3841. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ContactHardeningShadows11_SM_VS.hlsl");
  3842. }
  3843. TEST_F(CompilerTest, CodeGenDX11Sample_Contacthardeningshadows11_Vs){
  3844. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ContactHardeningShadows11_VS.hlsl");
  3845. }
  3846. TEST_F(CompilerTest, CodeGenDX11Sample_Decaltessellation11_Ds){
  3847. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DecalTessellation11_DS.hlsl");
  3848. }
  3849. TEST_F(CompilerTest, CodeGenDX11Sample_Decaltessellation11_Hs){
  3850. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DecalTessellation11_HS.hlsl");
  3851. }
  3852. TEST_F(CompilerTest, CodeGenDX11Sample_Decaltessellation11_Ps){
  3853. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DecalTessellation11_PS.hlsl");
  3854. }
  3855. TEST_F(CompilerTest, CodeGenDX11Sample_Decaltessellation11_Tessvs){
  3856. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DecalTessellation11_TessVS.hlsl");
  3857. }
  3858. TEST_F(CompilerTest, CodeGenDX11Sample_Decaltessellation11_Vs){
  3859. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DecalTessellation11_VS.hlsl");
  3860. }
  3861. TEST_F(CompilerTest, CodeGenDX11Sample_Detailtessellation11_Ds){
  3862. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DetailTessellation11_DS.hlsl");
  3863. }
  3864. TEST_F(CompilerTest, CodeGenDX11Sample_Detailtessellation11_Hs){
  3865. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DetailTessellation11_HS.hlsl");
  3866. }
  3867. TEST_F(CompilerTest, CodeGenDX11Sample_Detailtessellation11_Ps){
  3868. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DetailTessellation11_PS.hlsl");
  3869. }
  3870. TEST_F(CompilerTest, CodeGenDX11Sample_Detailtessellation11_Tessvs){
  3871. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DetailTessellation11_TessVS.hlsl");
  3872. }
  3873. TEST_F(CompilerTest, CodeGenDX11Sample_Detailtessellation11_Vs){
  3874. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DetailTessellation11_VS.hlsl");
  3875. }
  3876. TEST_F(CompilerTest, CodeGenDX11Sample_Dumptotexture){
  3877. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\DumpToTexture.hlsl");
  3878. }
  3879. TEST_F(CompilerTest, CodeGenDX11Sample_Filtercs_Horz){
  3880. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FilterCS_Horz.hlsl");
  3881. }
  3882. TEST_F(CompilerTest, CodeGenDX11Sample_Filtercs_Vertical){
  3883. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FilterCS_Vertical.hlsl");
  3884. }
  3885. TEST_F(CompilerTest, CodeGenDX11Sample_Finalpass_Cpu_Ps){
  3886. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FinalPass_CPU_PS.hlsl");
  3887. }
  3888. TEST_F(CompilerTest, CodeGenDX11Sample_Finalpass_Ps){
  3889. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FinalPass_PS.hlsl");
  3890. }
  3891. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Buildgridcs){
  3892. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_BuildGridCS.hlsl");
  3893. }
  3894. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Buildgridindicescs){
  3895. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_BuildGridIndicesCS.hlsl");
  3896. }
  3897. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Cleargridindicescs){
  3898. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_ClearGridIndicesCS.hlsl");
  3899. }
  3900. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Densitycs_Grid){
  3901. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_DensityCS_Grid.hlsl");
  3902. }
  3903. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Densitycs_Shared){
  3904. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_DensityCS_Shared.hlsl");
  3905. }
  3906. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Densitycs_Simple){
  3907. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_DensityCS_Simple.hlsl");
  3908. }
  3909. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Forcecs_Grid){
  3910. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_ForceCS_Grid.hlsl");
  3911. }
  3912. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Forcecs_Shared){
  3913. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_ForceCS_Shared.hlsl");
  3914. }
  3915. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Forcecs_Simple){
  3916. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_ForceCS_Simple.hlsl");
  3917. }
  3918. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Integratecs){
  3919. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_IntegrateCS.hlsl");
  3920. }
  3921. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidcs11_Rearrangeparticlescs){
  3922. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidCS11_RearrangeParticlesCS.hlsl");
  3923. }
  3924. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidrender_Gs){
  3925. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidRender_GS.hlsl");
  3926. }
  3927. TEST_F(CompilerTest, CodeGenDX11Sample_Fluidrender_Vs){
  3928. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\FluidRender_VS.hlsl");
  3929. }
  3930. TEST_F(CompilerTest, CodeGenDX11Sample_Nbodygravitycs11){
  3931. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\NBodyGravityCS11.hlsl");
  3932. }
  3933. TEST_F(CompilerTest, CodeGenDX11Sample_Oit_Createprefixsum_Pass0_Cs){
  3934. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\OIT_CreatePrefixSum_Pass0_CS.hlsl");
  3935. }
  3936. TEST_F(CompilerTest, CodeGenDX11Sample_Oit_Createprefixsum_Pass1_Cs){
  3937. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\OIT_CreatePrefixSum_Pass1_CS.hlsl");
  3938. }
  3939. TEST_F(CompilerTest, CodeGenDX11Sample_Oit_Fragmentcountps){
  3940. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\OIT_FragmentCountPS.hlsl");
  3941. }
  3942. TEST_F(CompilerTest, CodeGenDX11Sample_Oit_Ps){
  3943. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\OIT_PS.hlsl");
  3944. }
  3945. TEST_F(CompilerTest, CodeGenDX11Sample_Oit_Sortandrendercs){
  3946. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\OIT_SortAndRenderCS.hlsl");
  3947. }
  3948. TEST_F(CompilerTest, CodeGenDX11Sample_Particledraw_Gs){
  3949. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ParticleDraw_GS.hlsl");
  3950. }
  3951. TEST_F(CompilerTest, CodeGenDX11Sample_Particledraw_Vs){
  3952. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ParticleDraw_VS.hlsl");
  3953. }
  3954. TEST_F(CompilerTest, CodeGenDX11Sample_Particle_Gs){
  3955. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\Particle_GS.hlsl");
  3956. }
  3957. TEST_F(CompilerTest, CodeGenDX11Sample_Particle_Ps){
  3958. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\Particle_PS.hlsl");
  3959. }
  3960. TEST_F(CompilerTest, CodeGenDX11Sample_Particle_Vs){
  3961. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\Particle_VS.hlsl");
  3962. }
  3963. TEST_F(CompilerTest, CodeGenDX11Sample_Pntriangles11_Ds){
  3964. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PNTriangles11_DS.hlsl");
  3965. }
  3966. TEST_F(CompilerTest, CodeGenDX11Sample_Pntriangles11_Hs){
  3967. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PNTriangles11_HS.hlsl");
  3968. }
  3969. TEST_F(CompilerTest, CodeGenDX11Sample_Pntriangles11_Tessvs){
  3970. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PNTriangles11_TessVS.hlsl");
  3971. }
  3972. TEST_F(CompilerTest, CodeGenDX11Sample_Pntriangles11_Vs){
  3973. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PNTriangles11_VS.hlsl");
  3974. }
  3975. TEST_F(CompilerTest, CodeGenDX11Sample_Pom_Ps){
  3976. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\POM_PS.hlsl");
  3977. }
  3978. TEST_F(CompilerTest, CodeGenDX11Sample_Pom_Vs){
  3979. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\POM_VS.hlsl");
  3980. }
  3981. TEST_F(CompilerTest, CodeGenDX11Sample_Psapproach_Bloomps){
  3982. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PSApproach_BloomPS.hlsl");
  3983. }
  3984. TEST_F(CompilerTest, CodeGenDX11Sample_Psapproach_Downscale2X2_Lumps){
  3985. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PSApproach_DownScale2x2_LumPS.hlsl");
  3986. }
  3987. TEST_F(CompilerTest, CodeGenDX11Sample_Psapproach_Downscale3X3Ps){
  3988. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PSApproach_DownScale3x3PS.hlsl");
  3989. }
  3990. TEST_F(CompilerTest, CodeGenDX11Sample_Psapproach_Downscale3X3_Brightpassps){
  3991. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PSApproach_DownScale3x3_BrightPassPS.hlsl");
  3992. }
  3993. TEST_F(CompilerTest, CodeGenDX11Sample_Psapproach_Finalpassps){
  3994. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\PSApproach_FinalPassPS.hlsl");
  3995. }
  3996. TEST_F(CompilerTest, CodeGenDX11Sample_Reduceto1Dcs){
  3997. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ReduceTo1DCS.hlsl");
  3998. }
  3999. TEST_F(CompilerTest, CodeGenDX11Sample_Reducetosinglecs){
  4000. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\ReduceToSingleCS.hlsl");
  4001. }
  4002. TEST_F(CompilerTest, CodeGenDX11Sample_Rendervariancesceneps){
  4003. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\RenderVarianceScenePS.hlsl");
  4004. }
  4005. TEST_F(CompilerTest, CodeGenDX11Sample_Rendervs){
  4006. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\RenderVS.hlsl");
  4007. }
  4008. TEST_F(CompilerTest, CodeGenDX11Sample_Simplebezier11Ds){
  4009. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SimpleBezier11DS.hlsl");
  4010. }
  4011. TEST_F(CompilerTest, CodeGenDX11Sample_Simplebezier11Hs){
  4012. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SimpleBezier11HS.hlsl");
  4013. }
  4014. TEST_F(CompilerTest, CodeGenDX11Sample_Simplebezier11Ps){
  4015. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SimpleBezier11PS.hlsl");
  4016. }
  4017. TEST_F(CompilerTest, CodeGenDX11Sample_Subd11_Bezierevalds){
  4018. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SubD11_BezierEvalDS.hlsl");
  4019. }
  4020. TEST_F(CompilerTest, CodeGenDX11Sample_Subd11_Meshskinningvs){
  4021. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SubD11_MeshSkinningVS.hlsl");
  4022. }
  4023. TEST_F(CompilerTest, CodeGenDX11Sample_Subd11_Patchskinningvs){
  4024. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SubD11_PatchSkinningVS.hlsl");
  4025. }
  4026. TEST_F(CompilerTest, CodeGenDX11Sample_Subd11_Smoothps){
  4027. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SubD11_SmoothPS.hlsl");
  4028. }
  4029. TEST_F(CompilerTest, CodeGenDX11Sample_Subd11_Subdtobezierhs){
  4030. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SubD11_SubDToBezierHS.hlsl");
  4031. }
  4032. TEST_F(CompilerTest, CodeGenDX11Sample_Subd11_Subdtobezierhs4444){
  4033. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\SubD11_SubDToBezierHS4444.hlsl");
  4034. }
  4035. TEST_F(CompilerTest, CodeGenDX11Sample_Tessellatorcs40_Edgefactorcs){
  4036. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\TessellatorCS40_EdgeFactorCS.hlsl");
  4037. }
  4038. TEST_F(CompilerTest, CodeGenDX11Sample_Tessellatorcs40_Numverticesindicescs){
  4039. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\TessellatorCS40_NumVerticesIndicesCS.hlsl");
  4040. }
  4041. TEST_F(CompilerTest, CodeGenDX11Sample_Tessellatorcs40_Scatteridcs){
  4042. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\TessellatorCS40_ScatterIDCS.hlsl");
  4043. }
  4044. TEST_F(CompilerTest, CodeGenDX11Sample_Tessellatorcs40_Tessellateindicescs){
  4045. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\TessellatorCS40_TessellateIndicesCS.hlsl");
  4046. }
  4047. TEST_F(CompilerTest, CodeGenDX11Sample_Tessellatorcs40_Tessellateverticescs){
  4048. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\DX11\\TessellatorCS40_TessellateVerticesCS.hlsl");
  4049. }
  4050. // Dx12 Sample
  4051. TEST_F(CompilerTest, CodeGenSamplesD12_DynamicIndexing_PS) {
  4052. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\d12_dynamic_indexing_pixel.hlsl");
  4053. }
  4054. TEST_F(CompilerTest, CodeGenSamplesD12_ExecuteIndirect_CS) {
  4055. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\d12_execute_indirect_cs.hlsl");
  4056. }
  4057. TEST_F(CompilerTest, CodeGenSamplesD12_MultiThreading_VS) {
  4058. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\d12_multithreading_vs.hlsl");
  4059. }
  4060. TEST_F(CompilerTest, CodeGenSamplesD12_MultiThreading_PS) {
  4061. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\d12_multithreading_ps.hlsl");
  4062. }
  4063. TEST_F(CompilerTest, CodeGenSamplesD12_NBodyGravity_CS) {
  4064. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\d12_nBodyGravityCS.hlsl");
  4065. }
  4066. // Dx12 sample/MiniEngine
  4067. TEST_F(CompilerTest, CodeGenDx12MiniEngineAdaptexposurecs){
  4068. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AdaptExposureCS.hlsl");
  4069. }
  4070. TEST_F(CompilerTest, CodeGenDx12MiniEngineAoblurupsampleblendoutcs){
  4071. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoBlurUpsampleBlendOutCS.hlsl");
  4072. }
  4073. TEST_F(CompilerTest, CodeGenDx12MiniEngineAoblurupsamplecs){
  4074. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoBlurUpsampleCS.hlsl");
  4075. }
  4076. TEST_F(CompilerTest, CodeGenDx12MiniEngineAoblurupsamplepreminblendoutcs){
  4077. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoBlurUpsamplePreMinBlendOutCS.hlsl");
  4078. }
  4079. TEST_F(CompilerTest, CodeGenDx12MiniEngineAoblurupsamplepremincs){
  4080. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoBlurUpsamplePreMinCS.hlsl");
  4081. }
  4082. TEST_F(CompilerTest, CodeGenDx12MiniEngineAopreparedepthbuffers1Cs){
  4083. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoPrepareDepthBuffers1CS.hlsl");
  4084. }
  4085. TEST_F(CompilerTest, CodeGenDx12MiniEngineAopreparedepthbuffers2Cs){
  4086. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoPrepareDepthBuffers2CS.hlsl");
  4087. }
  4088. TEST_F(CompilerTest, CodeGenDx12MiniEngineAorender1Cs){
  4089. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoRender1CS.hlsl");
  4090. }
  4091. TEST_F(CompilerTest, CodeGenDx12MiniEngineAorender2Cs){
  4092. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AoRender2CS.hlsl");
  4093. }
  4094. TEST_F(CompilerTest, CodeGenDx12MiniEngineApplybloomcs){
  4095. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ApplyBloomCS.hlsl");
  4096. }
  4097. TEST_F(CompilerTest, CodeGenDx12MiniEngineAveragelumacs){
  4098. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\AverageLumaCS.hlsl");
  4099. }
  4100. TEST_F(CompilerTest, CodeGenDx12MiniEngineBicubichorizontalupsampleps){
  4101. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BicubicHorizontalUpsamplePS.hlsl");
  4102. }
  4103. TEST_F(CompilerTest, CodeGenDx12MiniEngineBicubicupsamplegammaps){
  4104. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BicubicUpsampleGammaPS.hlsl");
  4105. }
  4106. TEST_F(CompilerTest, CodeGenDx12MiniEngineBicubicupsampleps){
  4107. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BicubicUpsamplePS.hlsl");
  4108. }
  4109. TEST_F(CompilerTest, CodeGenDx12MiniEngineBicubicverticalupsampleps){
  4110. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BicubicVerticalUpsamplePS.hlsl");
  4111. }
  4112. TEST_F(CompilerTest, CodeGenDx12MiniEngineBilinearupsampleps){
  4113. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BilinearUpsamplePS.hlsl");
  4114. }
  4115. TEST_F(CompilerTest, CodeGenDx12MiniEngineBloomextractanddownsamplehdrcs){
  4116. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BloomExtractAndDownsampleHdrCS.hlsl");
  4117. }
  4118. TEST_F(CompilerTest, CodeGenDx12MiniEngineBloomextractanddownsampleldrcs){
  4119. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BloomExtractAndDownsampleLdrCS.hlsl");
  4120. }
  4121. TEST_F(CompilerTest, CodeGenDx12MiniEngineBlurcs){
  4122. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BlurCS.hlsl");
  4123. }
  4124. TEST_F(CompilerTest, CodeGenDx12MiniEngineBuffercopyps){
  4125. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\BufferCopyPS.hlsl");
  4126. }
  4127. TEST_F(CompilerTest, CodeGenDx12MiniEngineCameramotionblurprepasscs){
  4128. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\CameraMotionBlurPrePassCS.hlsl");
  4129. }
  4130. TEST_F(CompilerTest, CodeGenDx12MiniEngineCameramotionblurprepasslinearzcs){
  4131. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\CameraMotionBlurPrePassLinearZCS.hlsl");
  4132. }
  4133. TEST_F(CompilerTest, CodeGenDx12MiniEngineCameravelocitycs){
  4134. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\CameraVelocityCS.hlsl");
  4135. }
  4136. TEST_F(CompilerTest, CodeGenDx12MiniEngineConvertldrtodisplayaltps){
  4137. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ConvertLDRToDisplayAltPS.hlsl");
  4138. }
  4139. TEST_F(CompilerTest, CodeGenDx12MiniEngineConvertldrtodisplayps){
  4140. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ConvertLDRToDisplayPS.hlsl");
  4141. }
  4142. TEST_F(CompilerTest, CodeGenDx12MiniEngineDebugdrawhistogramcs){
  4143. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DebugDrawHistogramCS.hlsl");
  4144. }
  4145. TEST_F(CompilerTest, CodeGenDx12MiniEngineDebugluminancehdrcs){
  4146. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DebugLuminanceHdrCS.hlsl");
  4147. }
  4148. TEST_F(CompilerTest, CodeGenDx12MiniEngineDebugluminanceldrcs){
  4149. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DebugLuminanceLdrCS.hlsl");
  4150. }
  4151. TEST_F(CompilerTest, CodeGenDx12MiniEngineDebugssaocs){
  4152. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DebugSSAOCS.hlsl");
  4153. }
  4154. TEST_F(CompilerTest, CodeGenDx12MiniEngineDepthviewerps){
  4155. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DepthViewerPS.hlsl");
  4156. }
  4157. TEST_F(CompilerTest, CodeGenDx12MiniEngineDepthviewervs){
  4158. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DepthViewerVS.hlsl");
  4159. }
  4160. TEST_F(CompilerTest, CodeGenDx12MiniEngineDownsamplebloomallcs){
  4161. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DownsampleBloomAllCS.hlsl");
  4162. }
  4163. TEST_F(CompilerTest, CodeGenDx12MiniEngineDownsamplebloomcs){
  4164. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\DownsampleBloomCS.hlsl");
  4165. }
  4166. TEST_F(CompilerTest, CodeGenDx12MiniEngineExtractlumacs){
  4167. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ExtractLumaCS.hlsl");
  4168. }
  4169. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaapass1_Luma_Cs){
  4170. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAPass1_Luma_CS.hlsl");
  4171. }
  4172. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaapass1_Rgb_Cs){
  4173. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAPass1_RGB_CS.hlsl");
  4174. }
  4175. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaapass2Hcs){
  4176. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAPass2HCS.hlsl");
  4177. }
  4178. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaapass2Hdebugcs){
  4179. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAPass2HDebugCS.hlsl");
  4180. }
  4181. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaapass2Vcs){
  4182. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAPass2VCS.hlsl");
  4183. }
  4184. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaapass2Vdebugcs){
  4185. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAPass2VDebugCS.hlsl");
  4186. }
  4187. TEST_F(CompilerTest, CodeGenDx12MiniEngineFxaaresolveworkqueuecs){
  4188. if (m_ver.SkipIRSensitiveTest()) return;
  4189. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\FXAAResolveWorkQueueCS.hlsl");
  4190. }
  4191. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratehistogramcs){
  4192. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateHistogramCS.hlsl");
  4193. }
  4194. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipsgammacs){
  4195. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsGammaCS.hlsl");
  4196. }
  4197. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipsgammaoddcs){
  4198. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsGammaOddCS.hlsl");
  4199. }
  4200. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipsgammaoddxcs){
  4201. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsGammaOddXCS.hlsl");
  4202. }
  4203. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipsgammaoddycs){
  4204. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsGammaOddYCS.hlsl");
  4205. }
  4206. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipslinearcs){
  4207. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsLinearCS.hlsl");
  4208. }
  4209. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipslinearoddcs){
  4210. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsLinearOddCS.hlsl");
  4211. }
  4212. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipslinearoddxcs){
  4213. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsLinearOddXCS.hlsl");
  4214. }
  4215. TEST_F(CompilerTest, CodeGenDx12MiniEngineGeneratemipslinearoddycs){
  4216. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\GenerateMipsLinearOddYCS.hlsl");
  4217. }
  4218. TEST_F(CompilerTest, CodeGenDx12MiniEngineLinearizedepthcs){
  4219. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\LinearizeDepthCS.hlsl");
  4220. }
  4221. TEST_F(CompilerTest, CodeGenDx12MiniEngineMagnifypixelsps){
  4222. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\MagnifyPixelsPS.hlsl");
  4223. }
  4224. TEST_F(CompilerTest, CodeGenDx12MiniEngineModelviewerps){
  4225. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ModelViewerPS.hlsl");
  4226. }
  4227. TEST_F(CompilerTest, CodeGenDx12MiniEngineModelviewervs){
  4228. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ModelViewerVS.hlsl");
  4229. }
  4230. TEST_F(CompilerTest, CodeGenDx12MiniEngineMotionblurfinalpasscs){
  4231. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\MotionBlurFinalPassCS.hlsl");
  4232. }
  4233. TEST_F(CompilerTest, CodeGenDx12MiniEngineMotionblurfinalpasstemporalcs){
  4234. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\MotionBlurFinalPassTemporalCS.hlsl");
  4235. }
  4236. TEST_F(CompilerTest, CodeGenDx12MiniEngineMotionblurprepasscs){
  4237. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\MotionBlurPrePassCS.hlsl");
  4238. }
  4239. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlebincullingcs){
  4240. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleBinCullingCS.hlsl");
  4241. }
  4242. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticledepthboundscs){
  4243. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleDepthBoundsCS.hlsl");
  4244. }
  4245. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticledispatchindirectargscs){
  4246. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleDispatchIndirectArgsCS.hlsl");
  4247. }
  4248. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlefinaldispatchindirectargscs){
  4249. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleFinalDispatchIndirectArgsCS.hlsl");
  4250. }
  4251. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticleinnersortcs){
  4252. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleInnerSortCS.hlsl");
  4253. }
  4254. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlelargebincullingcs){
  4255. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleLargeBinCullingCS.hlsl");
  4256. }
  4257. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticleoutersortcs){
  4258. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleOuterSortCS.hlsl");
  4259. }
  4260. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlepresortcs){
  4261. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticlePreSortCS.hlsl");
  4262. }
  4263. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticleps){
  4264. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticlePS.hlsl");
  4265. }
  4266. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlesortindirectargscs){
  4267. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleSortIndirectArgsCS.hlsl");
  4268. }
  4269. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlespawncs){
  4270. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleSpawnCS.hlsl");
  4271. }
  4272. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilecullingcs){
  4273. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileCullingCS.hlsl");
  4274. }
  4275. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilerendercs){
  4276. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileRenderCS.hlsl");
  4277. }
  4278. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilerenderfastcs){
  4279. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileRenderFastCS.hlsl");
  4280. }
  4281. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilerenderfastdynamiccs){
  4282. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileRenderFastDynamicCS.hlsl");
  4283. }
  4284. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilerenderfastlowrescs){
  4285. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileRenderFastLowResCS.hlsl");
  4286. }
  4287. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilerenderslowdynamiccs){
  4288. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileRenderSlowDynamicCS.hlsl");
  4289. }
  4290. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticletilerenderslowlowrescs){
  4291. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleTileRenderSlowLowResCS.hlsl");
  4292. }
  4293. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticleupdatecs){
  4294. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleUpdateCS.hlsl");
  4295. }
  4296. TEST_F(CompilerTest, CodeGenDx12MiniEngineParticlevs){
  4297. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ParticleVS.hlsl");
  4298. }
  4299. TEST_F(CompilerTest, CodeGenDx12MiniEnginePerfgraphbackgroundvs){
  4300. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\PerfGraphBackgroundVS.hlsl");
  4301. }
  4302. TEST_F(CompilerTest, CodeGenDx12MiniEnginePerfgraphps){
  4303. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\PerfGraphPS.hlsl");
  4304. }
  4305. TEST_F(CompilerTest, CodeGenDx12MiniEnginePerfgraphvs){
  4306. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\PerfGraphVS.hlsl");
  4307. }
  4308. TEST_F(CompilerTest, CodeGenDx12MiniEngineScreenquadvs){
  4309. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ScreenQuadVS.hlsl");
  4310. }
  4311. TEST_F(CompilerTest, CodeGenDx12MiniEngineSharpeningupsamplegammaps){
  4312. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\SharpeningUpsampleGammaPS.hlsl");
  4313. }
  4314. TEST_F(CompilerTest, CodeGenDx12MiniEngineSharpeningupsampleps){
  4315. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\SharpeningUpsamplePS.hlsl");
  4316. }
  4317. TEST_F(CompilerTest, CodeGenDx12MiniEngineTemporalblendcs){
  4318. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\TemporalBlendCS.hlsl");
  4319. }
  4320. TEST_F(CompilerTest, CodeGenDx12MiniEngineTextantialiasps){
  4321. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\TextAntialiasPS.hlsl");
  4322. }
  4323. TEST_F(CompilerTest, CodeGenDx12MiniEngineTextshadowps){
  4324. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\TextShadowPS.hlsl");
  4325. }
  4326. TEST_F(CompilerTest, CodeGenDx12MiniEngineTextvs){
  4327. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\TextVS.hlsl");
  4328. }
  4329. TEST_F(CompilerTest, CodeGenDx12MiniEngineTonemap2Cs){
  4330. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ToneMap2CS.hlsl");
  4331. }
  4332. TEST_F(CompilerTest, CodeGenDx12MiniEngineTonemapcs){
  4333. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\ToneMapCS.hlsl");
  4334. }
  4335. TEST_F(CompilerTest, CodeGenDx12MiniEngineUpsampleandblurcs){
  4336. CodeGenTestCheck(L"..\\CodeGenHLSL\\Samples\\MiniEngine\\UpsampleAndBlurCS.hlsl");
  4337. }
  4338. TEST_F(CompilerTest, DxilGen_StoreOutput) {
  4339. CodeGenTestCheck(L"..\\CodeGenHLSL\\dxilgen_storeoutput.hlsl");
  4340. }
  4341. TEST_F(CompilerTest, ConstantFolding) {
  4342. CodeGenTestCheck(L"constprop\\FAbs.hlsl");
  4343. CodeGenTestCheck(L"constprop\\Saturate_half.hlsl");
  4344. CodeGenTestCheck(L"constprop\\Saturate_float.hlsl");
  4345. CodeGenTestCheck(L"constprop\\Saturate_double.hlsl");
  4346. CodeGenTestCheck(L"constprop\\Cos.hlsl");
  4347. CodeGenTestCheck(L"constprop\\Sin.hlsl");
  4348. CodeGenTestCheck(L"constprop\\Tan.hlsl");
  4349. CodeGenTestCheck(L"constprop\\Acos.hlsl");
  4350. CodeGenTestCheck(L"constprop\\Asin.hlsl");
  4351. CodeGenTestCheck(L"constprop\\Atan.hlsl");
  4352. CodeGenTestCheck(L"constprop\\Hcos.hlsl");
  4353. CodeGenTestCheck(L"constprop\\Hsin.hlsl");
  4354. CodeGenTestCheck(L"constprop\\Htan.hlsl");
  4355. CodeGenTestCheck(L"constprop\\Exp.hlsl");
  4356. CodeGenTestCheck(L"constprop\\Frc.hlsl");
  4357. CodeGenTestCheck(L"constprop\\Log.hlsl");
  4358. CodeGenTestCheck(L"constprop\\Sqrt.hlsl");
  4359. CodeGenTestCheck(L"constprop\\Rsqrt.hlsl");
  4360. CodeGenTestCheck(L"constprop\\Round_ne.hlsl");
  4361. CodeGenTestCheck(L"constprop\\Round_ni.hlsl");
  4362. CodeGenTestCheck(L"constprop\\Round_pi.hlsl");
  4363. CodeGenTestCheck(L"constprop\\Round_z.hlsl");
  4364. CodeGenTestCheck(L"constprop\\Bfrev.hlsl");
  4365. CodeGenTestCheck(L"constprop\\Countbits.hlsl");
  4366. CodeGenTestCheck(L"constprop\\Firstbitlo.hlsl");
  4367. CodeGenTestCheck(L"constprop\\Firstbithi.hlsl");
  4368. CodeGenTestCheck(L"constprop\\FMin.hlsl");
  4369. CodeGenTestCheck(L"constprop\\FMax.hlsl");
  4370. CodeGenTestCheck(L"constprop\\IMin.hlsl");
  4371. CodeGenTestCheck(L"constprop\\IMax.hlsl");
  4372. CodeGenTestCheck(L"constprop\\UMin.hlsl");
  4373. CodeGenTestCheck(L"constprop\\UMax.hlsl");
  4374. CodeGenTestCheck(L"constprop\\FMad.hlsl");
  4375. CodeGenTestCheck(L"constprop\\Fma.hlsl");
  4376. CodeGenTestCheck(L"constprop\\IMad.hlsl");
  4377. CodeGenTestCheck(L"constprop\\UMad.hlsl");
  4378. CodeGenTestCheck(L"constprop\\Dot2.hlsl");
  4379. CodeGenTestCheck(L"constprop\\Dot3.hlsl");
  4380. CodeGenTestCheck(L"constprop\\Dot4.hlsl");
  4381. CodeGenTestCheck(L"constprop\\ibfe.ll");
  4382. CodeGenTestCheck(L"constprop\\ubfe.ll");
  4383. CodeGenTestCheck(L"constprop\\bfi.ll");
  4384. }
  4385. TEST_F(CompilerTest, HoistConstantArray) {
  4386. CodeGenTestCheck(L"hca\\01.hlsl");
  4387. CodeGenTestCheck(L"hca\\02.hlsl");
  4388. CodeGenTestCheck(L"hca\\03.hlsl");
  4389. CodeGenTestCheck(L"hca\\04.hlsl");
  4390. CodeGenTestCheck(L"hca\\05.hlsl");
  4391. CodeGenTestCheck(L"hca\\06.hlsl");
  4392. CodeGenTestCheck(L"hca\\07.hlsl");
  4393. CodeGenTestCheck(L"hca\\08.hlsl");
  4394. CodeGenTestCheck(L"hca\\09.hlsl");
  4395. CodeGenTestCheck(L"hca\\10.hlsl");
  4396. CodeGenTestCheck(L"hca\\11.hlsl");
  4397. CodeGenTestCheck(L"hca\\12.hlsl");
  4398. CodeGenTestCheck(L"hca\\13.hlsl");
  4399. CodeGenTestCheck(L"hca\\14.hlsl");
  4400. }
  4401. TEST_F(CompilerTest, PreprocessWhenValidThenOK) {
  4402. CComPtr<IDxcCompiler> pCompiler;
  4403. CComPtr<IDxcOperationResult> pResult;
  4404. CComPtr<IDxcBlobEncoding> pSource;
  4405. DxcDefine defines[2];
  4406. defines[0].Name = L"MYDEF";
  4407. defines[0].Value = L"int";
  4408. defines[1].Name = L"MYOTHERDEF";
  4409. defines[1].Value = L"123";
  4410. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  4411. CreateBlobFromText(
  4412. "// First line\r\n"
  4413. "MYDEF g_int = MYOTHERDEF;\r\n"
  4414. "#define FOO BAR\r\n"
  4415. "int FOO;", &pSource);
  4416. VERIFY_SUCCEEDED(pCompiler->Preprocess(pSource, L"file.hlsl", nullptr, 0,
  4417. defines, _countof(defines), nullptr,
  4418. &pResult));
  4419. HRESULT hrOp;
  4420. VERIFY_SUCCEEDED(pResult->GetStatus(&hrOp));
  4421. VERIFY_SUCCEEDED(hrOp);
  4422. CComPtr<IDxcBlob> pOutText;
  4423. VERIFY_SUCCEEDED(pResult->GetResult(&pOutText));
  4424. std::string text(BlobToUtf8(pOutText));
  4425. VERIFY_ARE_EQUAL_STR(
  4426. "#line 1 \"file.hlsl\"\n"
  4427. "\n"
  4428. "int g_int = 123;\n"
  4429. "\n"
  4430. "int BAR;\n", text.c_str());
  4431. }
  4432. TEST_F(CompilerTest, WhenSigMismatchPCFunctionThenFail) {
  4433. CComPtr<IDxcCompiler> pCompiler;
  4434. CComPtr<IDxcOperationResult> pResult;
  4435. CComPtr<IDxcBlobEncoding> pSource;
  4436. VERIFY_SUCCEEDED(CreateCompiler(&pCompiler));
  4437. CreateBlobFromText(
  4438. "struct PSSceneIn \n\
  4439. { \n\
  4440. float4 pos : SV_Position; \n\
  4441. float2 tex : TEXCOORD0; \n\
  4442. float3 norm : NORMAL; \n\
  4443. }; \n"
  4444. "struct HSPerPatchData { \n\
  4445. float edges[ 3 ] : SV_TessFactor; \n\
  4446. float inside : SV_InsideTessFactor; \n\
  4447. float foo : FOO; \n\
  4448. }; \n"
  4449. "HSPerPatchData HSPerPatchFunc( InputPatch< PSSceneIn, 3 > points, \n\
  4450. OutputPatch<PSSceneIn, 3> outpoints) { \n\
  4451. HSPerPatchData d = (HSPerPatchData)0; \n\
  4452. d.edges[ 0 ] = points[0].tex.x + outpoints[0].tex.x; \n\
  4453. d.edges[ 1 ] = 1; \n\
  4454. d.edges[ 2 ] = 1; \n\
  4455. d.inside = 1; \n\
  4456. return d; \n\
  4457. } \n"
  4458. "[domain(\"tri\")] \n\
  4459. [partitioning(\"fractional_odd\")] \n\
  4460. [outputtopology(\"triangle_cw\")] \n\
  4461. [patchconstantfunc(\"HSPerPatchFunc\")] \n\
  4462. [outputcontrolpoints(3)] \n"
  4463. "void main(const uint id : SV_OutputControlPointID, \n\
  4464. const InputPatch< PSSceneIn, 3 > points ) { \n\
  4465. } \n"
  4466. , &pSource);
  4467. VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"source.hlsl", L"main",
  4468. L"hs_6_0", nullptr, 0, nullptr, 0, nullptr, &pResult));
  4469. std::string failLog(VerifyOperationFailed(pResult));
  4470. VERIFY_ARE_NOT_EQUAL(string::npos, failLog.find(
  4471. "Signature element SV_Position, referred to by patch constant function, is not found in corresponding hull shader output."));
  4472. }
  4473. TEST_F(CompilerTest, ViewID) {
  4474. if (m_ver.SkipDxilVersion(1,1)) return;
  4475. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid01.hlsl");
  4476. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid02.hlsl");
  4477. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid03.hlsl");
  4478. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid04.hlsl");
  4479. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid05.hlsl");
  4480. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid06.hlsl");
  4481. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid07.hlsl");
  4482. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid08.hlsl");
  4483. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid09.hlsl");
  4484. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid10.hlsl");
  4485. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid11.hlsl");
  4486. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid12.hlsl");
  4487. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid13.hlsl");
  4488. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid14.hlsl");
  4489. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid15.hlsl");
  4490. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid16.hlsl");
  4491. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid17.hlsl");
  4492. CodeGenTestCheck(L"..\\CodeGenHLSL\\viewid\\viewid18.hlsl");
  4493. }
  4494. TEST_F(CompilerTest, ShaderCompatSuite) {
  4495. using namespace llvm;
  4496. using namespace WEX::TestExecution;
  4497. ::llvm::sys::fs::MSFileSystem *msfPtr;
  4498. VERIFY_SUCCEEDED(CreateMSFileSystemForDisk(&msfPtr));
  4499. std::unique_ptr<::llvm::sys::fs::MSFileSystem> msf(msfPtr);
  4500. ::llvm::sys::fs::AutoPerThreadSystem pts(msf.get());
  4501. IFTLLVM(pts.error_code());
  4502. std::wstring suitePath = L"..\\CodeGenHLSL\\shader-compat-suite";
  4503. WEX::Common::String value;
  4504. if (!DXC_FAILED(RuntimeParameters::TryGetValue(L"SuitePath", value)))
  4505. {
  4506. suitePath = value;
  4507. }
  4508. CW2A pUtf8Filename(suitePath.c_str());
  4509. if (!llvm::sys::path::is_absolute(pUtf8Filename.m_psz)) {
  4510. suitePath = hlsl_test::GetPathToHlslDataFile(suitePath.c_str());
  4511. }
  4512. CW2A utf8SuitePath(suitePath.c_str());
  4513. std::error_code EC;
  4514. llvm::SmallString<128> DirNative;
  4515. llvm::sys::path::native(utf8SuitePath.m_psz, DirNative);
  4516. for (llvm::sys::fs::recursive_directory_iterator Dir(DirNative, EC), DirEnd;
  4517. Dir != DirEnd && !EC; Dir.increment(EC)) {
  4518. // Check whether this entry has an extension typically associated with
  4519. // headers.
  4520. if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
  4521. .Cases(".hlsl", ".hlsl", true)
  4522. .Default(false))
  4523. continue;
  4524. StringRef filename = Dir->path();
  4525. CA2W wRelPath(filename.data());
  4526. CodeGenTestCheckBatch(wRelPath.m_psz, 0);
  4527. }
  4528. }
  4529. TEST_F(CompilerTest, SingleFileCheckTest) {
  4530. using namespace llvm;
  4531. using namespace WEX::TestExecution;
  4532. WEX::Common::String value;
  4533. VERIFY_SUCCEEDED(RuntimeParameters::TryGetValue(L"InputFile", value));
  4534. std::wstring filename = value;
  4535. CW2A pUtf8Filename(filename.c_str());
  4536. if (!llvm::sys::path::is_absolute(pUtf8Filename.m_psz)) {
  4537. filename = hlsl_test::GetPathToHlslDataFile(filename.c_str());
  4538. }
  4539. CodeGenTestCheckBatch(filename.c_str(), 0);
  4540. }