| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052 |
- // Copyright (c) 2017 Google Inc.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- // Tests validation rules of GLSL.450.std and OpenCL.std extended instructions.
- // Doesn't test OpenCL.std vector size 2, 3, 4, 8 or 16 rules (not supported
- // by standard SPIR-V).
- #include <sstream>
- #include <string>
- #include <vector>
- #include "gmock/gmock.h"
- #include "spirv-tools/libspirv.h"
- #include "test/unit_spirv.h"
- #include "test/val/val_fixtures.h"
- namespace spvtools {
- namespace val {
- namespace {
- using ::testing::Eq;
- using ::testing::HasSubstr;
- using ::testing::Not;
- using ValidateOldDebugInfo = spvtest::ValidateBase<std::string>;
- using ValidateOpenCL100DebugInfo = spvtest::ValidateBase<std::string>;
- using ValidateXDebugInfo = spvtest::ValidateBase<std::string>;
- using ValidateLocalDebugInfoOutOfFunction = spvtest::ValidateBase<std::string>;
- using ValidateOpenCL100DebugInfoDebugTypedef =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugTypedef =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeEnum =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugTypeEnum =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeComposite =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugTypeComposite =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeMember =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugTypeMember =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeInheritance =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugFunction =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugFunction =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugFunctionDeclaration =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugFunctionDeclaration =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugLexicalBlock =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugLexicalBlock =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugLocalVariable =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugLocalVariable =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugGlobalVariable =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugGlobalVariable =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugDeclare =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugDeclare =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugValue =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfoDebugValue =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateVulkan100DebugInfo = spvtest::ValidateBase<std::string>;
- const static std::string shader_extension = R"(
- OpExtension "SPV_KHR_non_semantic_info"
- %DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
- )";
- const static std::string opencl_extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- std::string GenerateShaderCodeForDebugInfo(
- const std::string& op_string_instructions,
- const std::string& op_const_instructions,
- const std::string& debug_instructions_before_main, const std::string& body,
- const std::string& capabilities_and_extensions = "",
- const std::string& execution_model = "Fragment") {
- std::ostringstream ss;
- ss << R"(
- OpCapability Shader
- OpCapability Float16
- OpCapability Float64
- OpCapability Int16
- OpCapability Int64
- )";
- ss << capabilities_and_extensions;
- ss << "%extinst = OpExtInstImport \"GLSL.std.450\"\n";
- ss << "OpMemoryModel Logical GLSL450\n";
- ss << "OpEntryPoint " << execution_model << " %main \"main\""
- << " %f32_output"
- << " %f32vec2_output"
- << " %u32_output"
- << " %u32vec2_output"
- << " %u64_output"
- << " %f32_input"
- << " %f32vec2_input"
- << " %u32_input"
- << " %u32vec2_input"
- << " %u64_input"
- << "\n";
- if (execution_model == "Fragment") {
- ss << "OpExecutionMode %main OriginUpperLeft\n";
- }
- ss << "%main_name = OpString \"main\"\n";
- ss << op_string_instructions;
- ss << R"(
- %void = OpTypeVoid
- %func = OpTypeFunction %void
- %bool = OpTypeBool
- %f16 = OpTypeFloat 16
- %f32 = OpTypeFloat 32
- %f64 = OpTypeFloat 64
- %u32 = OpTypeInt 32 0
- %s32 = OpTypeInt 32 1
- %u64 = OpTypeInt 64 0
- %s64 = OpTypeInt 64 1
- %u16 = OpTypeInt 16 0
- %s16 = OpTypeInt 16 1
- %f32vec2 = OpTypeVector %f32 2
- %f32vec3 = OpTypeVector %f32 3
- %f32vec4 = OpTypeVector %f32 4
- %f64vec2 = OpTypeVector %f64 2
- %f64vec3 = OpTypeVector %f64 3
- %f64vec4 = OpTypeVector %f64 4
- %u32vec2 = OpTypeVector %u32 2
- %u32vec3 = OpTypeVector %u32 3
- %s32vec2 = OpTypeVector %s32 2
- %u32vec4 = OpTypeVector %u32 4
- %s32vec4 = OpTypeVector %s32 4
- %u64vec2 = OpTypeVector %u64 2
- %s64vec2 = OpTypeVector %s64 2
- %f64mat22 = OpTypeMatrix %f64vec2 2
- %f32mat22 = OpTypeMatrix %f32vec2 2
- %f32mat23 = OpTypeMatrix %f32vec2 3
- %f32mat32 = OpTypeMatrix %f32vec3 2
- %f32mat33 = OpTypeMatrix %f32vec3 3
- %f32_0 = OpConstant %f32 0
- %f32_1 = OpConstant %f32 1
- %f32_2 = OpConstant %f32 2
- %f32_3 = OpConstant %f32 3
- %f32_4 = OpConstant %f32 4
- %f32_h = OpConstant %f32 0.5
- %f32vec2_01 = OpConstantComposite %f32vec2 %f32_0 %f32_1
- %f32vec2_12 = OpConstantComposite %f32vec2 %f32_1 %f32_2
- %f32vec3_012 = OpConstantComposite %f32vec3 %f32_0 %f32_1 %f32_2
- %f32vec3_123 = OpConstantComposite %f32vec3 %f32_1 %f32_2 %f32_3
- %f32vec4_0123 = OpConstantComposite %f32vec4 %f32_0 %f32_1 %f32_2 %f32_3
- %f32vec4_1234 = OpConstantComposite %f32vec4 %f32_1 %f32_2 %f32_3 %f32_4
- %f64_0 = OpConstant %f64 0
- %f64_1 = OpConstant %f64 1
- %f64_2 = OpConstant %f64 2
- %f64_3 = OpConstant %f64 3
- %f64vec2_01 = OpConstantComposite %f64vec2 %f64_0 %f64_1
- %f64vec3_012 = OpConstantComposite %f64vec3 %f64_0 %f64_1 %f64_2
- %f64vec4_0123 = OpConstantComposite %f64vec4 %f64_0 %f64_1 %f64_2 %f64_3
- %f16_0 = OpConstant %f16 0
- %f16_1 = OpConstant %f16 1
- %f16_h = OpConstant %f16 0.5
- %u32_0 = OpConstant %u32 0
- %u32_1 = OpConstant %u32 1
- %u32_2 = OpConstant %u32 2
- %u32_3 = OpConstant %u32 3
- %u32_4 = OpConstant %u32 4
- %u32_5 = OpConstant %u32 5
- %u32_32 = OpConstant %u32 32
- %s32_0 = OpConstant %s32 0
- %s32_1 = OpConstant %s32 1
- %s32_2 = OpConstant %s32 2
- %s32_3 = OpConstant %s32 3
- %u64_0 = OpConstant %u64 0
- %u64_1 = OpConstant %u64 1
- %u64_2 = OpConstant %u64 2
- %u64_3 = OpConstant %u64 3
- %s64_0 = OpConstant %s64 0
- %s64_1 = OpConstant %s64 1
- %s64_2 = OpConstant %s64 2
- %s64_3 = OpConstant %s64 3
- )";
- ss << op_const_instructions;
- ss << R"(
- %s32vec2_01 = OpConstantComposite %s32vec2 %s32_0 %s32_1
- %u32vec2_01 = OpConstantComposite %u32vec2 %u32_0 %u32_1
- %s32vec2_12 = OpConstantComposite %s32vec2 %s32_1 %s32_2
- %u32vec2_12 = OpConstantComposite %u32vec2 %u32_1 %u32_2
- %s32vec4_0123 = OpConstantComposite %s32vec4 %s32_0 %s32_1 %s32_2 %s32_3
- %u32vec4_0123 = OpConstantComposite %u32vec4 %u32_0 %u32_1 %u32_2 %u32_3
- %s64vec2_01 = OpConstantComposite %s64vec2 %s64_0 %s64_1
- %u64vec2_01 = OpConstantComposite %u64vec2 %u64_0 %u64_1
- %f32mat22_1212 = OpConstantComposite %f32mat22 %f32vec2_12 %f32vec2_12
- %f32mat23_121212 = OpConstantComposite %f32mat23 %f32vec2_12 %f32vec2_12 %f32vec2_12
- %f32_ptr_output = OpTypePointer Output %f32
- %f32vec2_ptr_output = OpTypePointer Output %f32vec2
- %u32_ptr_output = OpTypePointer Output %u32
- %u32vec2_ptr_output = OpTypePointer Output %u32vec2
- %u64_ptr_output = OpTypePointer Output %u64
- %f32_output = OpVariable %f32_ptr_output Output
- %f32vec2_output = OpVariable %f32vec2_ptr_output Output
- %u32_output = OpVariable %u32_ptr_output Output
- %u32vec2_output = OpVariable %u32vec2_ptr_output Output
- %u64_output = OpVariable %u64_ptr_output Output
- %f32_ptr_input = OpTypePointer Input %f32
- %f32vec2_ptr_input = OpTypePointer Input %f32vec2
- %u32_ptr_input = OpTypePointer Input %u32
- %u32vec2_ptr_input = OpTypePointer Input %u32vec2
- %u64_ptr_input = OpTypePointer Input %u64
- %f32_ptr_function = OpTypePointer Function %f32
- %f32_input = OpVariable %f32_ptr_input Input
- %f32vec2_input = OpVariable %f32vec2_ptr_input Input
- %u32_input = OpVariable %u32_ptr_input Input
- %u32vec2_input = OpVariable %u32vec2_ptr_input Input
- %u64_input = OpVariable %u64_ptr_input Input
- %u32_ptr_function = OpTypePointer Function %u32
- %struct_f16_u16 = OpTypeStruct %f16 %u16
- %struct_f32_f32 = OpTypeStruct %f32 %f32
- %struct_f32_f32_f32 = OpTypeStruct %f32 %f32 %f32
- %struct_f32_u32 = OpTypeStruct %f32 %u32
- %struct_f32_u32_f32 = OpTypeStruct %f32 %u32 %f32
- %struct_u32_f32 = OpTypeStruct %u32 %f32
- %struct_u32_u32 = OpTypeStruct %u32 %u32
- %struct_f32_f64 = OpTypeStruct %f32 %f64
- %struct_f32vec2_f32vec2 = OpTypeStruct %f32vec2 %f32vec2
- %struct_f32vec2_u32vec2 = OpTypeStruct %f32vec2 %u32vec2
- )";
- ss << debug_instructions_before_main;
- ss << R"(
- %main = OpFunction %void None %func
- %main_entry = OpLabel
- )";
- ss << body;
- ss << R"(
- OpReturn
- OpFunctionEnd)";
- return ss.str();
- }
- TEST_F(ValidateOldDebugInfo, UseDebugInstructionOutOfFunction) {
- const std::string src = R"(
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %cu = OpExtInst %void %DbgExt DebugCompilationUnit %code 1 1
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "DebugInfo"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, UseDebugInstructionOutOfFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugSourceInFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", "", dbg_inst, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("Debug info extension instructions other than DebugScope, "
- "DebugNoScope, DebugDeclare, DebugValue must appear between "
- "section 9 (types, constants, global variables) and section 10 "
- "(function declarations)"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugSourceInFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", "", dbg_inst, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("Debug info extension instructions other than DebugScope, "
- "DebugNoScope, DebugDeclare, DebugValue must appear between "
- "section 9 (types, constants, global variables) and section 10 "
- "(function declarations)"));
- }
- TEST_P(ValidateLocalDebugInfoOutOfFunction, OpenCLDebugInfo100DebugScope) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- %int_name = OpString "int"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 Signed
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src 1 1 %main_info FlagIsLocal
- %expr = OpExtInst %void %DbgExt DebugExpression
- )";
- const std::string body = R"(
- %foo = OpVariable %u32_ptr_function Function
- %foo_val = OpLoad %u32 %foo
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header + GetParam(), body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue "
- "of debug info extension must appear in a function "
- "body"));
- }
- TEST_P(ValidateLocalDebugInfoOutOfFunction, VulkanDebugInfo100DebugScope) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- %int_name = OpString "int"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 %u32_1 %u32_0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %int_info %dbg_src %u32_1 %u32_1 %main_info %u32_4
- %expr = OpExtInst %void %DbgExt DebugExpression
- )";
- const std::string body = R"(
- %foo = OpVariable %u32_ptr_function Function
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main
- %foo_val = OpLoad %u32 %foo
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header + GetParam(), body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugScope, DebugNoScope, DebugDeclare, DebugValue "
- "of debug info extension must appear in a function "
- "body"));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllLocalDebugInfo, ValidateLocalDebugInfoOutOfFunction,
- ::testing::ValuesIn(std::vector<std::string>{
- "%main_scope = OpExtInst %void %DbgExt DebugScope %main_info",
- "%no_scope = OpExtInst %void %DbgExt DebugNoScope",
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionForwardReference) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionMissingOpFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbgNone = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %dbgNone
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugScopeBeforeOpVariableInFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info
- %foo = OpVariable %f32_ptr_function Function
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeSizeDebugInfoNone) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %ty_name = OpString "struct VS_OUTPUT"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeForwardReference) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- float4 color : COLOR;
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_color_name = OpString "color : COLOR"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %VS_OUTPUT_color_info
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic
- %VS_OUTPUT_color_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_color_name %v4float_info %dbg_src 3 3 %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeMissingReference) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- float4 color : COLOR;
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_color_name = OpString "color : COLOR"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %VS_OUTPUT_color_info
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("forward referenced IDs have not been defined"));
- }
- TEST_P(ValidateXDebugInfo, DebugSourceWrongResultType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %bool %DbgExt DebugSource %src %code
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- GetParam(), "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected result type must be a result id of "
- "OpTypeVoid"));
- }
- TEST_P(ValidateXDebugInfo, DebugSourceFailFile) {
- const std::string src = R"(
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %DbgExt %code
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- GetParam(), "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand File must be a result id of "
- "OpString"));
- }
- TEST_P(ValidateXDebugInfo, DebugSourceFailSource) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %DbgExt
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- GetParam(), "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Text must be a result id of "
- "OpString"));
- }
- TEST_P(ValidateXDebugInfo, DebugSourceNoText) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- GetParam(), "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- INSTANTIATE_TEST_SUITE_P(OpenCLAndVkDebugInfo100, ValidateXDebugInfo,
- ::testing::ValuesIn(std::vector<std::string>{
- R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )",
- R"(
- OpExtension "SPV_KHR_non_semantic_info"
- %DbgExt = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
- )",
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnit) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugCompilationUnitFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %src HLSL
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Source must be a result id of "
- "DebugSource"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugCompilationUnitFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %src %u32_5
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Source must be a result id of "
- "DebugSource"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailName) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %int_32 %int_32 Float
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Name must be a result id of "
- "OpString"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailName) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %u32_32 %u32_32 %u32_3 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Name must be a result id of "
- "OpString"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeBasicFailSize) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %float_name Float
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Size must be a result id of "
- "OpConstant"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailSize) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %float_name %u32_3 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Size must be a result id of "
- "OpConstant"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeBasicFailFlags) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() {}"
- %float_name = OpString "float"
- )";
- const std::string constants = R"(
- %f32_32 = OpConstant %f32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_3 %u32_3 %f32_32
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Flags must be a result id of 32-bit "
- "unsigned OpConstant"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointer) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %pfloat_info = OpExtInst %void %DbgExt DebugTypePointer %float_info Function FlagIsLocal
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypePointerFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %pfloat_info = OpExtInst %void %DbgExt DebugTypePointer %dbg_src Function FlagIsLocal
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Base Type is not a valid debug type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifier) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %float_info ConstType
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeQualifierFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %comp_unit ConstType
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Base Type is not a valid debug type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifier) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %float_info %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeQualifierFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float4 main(float arg) {
- float foo;
- return float4(0, 0, 0, 0);
- }
- "
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %cfloat_info = OpExtInst %void %DbgExt DebugTypeQualifier %comp_unit %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Base Type is not a valid debug type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArray) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %int_32
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayWithVariableSize) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %int_name = OpString "int"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %uint_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %int_32 Unsigned
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %uint_info %dbg_src 1 1 %main_info FlagIsLocal
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailBaseType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %comp_unit %int_32
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Base Type is not a valid debug "
- "type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCount) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountFloat) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %f32_4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailComponentCountZero) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 1 %main_info FlagIsLocal
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArray) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_32
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayWithVariableSize) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %uint_name = OpString "uint"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_6 = OpConstant %u32 6
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %uint_info = OpExtInst %void %DbgExt DebugTypeBasic %uint_name %u32_32 %u32_6 %u32_0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %uint_info %dbg_src %u32_1 %u32_1 %main_info %u32_4
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailBaseType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %comp_unit %u32_32
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Base Type is not a valid debug "
- "type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCount) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailComponentCountFloat) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %f32_4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayComponentCountZero) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeArrayFailVariableSizeTypeFloat) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_6 = OpConstant %u32 6
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_1 %main_info %u32_4
- %float_arr_info = OpExtInst %void %DbgExt DebugTypeArray %float_info %foo_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be OpConstant with a 32- or "
- "64-bits integer scalar type or DebugGlobalVariable or "
- "DebugLocalVariable with a 32- or 64-bits unsigned "
- "integer scalar type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVector) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Base Type must be a result id of "
- "DebugTypeBasic"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentZero) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Base Type must be a result id of "
- "DebugTypeBasic"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeVectorFailComponentFive) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src 5
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Base Type must be a result id of "
- "DebugTypeBasic"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeVector) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %dbg_src %u32_4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Base Type must be a result id of "
- "DebugTypeBasic"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentZero) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be positive "
- "integer less than or equal to 4"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeVectorFailComponentFive) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_5
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Component Count must be positive "
- "integer less than or equal to 4"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrix) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string constants = R"(
- %true = OpConstantTrue %bool
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_4 %true
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorTypeType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string constants = R"(
- %true = OpConstantTrue %bool
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %dbg_src %u32_4 %true
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Vector Type must be a result id of "
- "DebugTypeVector"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string constants = R"(
- %true = OpConstantTrue %bool
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %dbg_src %true
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Vector Count must be a result id of "
- "32-bit unsigned OpConstant"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountZero) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string constants = R"(
- %true = OpConstantTrue %bool
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_0 %true
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Vector Count must be positive "
- "integer less than or equal to 4"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeMatrixFailVectorCountFive) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string constants = R"(
- %true = OpConstantTrue %bool
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %vfloat_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %mfloat_info = OpExtInst %void %DbgExt DebugTypeMatrix %vfloat_info %u32_5 %true
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Vector Count must be positive "
- "integer less than or equal to 4"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypedef) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info = OpExtInst %void %DbgExt DebugTypedef %foo_name %float_info %dbg_src 1 1 %comp_unit
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugTypedef, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info = OpExtInst %void %DbgExt DebugTypedef )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second +
- " must be a result id of "));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypedef,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%dbg_src %float_info %dbg_src 1 1 %comp_unit)",
- "Name"),
- std::make_pair(R"(%foo_name %dbg_src %dbg_src 1 1 %comp_unit)",
- "Base Type"),
- std::make_pair(R"(%foo_name %float_info %comp_unit 1 1 %comp_unit)",
- "Source"),
- std::make_pair(R"(%foo_name %float_info %dbg_src 1 1 %dbg_src)",
- "Parent"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugTypedef) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo_info = OpExtInst %void %DbgExt DebugTypedef %foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugTypedef, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo_info = OpExtInst %void %DbgExt DebugTypedef )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second +
- " must be a result id of "));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugTypedef,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src %float_info %dbg_src %u32_1 %u32_1 %comp_unit)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src %u32_1 %u32_1 %comp_unit)",
- "Base Type"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit %u32_1 %u32_1 %comp_unit)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %dbg_src)",
- "Parent"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %main_type_info1 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_type_info2 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info
- %main_type_info3 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %float_info
- %main_type_info4 = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void %float_info %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailReturn) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %dbg_src %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Return Type is not a valid debug type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailParam) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %float_info %void
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Parameter Types is not a valid debug type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionAndParams) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %main_type_info1 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_type_info2 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info
- %main_type_info3 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %float_info
- %main_type_info4 = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void %float_info %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailReturn) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %dbg_src %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Return Type is not a valid debug type"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeFunctionFailParam) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %float_info %void
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("expected operand Parameter Types is not a valid debug type"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeEnum) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %none = OpExtInst %void %DbgExt DebugInfoNone
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info1 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name %u32_1 %foo_name
- %foo_info2 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name %u32_1 %foo_name
- %foo_info3 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugTypeEnum, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info = OpExtInst %void %DbgExt DebugTypeEnum )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypeEnum,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name)",
- "Underlying Types"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %foo_name)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 1 1 %dbg_src %int_32 FlagIsPublic %u32_0 %foo_name)",
- "Parent"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %void FlagIsPublic %u32_0 %foo_name)",
- "Size"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %u32_0 FlagIsPublic %u32_0 %foo_name)",
- "Size"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %foo_name %foo_name)",
- "Value"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 1 1 %comp_unit %int_32 FlagIsPublic %u32_0 %u32_1)",
- "Name"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeEnum) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %none = OpExtInst %void %DbgExt DebugInfoNone
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo_info1 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name %u32_1 %foo_name
- %foo_info2 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name %u32_1 %foo_name
- %foo_info3 = OpExtInst %void %DbgExt DebugTypeEnum %foo_name %none %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugTypeEnum, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo_info = OpExtInst %void %DbgExt DebugTypeEnum )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugTypeEnum,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name)",
- "Underlying Types"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %foo_name)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %dbg_src %u32_32 %u32_3 %u32_0 %foo_name)",
- "Parent"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %void %u32_3 %u32_0 %foo_name)",
- "Size"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_0 %u32_3 %u32_0 %foo_name)",
- "Size"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %foo_name %foo_name)",
- "Value"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_1 %comp_unit %u32_32 %u32_3 %u32_0 %u32_1)",
- "Name"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeCompositeFunctionAndInheritance) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- struct foo : VS_OUTPUT {
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %main_info %child
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main
- %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic
- %child = OpExtInst %void %DbgExt DebugTypeInheritance %foo_info %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugTypeComposite, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- struct foo : VS_OUTPUT {
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite )";
- ss << param.first;
- ss << R"(
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_128 FlagIsPublic
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %v4float_info %float_info
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main
- %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic
- %child = OpExtInst %void %DbgExt DebugTypeInheritance %foo_info %VS_OUTPUT_info %int_128 %int_128 FlagIsPublic
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second + " must be "));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypeComposite,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %main_info %child)",
- "Name"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %comp_unit 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %main_info %child)",
- "Source"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %dbg_src 1 1 %dbg_src %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %main_info %child)",
- "Parent"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %int_128 %int_128 FlagIsPublic %VS_OUTPUT_pos_info %main_info %child)",
- "Linkage Name"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %dbg_src FlagIsPublic %VS_OUTPUT_pos_info %main_info %child)",
- "Size"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %dbg_src %main_info %child)",
- "Members"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %dbg_src %child)",
- "Members"),
- std::make_pair(
- R"(%VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_128 FlagIsPublic %VS_OUTPUT_pos_info %main_info %dbg_src)",
- "Members"),
- }));
- TEST_P(ValidateOpenCL100DebugInfoDebugTypeMember, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float pos : SV_POSITION;
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_linkage_name %int_32 FlagIsPublic %VS_OUTPUT_pos_info
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- if (!param.second.empty()) {
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second +
- " must be a result id of "));
- }
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypeMember,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src %float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_32 FlagIsPublic)",
- "Name"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %dbg_src %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %int_32 FlagIsPublic)",
- ""),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %float_info 2 3 %VS_OUTPUT_info %u32_0 %int_32 FlagIsPublic)",
- "Source"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %dbg_src 2 3 %float_info %u32_0 %int_32 FlagIsPublic)",
- "Parent"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %dbg_src 2 3 %VS_OUTPUT_info %void %int_32 FlagIsPublic)",
- "Offset"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %dbg_src 2 3 %VS_OUTPUT_info %u32_0 %void FlagIsPublic)",
- "Size"),
- }));
- TEST_P(ValidateOpenCL100DebugInfoDebugTypeInheritance, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {};
- struct foo : VS_OUTPUT {};
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %foo_name = OpString "foo"
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name Structure %dbg_src 1 1 %comp_unit %VS_OUTPUT_name %u32_0 FlagIsPublic %child
- %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Structure %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic
- %bar_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Union %dbg_src 1 1 %comp_unit %foo_name %u32_0 FlagIsPublic
- %child = OpExtInst %void %DbgExt DebugTypeInheritance )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugTypeInheritance,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%dbg_src %VS_OUTPUT_info %u32_0 %u32_0 FlagIsPublic)",
- "Child must be a result id of"),
- std::make_pair(R"(%foo_info %dbg_src %u32_0 %u32_0 FlagIsPublic)",
- "Parent must be a result id of"),
- std::make_pair(
- R"(%bar_info %VS_OUTPUT_info %u32_0 %u32_0 FlagIsPublic)",
- "Child must be class or struct debug type"),
- std::make_pair(R"(%foo_info %bar_info %u32_0 %u32_0 FlagIsPublic)",
- "Parent must be class or struct debug type"),
- std::make_pair(R"(%foo_info %VS_OUTPUT_info %void %u32_0 FlagIsPublic)",
- "Offset"),
- std::make_pair(R"(%foo_info %VS_OUTPUT_info %u32_0 %void FlagIsPublic)",
- "Size"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeComposite) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- struct foo : VS_OUTPUT {
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string constants = R"(
- %u32_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src %u32_2 %u32_3 %u32_0 %u32_128 %u32_3
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite %VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %u32_3 %VS_OUTPUT_pos_info
- %foo_info = OpExtInst %void %DbgExt DebugTypeComposite %foo_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %foo_name %u32_0 %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugTypeComposite, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- struct foo : VS_OUTPUT {
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string constants = R"(
- %u32_128 = OpConstant %u32 128
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember %VS_OUTPUT_pos_name %v4float_info %dbg_src %u32_2 %u32_3 %u32_0 %u32_128 %u32_3
- %VS_OUTPUT_info = OpExtInst %void %DbgExt DebugTypeComposite )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second + " must be "));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugTypeComposite,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %u32_3 %VS_OUTPUT_pos_info)",
- "Name"),
- std::make_pair(
- R"(%VS_OUTPUT_name %u32_1 %comp_unit %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %u32_3 %VS_OUTPUT_pos_info)",
- "Source"),
- std::make_pair(
- R"(%VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %dbg_src %VS_OUTPUT_linkage_name %u32_128 %u32_3 %VS_OUTPUT_pos_info)",
- "Parent"),
- std::make_pair(
- R"(%VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %u32_128 %u32_128 %u32_3 %VS_OUTPUT_pos_info)",
- "Linkage Name"),
- std::make_pair(
- R"(%VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %dbg_src %u32_3 %VS_OUTPUT_pos_info)",
- "Size"),
- std::make_pair(
- R"(%VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %dbg_src %VS_OUTPUT_pos_info)",
- "Flags"),
- std::make_pair(
- R"(%VS_OUTPUT_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %VS_OUTPUT_linkage_name %u32_128 %u32_3 %dbg_src)",
- "Members"),
- }));
- TEST_P(ValidateVulkan100DebugInfoDebugTypeMember, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float pos : SV_POSITION;
- };
- main() {}
- "
- %VS_OUTPUT_name = OpString "struct VS_OUTPUT"
- %float_name = OpString "float"
- %VS_OUTPUT_pos_name = OpString "pos : SV_POSITION"
- %VS_OUTPUT_linkage_name = OpString "VS_OUTPUT"
- )";
- const std::string constants = R"(
- %u32_128 = OpConstant %u32 128
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %VS_OUTPUT_pos_info = OpExtInst %void %DbgExt DebugTypeMember )";
- ss << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- if (!param.second.empty()) {
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second +
- " must be a result id of "));
- }
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugTypeMember,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%dbg_src %float_info %dbg_src %u32_2 %u32_3 %u32_0 %u32_32 %u32_3)",
- "Name"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %dbg_src %dbg_src %u32_2 %u32_3 %u32_0 %u32_32 %u32_3)",
- ""),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %float_info %u32_2 %u32_3 %u32_0 %u32_32 %u32_3)",
- "Source"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %dbg_src %u32_2 %u32_3 %void %u32_32 %u32_3)",
- "Offset"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %dbg_src %u32_2 %u32_3 %u32_0 %void %u32_3)",
- "Size"),
- std::make_pair(
- R"(%VS_OUTPUT_pos_name %float_info %dbg_src %u32_2 %u32_3 %u32_0 %u32_32 %void)",
- "Flags"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionDeclaration) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugFunction, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic
- %main_info = OpExtInst %void %DbgExt DebugFunction )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugFunction,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)",
- "Name"),
- std::make_pair(
- R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main)",
- "Type"),
- std::make_pair(
- R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_name FlagIsPublic 13 %main)",
- "Source"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_name FlagIsPublic 13 %main)",
- "Parent"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic 13 %main)",
- "Linkage Name"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %void)",
- "Function"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic 13 %main %dbg_src)",
- "Declaration"),
- }));
- TEST_P(ValidateOpenCL100DebugInfoDebugFunctionDeclaration, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail,
- ValidateOpenCL100DebugInfoDebugFunctionDeclaration,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%u32_0 %main_type_info %dbg_src 12 1 %comp_unit %main_name FlagIsPublic)",
- "Name"),
- std::make_pair(
- R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_name FlagIsPublic)",
- "Type"),
- std::make_pair(
- R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_name FlagIsPublic)",
- "Source"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_name FlagIsPublic)",
- "Parent"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic)",
- "Linkage Name"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDeclaration) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- )";
- const std::string constants = R"(
- %u32_12 = OpConstant %u32 12
- %u32_13 = OpConstant %u32 13
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugFunction, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- )";
- const std::string constants = R"(
- %u32_12 = OpConstant %u32 12
- %u32_13 = OpConstant %u32 13
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration %main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3
- %main_info = OpExtInst %void %DbgExt DebugFunction )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugFunction,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)",
- "Name"),
- std::make_pair(
- R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)",
- "Type"),
- std::make_pair(
- R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13)",
- "Source"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_name %u32_3 %u32_13)",
- "Parent"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %void %u32_3 %u32_13)",
- "Linkage Name"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3 %u32_13 %dbg_src)",
- "Declaration"),
- }));
- TEST_P(ValidateVulkan100DebugInfoDebugFunctionDeclaration, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- )";
- const std::string constants = R"(
- %u32_12 = OpConstant %u32 12
- %u32_13 = OpConstant %u32 13
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_decl = OpExtInst %void %DbgExt DebugFunctionDeclaration )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail,
- ValidateVulkan100DebugInfoDebugFunctionDeclaration,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%u32_0 %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3)",
- "Name"),
- std::make_pair(
- R"(%main_name %dbg_src %dbg_src %u32_12 %u32_1 %comp_unit %main_name %u32_3)",
- "Type"),
- std::make_pair(
- R"(%main_name %main_type_info %comp_unit %u32_12 %u32_1 %comp_unit %main_name %u32_3)",
- "Source"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %dbg_src %main_name %u32_3)",
- "Parent"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src %u32_12 %u32_1 %comp_unit %void %u32_3)",
- "Linkage Name"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %float_name = OpString "float"
- %uint_name = OpString "uint"
- )";
- const std::string constants = R"(
- %u32_6 = OpConstant %u32 6
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %uint_info = OpExtInst %void %DbgExt DebugTypeBasic %uint_name %u32_32 %u32_6 %u32_0
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %uint_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunction: expected operand Type must be a result "
- "id of DebugTypeFunction"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugLexicalBlock) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_block = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src 1 1 %comp_unit %main_name)";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugLexicalBlock, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_block = OpExtInst %void %DbgExt DebugLexicalBlock )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugLexicalBlock,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%comp_unit 1 1 %comp_unit %main_name)", "Source"),
- std::make_pair(R"(%dbg_src 1 1 %dbg_src %main_name)", "Parent"),
- std::make_pair(R"(%dbg_src 1 1 %comp_unit %void)", "Name"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugScopeFailScope) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %dbg_src
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugScopeFailInlinedAt) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %comp_unit %dbg_src
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined At"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLexicalBlock) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_block = OpExtInst %void %DbgExt DebugLexicalBlock %dbg_src %u32_1 %u32_1 %comp_unit %main_name
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugLexicalBlock, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_block = OpExtInst %void %DbgExt DebugLexicalBlock )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugLexicalBlock,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%comp_unit %u32_1 %u32_1 %comp_unit %main_name)",
- "Source"),
- std::make_pair(R"(%dbg_src %u32_1 %u32_1 %dbg_src %main_name)",
- "Parent"),
- std::make_pair(R"(%dbg_src %u32_1 %u32_1 %comp_unit %void)", "Name"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailScope) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %dbg_src
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugScopeFailInlinedAt) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %comp_unit %dbg_src
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined At"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugLocalVariable) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugLocalVariable, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo = OpExtInst %void %DbgExt DebugLocalVariable )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugLocalVariable,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%void %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src 1 10 %comp_unit FlagIsLocal 0)",
- "Type"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit 1 10 %comp_unit FlagIsLocal 0)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 1 10 %dbg_src FlagIsLocal 0)",
- "Parent"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugLocalVariable) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugLocalVariable, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo = OpExtInst %void %DbgExt DebugLocalVariable )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugLocalVariable,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%void %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_3 %u32_0)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src %u32_1 %u32_10 %comp_unit %u32_3 %u32_0)",
- "Type"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit %u32_1 %u32_10 %comp_unit %u32_3 %u32_0)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_1 %u32_10 %dbg_src %u32_3 %u32_0)",
- "Parent"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugDeclare) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0
- )";
- const std::string body = R"(
- %foo = OpVariable %f32_ptr_function Function
- %decl = OpExtInst %void %DbgExt DebugDeclare %foo_info %foo %null_expr
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugDeclareParam) {
- CompileSuccessfully(R"(
- OpCapability Shader
- %1 = OpExtInstImport "OpenCL.DebugInfo.100"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %main "main" %in_var_COLOR
- %4 = OpString "test.hlsl"
- OpSource HLSL 620 %4 "#line 1 \"test.hlsl\"
- void main(float foo:COLOR) {}
- "
- %11 = OpString "#line 1 \"test.hlsl\"
- void main(float foo:COLOR) {}
- "
- %14 = OpString "float"
- %17 = OpString "src.main"
- %20 = OpString "foo"
- OpName %in_var_COLOR "in.var.COLOR"
- OpName %main "main"
- OpName %param_var_foo "param.var.foo"
- OpName %src_main "src.main"
- OpName %foo "foo"
- OpName %bb_entry "bb.entry"
- OpDecorate %in_var_COLOR Location 0
- %uint = OpTypeInt 32 0
- %uint_32 = OpConstant %uint 32
- %float = OpTypeFloat 32
- %_ptr_Input_float = OpTypePointer Input %float
- %void = OpTypeVoid
- %23 = OpTypeFunction %void
- %_ptr_Function_float = OpTypePointer Function %float
- %29 = OpTypeFunction %void %_ptr_Function_float
- OpLine %4 1 21
- %in_var_COLOR = OpVariable %_ptr_Input_float Input
- %10 = OpExtInst %void %1 DebugExpression
- %12 = OpExtInst %void %1 DebugSource %4 %11
- %13 = OpExtInst %void %1 DebugCompilationUnit 1 4 %12 HLSL
- %15 = OpExtInst %void %1 DebugTypeBasic %14 %uint_32 Float
- %16 = OpExtInst %void %1 DebugTypeFunction FlagIsProtected|FlagIsPrivate %void %15
- %18 = OpExtInst %void %1 DebugFunction %17 %16 %12 1 1 %13 %17 FlagIsProtected|FlagIsPrivate 1 %src_main
- %21 = OpExtInst %void %1 DebugLocalVariable %20 %15 %12 1 17 %18 FlagIsLocal 0
- %22 = OpExtInst %void %1 DebugLexicalBlock %12 1 28 %18
- OpLine %4 1 1
- %main = OpFunction %void None %23
- %24 = OpLabel
- OpLine %4 1 17
- %param_var_foo = OpVariable %_ptr_Function_float Function
- %27 = OpLoad %float %in_var_COLOR
- OpLine %4 1 1
- %28 = OpFunctionCall %void %src_main %param_var_foo
- OpReturn
- OpFunctionEnd
- %src_main = OpFunction %void None %29
- OpLine %4 1 17
- %foo = OpFunctionParameter %_ptr_Function_float
- %31 = OpExtInst %void %1 DebugDeclare %21 %foo %10
- %bb_entry = OpLabel
- OpLine %4 1 29
- OpReturn
- OpFunctionEnd
- )");
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugDeclare, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %foo = OpVariable %f32_ptr_function Function
- %decl = OpExtInst %void %DbgExt DebugDeclare )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, ss.str(), opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugDeclare,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%dbg_src %foo %null_expr)", "Local Variable"),
- std::make_pair(R"(%foo_info %void %null_expr)", "Variable"),
- std::make_pair(R"(%foo_info %foo %dbg_src)", "Expression"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugDeclare) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4
- )";
- const std::string body = R"(
- %foo = OpVariable %f32_ptr_function Function
- %decl = OpExtInst %void %DbgExt DebugDeclare %foo_info %foo %null_expr
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugDeclareParam) {
- CompileSuccessfully(R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %main "main" %in_var_COLOR
- %4 = OpString "test.hlsl"
- OpSource HLSL 620 %4 "#line 1 \"test.hlsl\"
- void main(float foo:COLOR) {}
- "
- %11 = OpString "#line 1 \"test.hlsl\"
- void main(float foo:COLOR) {}
- "
- %14 = OpString "float"
- %17 = OpString "src.main"
- %20 = OpString "foo"
- OpName %in_var_COLOR "in.var.COLOR"
- OpName %main "main"
- OpName %param_var_foo "param.var.foo"
- OpName %src_main "src.main"
- OpName %foo "foo"
- OpName %bb_entry "bb.entry"
- OpDecorate %in_var_COLOR Location 0
- %uint = OpTypeInt 32 0
- %u32_0 = OpConstant %uint 0
- %u32_1 = OpConstant %uint 1
- %u32_2 = OpConstant %uint 2
- %u32_3 = OpConstant %uint 3
- %u32_4 = OpConstant %uint 4
- %u32_5 = OpConstant %uint 5
- %u32_10 = OpConstant %uint 10
- %u32_17 = OpConstant %uint 17
- %u32_28 = OpConstant %uint 28
- %u32_32 = OpConstant %uint 32
- %uint_32 = OpConstant %uint 32
- %float = OpTypeFloat 32
- %_ptr_Input_float = OpTypePointer Input %float
- %void = OpTypeVoid
- %23 = OpTypeFunction %void
- %_ptr_Function_float = OpTypePointer Function %float
- %29 = OpTypeFunction %void %_ptr_Function_float
- OpLine %4 1 21
- %in_var_COLOR = OpVariable %_ptr_Input_float Input
- %10 = OpExtInst %void %1 DebugExpression
- %12 = OpExtInst %void %1 DebugSource %4 %11
- %13 = OpExtInst %void %1 DebugCompilationUnit %u32_1 %u32_4 %12 %u32_5
- %15 = OpExtInst %void %1 DebugTypeBasic %14 %uint_32 %u32_3 %u32_0
- %16 = OpExtInst %void %1 DebugTypeFunction %u32_3 %void %15
- %18 = OpExtInst %void %1 DebugFunction %17 %16 %12 %u32_1 %u32_1 %13 %17 %u32_3 %u32_1
- %21 = OpExtInst %void %1 DebugLocalVariable %20 %15 %12 %u32_1 %u32_17 %18 %u32_4 %u32_0
- %22 = OpExtInst %void %1 DebugLexicalBlock %12 %u32_1 %u32_28 %18
- %main = OpFunction %void None %23
- %24 = OpLabel
- %param_var_foo = OpVariable %_ptr_Function_float Function
- %27 = OpLoad %float %in_var_COLOR
- %28 = OpFunctionCall %void %src_main %param_var_foo
- OpReturn
- OpFunctionEnd
- %src_main = OpFunction %void None %29
- %foo = OpFunctionParameter %_ptr_Function_float
- %31 = OpExtInst %void %1 DebugDeclare %21 %foo %10
- %bb_entry = OpLabel
- OpReturn
- OpFunctionEnd
- )");
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugDeclare, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %foo = OpVariable %f32_ptr_function Function
- %decl = OpExtInst %void %DbgExt DebugDeclare )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, ss.str(), shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllVulkan100DebugInfoFail, ValidateVulkan100DebugInfoDebugDeclare,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%dbg_src %foo %null_expr)", "Local Variable"),
- std::make_pair(R"(%foo_info %void %null_expr)", "Variable"),
- std::make_pair(R"(%foo_info %foo %dbg_src)", "Expression"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugExpression) {
- const std::string dbg_inst_header = R"(
- %op0 = OpExtInst %void %DbgExt DebugOperation Deref
- %op1 = OpExtInst %void %DbgExt DebugOperation Plus
- %null_expr = OpExtInst %void %DbgExt DebugExpression %op0 %op1
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- "", "", dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugExpressionFail) {
- const std::string dbg_inst_header = R"(
- %op = OpExtInst %void %DbgExt DebugOperation Deref
- %null_expr = OpExtInst %void %DbgExt DebugExpression %op %void
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- "", "", dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "expected operand Operation must be a result id of DebugOperation"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugExpression) {
- const std::string dbg_inst_header = R"(
- %op0 = OpExtInst %void %DbgExt DebugOperation %u32_0
- %op1 = OpExtInst %void %DbgExt DebugOperation %u32_1
- %null_expr = OpExtInst %void %DbgExt DebugExpression %op0 %op1
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- "", "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugExpressionFail) {
- const std::string dbg_inst_header = R"(
- %op = OpExtInst %void %DbgExt DebugOperation %u32_0
- %null_expr = OpExtInst %void %DbgExt DebugExpression %op %void
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- "", "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "expected operand Operation must be a result id of DebugOperation"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeTemplate) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeTemplateUsedForVariableType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name Class %dbg_src 1 1 %comp_unit %ty_name %dbg_none FlagIsPublic
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %temp %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeTemplateFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %param %param
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %param
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeTemplateFailTarget) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %float_info %param
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Target must be DebugTypeComposite or "
- "DebugFunction"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeTemplateFailParam) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- %int_128 = OpConstant %u32 128
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src 0 0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %param %param
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "expected operand Parameters must be DebugTypeTemplateParameter or "
- "DebugTypeTemplateTemplateParameter"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeTemplate) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeTemplateUsedForVariableType) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %param
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %temp %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeTemplateFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %param %param
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %main_info %param
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeTemplateFailTarget) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %float_info %param
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Target must be DebugTypeComposite or "
- "DebugFunction"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugTypeTemplateFailParam) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "OpaqueType foo;
- main() {}
- "
- %float_name = OpString "float"
- %ty_name = OpString "Texture"
- %t_name = OpString "T"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_none = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %opaque = OpExtInst %void %DbgExt DebugTypeComposite %ty_name %u32_1 %dbg_src %u32_1 %u32_1 %comp_unit %ty_name %dbg_none %u32_3
- %param = OpExtInst %void %DbgExt DebugTypeTemplateParameter %t_name %float_info %dbg_none %dbg_src %u32_0 %u32_0
- %temp = OpExtInst %void %DbgExt DebugTypeTemplate %opaque %float_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "expected operand Parameters must be DebugTypeTemplateParameter or "
- "DebugTypeTemplateTemplateParameter"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariable) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableStaticMember) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %t = OpExtInst %void %DbgExt DebugTypeComposite %foo_name Class %dbg_src 0 0 %comp_unit %foo_name %int_32 FlagIsPublic %a
- %a = OpExtInst %void %DbgExt DebugTypeMember %foo_name %float_info %dbg_src 0 0 %t %u32_0 %int_32 FlagIsPublic
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate %a
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableDebugInfoNone) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbgNone = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %dbgNone FlagIsProtected|FlagIsPrivate
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugGlobalVariableConst) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %int_32 FlagIsProtected|FlagIsPrivate
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugGlobalVariable, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, ss.str(), "", opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugGlobalVariable,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%void %float_info %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate)",
- "Type"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit 0 0 %comp_unit %foo_name %f32_input FlagIsProtected|FlagIsPrivate)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 0 0 %dbg_src %foo_name %f32_input FlagIsProtected|FlagIsPrivate)",
- "Scope"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 0 0 %comp_unit %void %f32_input FlagIsProtected|FlagIsPrivate)",
- "Linkage Name"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src 0 0 %comp_unit %foo_name %void FlagIsProtected|FlagIsPrivate)",
- "Variable"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariable) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableStaticMember) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %a = OpExtInst %void %DbgExt DebugTypeMember %foo_name %float_info %dbg_src %u32_0 %u32_0 %u32_0 %u32_32 %u32_3
- %t = OpExtInst %void %DbgExt DebugTypeComposite %foo_name %u32_1 %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %u32_32 %u32_3 %a
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %t %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableDebugInfoNone) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbgNone = OpExtInst %void %DbgExt DebugInfoNone
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %dbgNone %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugGlobalVariableConst) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable %foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %u32_32 %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugGlobalVariable, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "float foo; void main() {}"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %foo = OpExtInst %void %DbgExt DebugGlobalVariable )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", ss.str(), "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateVulkan100DebugInfoDebugGlobalVariable,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(
- R"(%void %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3)",
- "Name"),
- std::make_pair(
- R"(%foo_name %dbg_src %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3)",
- "Type"),
- std::make_pair(
- R"(%foo_name %float_info %comp_unit %u32_0 %u32_0 %comp_unit %foo_name %f32_input %u32_3)",
- "Source"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_0 %u32_0 %dbg_src %foo_name %f32_input %u32_3)",
- "Scope"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %void %f32_input %u32_3)",
- "Linkage Name"),
- std::make_pair(
- R"(%foo_name %float_info %dbg_src %u32_0 %u32_0 %comp_unit %foo_name %void %u32_3)",
- "Variable"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAt) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info
- %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %inlined_at
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAtFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info
- %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %inlined_at
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugInlinedAtFail2) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction FlagIsPublic %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_name FlagIsPublic 1 %main
- %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info
- %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt 0 %main_info %main_info
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAt) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info
- %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %inlined_at
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info
- %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %inlined_at %inlined_at
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Scope"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugInlinedAtFail2) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %inlined_at = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info
- %inlined_at_recursive = OpExtInst %void %DbgExt DebugInlinedAt %u32_0 %main_info %main_info
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info %inlined_at
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr("expected operand Inlined"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugValue) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_3 = OpConstant %u32 3
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0
- )";
- const std::string body = R"(
- %value = OpExtInst %void %DbgExt DebugValue %foo_info %int_32 %null_expr %int_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugValueWithVariableIndex) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %int_name = OpString "int"
- %foo_name = OpString "foo"
- %len_name = OpString "length"
- )";
- const std::string size_const = R"(
- %int_3 = OpConstant %u32 3
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %int_32 Signed
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info 4
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src 1 10 %comp_unit FlagIsLocal
- %len_info = OpExtInst %void %DbgExt DebugLocalVariable %len_name %int_info %dbg_src 0 0 %comp_unit FlagIsLocal
- )";
- const std::string body = R"(
- %value = OpExtInst %void %DbgExt DebugValue %foo_info %int_32 %null_expr %len_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugValue, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string size_const = R"(
- %int_32 = OpConstant %u32 32
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit 2 4 %dbg_src HLSL
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %int_32 Float
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %float_info %dbg_src 1 10 %comp_unit FlagIsLocal 0
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %decl = OpExtInst %void %DbgExt DebugValue )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, ss.str(), opencl_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateOpenCL100DebugInfoDebugValue,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%dbg_src %int_32 %null_expr)", "Local Variable"),
- std::make_pair(R"(%foo_info %int_32 %dbg_src)", "Expression"),
- std::make_pair(R"(%foo_info %int_32 %null_expr %dbg_src)", "Indexes"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, DebugValue) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4
- )";
- const std::string body = R"(
- %value = OpExtInst %void %DbgExt DebugValue %foo_info %u32_32 %null_expr %u32_3
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugValueWithVariableIndex) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %int_name = OpString "int"
- %foo_name = OpString "foo"
- %len_name = OpString "length"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_32 %u32_4 %u32_0
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 %u32_0
- %len_info = OpExtInst %void %DbgExt DebugLocalVariable %len_name %int_info %dbg_src %u32_0 %u32_0 %comp_unit %u32_4
- )";
- const std::string body = R"(
- %value = OpExtInst %void %DbgExt DebugValue %foo_info %u32_32 %null_expr %len_info
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateVulkan100DebugInfoDebugValue, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() { float foo; }"
- %float_name = OpString "float"
- %foo_name = OpString "foo"
- )";
- const std::string constants = R"(
- %u32_10 = OpConstant %u32 10
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %null_expr = OpExtInst %void %DbgExt DebugExpression
- %float_info = OpExtInst %void %DbgExt DebugTypeBasic %float_name %u32_32 %u32_3 %u32_0
- %v4float_info = OpExtInst %void %DbgExt DebugTypeVector %float_info %u32_4
- %foo_info = OpExtInst %void %DbgExt DebugLocalVariable %foo_name %v4float_info %dbg_src %u32_1 %u32_10 %comp_unit %u32_4 %u32_0
- )";
- const auto& param = GetParam();
- std::ostringstream ss;
- ss << R"(
- %decl = OpExtInst %void %DbgExt DebugValue )"
- << param.first;
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, ss.str(), shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand " + param.second));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllOpenCL100DebugInfoFail, ValidateVulkan100DebugInfoDebugValue,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair(R"(%dbg_src %u32_32 %null_expr %u32_3)",
- "Local Variable"),
- std::make_pair(R"(%foo_info %u32_32 %dbg_src %u32_3)", "Expression"),
- std::make_pair(R"(%foo_info %u32_32 %null_expr %dbg_src)", "Indexes"),
- }));
- TEST_F(ValidateVulkan100DebugInfo, VulkanDebugInfoSample) {
- std::ostringstream ss;
- ss << R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %id_1 = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %id_MainPs "MainPs" %id_in_var_TEXCOORD2 %id_out_var_SV_Target0
- OpExecutionMode %id_MainPs OriginUpperLeft
- %id_7 = OpString "foo.frag"
- %id_27 = OpString "float"
- %id_32 = OpString "vColor"
- %id_36 = OpString "PS_OUTPUT"
- %id_42 = OpString "vTextureCoords"
- %id_46 = OpString "PS_INPUT"
- %id_49 = OpString "MainPs"
- %id_50 = OpString ""
- %id_55 = OpString "ps_output"
- %id_59 = OpString "i"
- %id_63 = OpString "@type.sampler"
- %id_64 = OpString "type.sampler"
- %id_66 = OpString "g_sAniso"
- %id_69 = OpString "@type.2d.image"
- %id_70 = OpString "type.2d.image"
- %id_72 = OpString "TemplateParam"
- %id_75 = OpString "g_tColor"
- OpName %id_type_2d_image "type.2d.image"
- OpName %id_g_tColor "g_tColor"
- OpName %id_type_sampler "type.sampler"
- OpName %id_g_sAniso "g_sAniso"
- OpName %id_in_var_TEXCOORD2 "in.var.TEXCOORD2"
- OpName %id_out_var_SV_Target0 "out.var.SV_Target0"
- OpName %id_MainPs "MainPs"
- OpName %id_PS_INPUT "PS_INPUT"
- OpMemberName %id_PS_INPUT 0 "vTextureCoords"
- OpName %id_param_var_i "param.var.i"
- OpName %id_PS_OUTPUT "PS_OUTPUT"
- OpMemberName %id_PS_OUTPUT 0 "vColor"
- OpName %id_src_MainPs "src.MainPs"
- OpName %id_i "i"
- OpName %id_bb_entry "bb.entry"
- OpName %id_ps_output "ps_output"
- OpName %id_type_sampled_image "type.sampled.image"
- OpDecorate %id_in_var_TEXCOORD2 Location 0
- OpDecorate %id_out_var_SV_Target0 Location 0
- OpDecorate %id_g_tColor DescriptorSet 0
- OpDecorate %id_g_tColor Binding 0
- OpDecorate %id_g_sAniso DescriptorSet 0
- OpDecorate %id_g_sAniso Binding 1
- %id_int = OpTypeInt 32 1
- %id_int_0 = OpConstant %id_int 0
- %id_uint = OpTypeInt 32 0
- %id_uint_32 = OpConstant %id_uint 32
- %id_float = OpTypeFloat 32
- %id_type_2d_image = OpTypeImage %id_float 2D 2 0 0 1 Unknown
- %id__ptr_UniformConstant_type_2d_image = OpTypePointer UniformConstant %id_type_2d_image
- %id_type_sampler = OpTypeSampler
- %id__ptr_UniformConstant_type_sampler = OpTypePointer UniformConstant %id_type_sampler
- %id_v2float = OpTypeVector %id_float 2
- %id__ptr_Input_v2float = OpTypePointer Input %id_v2float
- %id_v4float = OpTypeVector %id_float 4
- %id__ptr_Output_v4float = OpTypePointer Output %id_v4float
- %id_void = OpTypeVoid
- %id_uint_1 = OpConstant %id_uint 1
- %id_uint_4 = OpConstant %id_uint 4
- %id_uint_5 = OpConstant %id_uint 5
- %id_uint_3 = OpConstant %id_uint 3
- %id_uint_0 = OpConstant %id_uint 0
- %id_uint_128 = OpConstant %id_uint 128
- %id_uint_12 = OpConstant %id_uint 12
- %id_uint_10 = OpConstant %id_uint 10
- %id_uint_8 = OpConstant %id_uint 8
- %id_uint_2 = OpConstant %id_uint 2
- %id_uint_64 = OpConstant %id_uint 64
- %id_uint_7 = OpConstant %id_uint 7
- %id_uint_15 = OpConstant %id_uint 15
- %id_uint_16 = OpConstant %id_uint 16
- %id_uint_17 = OpConstant %id_uint 17
- %id_uint_29 = OpConstant %id_uint 29
- %id_uint_14 = OpConstant %id_uint 14
- %id_uint_11 = OpConstant %id_uint 11
- %id_78 = OpTypeFunction %id_void
- %id_PS_INPUT = OpTypeStruct %id_v2float
- %id__ptr_Function_PS_INPUT = OpTypePointer Function %id_PS_INPUT
- %id_PS_OUTPUT = OpTypeStruct %id_v4float
- %id_89 = OpTypeFunction %id_PS_OUTPUT %id__ptr_Function_PS_INPUT
- %id__ptr_Function_PS_OUTPUT = OpTypePointer Function %id_PS_OUTPUT
- %id_uint_20 = OpConstant %id_uint 20
- %id_uint_19 = OpConstant %id_uint 19
- %id_uint_26 = OpConstant %id_uint 26
- %id_uint_46 = OpConstant %id_uint 46
- %id__ptr_Function_v2float = OpTypePointer Function %id_v2float
- %id_uint_57 = OpConstant %id_uint 57
- %id_uint_78 = OpConstant %id_uint 78
- %id_type_sampled_image = OpTypeSampledImage %id_type_2d_image
- %id_uint_81 = OpConstant %id_uint 81
- %id__ptr_Function_v4float = OpTypePointer Function %id_v4float
- %id_g_tColor = OpVariable %id__ptr_UniformConstant_type_2d_image UniformConstant
- %id_g_sAniso = OpVariable %id__ptr_UniformConstant_type_sampler UniformConstant
- %id_in_var_TEXCOORD2 = OpVariable %id__ptr_Input_v2float Input
- %id_out_var_SV_Target0 = OpVariable %id__ptr_Output_v4float Output
- %id_22 = OpExtInst %id_void %id_1 DebugSource %id_7
- %id_23 = OpExtInst %id_void %id_1 DebugCompilationUnit %id_uint_1 %id_uint_4 %id_22 %id_uint_5
- %id_28 = OpExtInst %id_void %id_1 DebugTypeBasic %id_27 %id_uint_32 %id_uint_3 %id_uint_0
- %id_31 = OpExtInst %id_void %id_1 DebugTypeVector %id_28 %id_uint_4
- %id_34 = OpExtInst %id_void %id_1 DebugTypeMember %id_32 %id_31 %id_22 %id_uint_12 %id_uint_12 %id_uint_0 %id_uint_128 %id_uint_3
- %id_37 = OpExtInst %id_void %id_1 DebugTypeComposite %id_36 %id_uint_1 %id_22 %id_uint_10 %id_uint_8 %id_23 %id_36 %id_uint_128 %id_uint_3 %id_34
- %id_40 = OpExtInst %id_void %id_1 DebugTypeVector %id_28 %id_uint_2
- %id_44 = OpExtInst %id_void %id_1 DebugTypeMember %id_42 %id_40 %id_22 %id_uint_7 %id_uint_12 %id_uint_0 %id_uint_64 %id_uint_3
- %id_47 = OpExtInst %id_void %id_1 DebugTypeComposite %id_46 %id_uint_1 %id_22 %id_uint_5 %id_uint_8 %id_23 %id_46 %id_uint_64 %id_uint_3 %id_44
- %id_48 = OpExtInst %id_void %id_1 DebugTypeFunction %id_uint_3 %id_37 %id_47
- %id_51 = OpExtInst %id_void %id_1 DebugFunction %id_49 %id_48 %id_22 %id_uint_15 %id_uint_1 %id_23 %id_50 %id_uint_3 %id_uint_16
- %id_54 = OpExtInst %id_void %id_1 DebugLexicalBlock %id_22 %id_uint_16 %id_uint_1 %id_51
- %id_56 = OpExtInst %id_void %id_1 DebugLocalVariable %id_55 %id_37 %id_22 %id_uint_17 %id_uint_15 %id_54 %id_uint_4
- %id_58 = OpExtInst %id_void %id_1 DebugExpression
- %id_60 = OpExtInst %id_void %id_1 DebugLocalVariable %id_59 %id_47 %id_22 %id_uint_15 %id_uint_29 %id_51 %id_uint_4 %id_uint_1
- %id_62 = OpExtInst %id_void %id_1 DebugInfoNone
- %id_65 = OpExtInst %id_void %id_1 DebugTypeComposite %id_63 %id_uint_1 %id_22 %id_uint_0 %id_uint_0 %id_23 %id_64 %id_62 %id_uint_3
- %id_67 = OpExtInst %id_void %id_1 DebugGlobalVariable %id_66 %id_65 %id_22 %id_uint_3 %id_uint_14 %id_23 %id_66 %id_g_sAniso %id_uint_8
- %id_71 = OpExtInst %id_void %id_1 DebugTypeComposite %id_69 %id_uint_0 %id_22 %id_uint_0 %id_uint_0 %id_23 %id_70 %id_62 %id_uint_3
- %id_73 = OpExtInst %id_void %id_1 DebugTypeTemplateParameter %id_72 %id_31 %id_62 %id_22 %id_uint_0 %id_uint_0
- %id_74 = OpExtInst %id_void %id_1 DebugTypeTemplate %id_71 %id_73
- %id_76 = OpExtInst %id_void %id_1 DebugGlobalVariable %id_75 %id_74 %id_22 %id_uint_1 %id_uint_11 %id_23 %id_75 %id_g_tColor %id_uint_8
- %id_MainPs = OpFunction %id_void None %id_78
- %id_79 = OpLabel
- %id_param_var_i = OpVariable %id__ptr_Function_PS_INPUT Function
- %id_83 = OpLoad %id_v2float %id_in_var_TEXCOORD2
- %id_84 = OpCompositeConstruct %id_PS_INPUT %id_83
- OpStore %id_param_var_i %id_84
- %id_86 = OpFunctionCall %id_PS_OUTPUT %id_src_MainPs %id_param_var_i
- %id_88 = OpCompositeExtract %id_v4float %id_86 0
- OpStore %id_out_var_SV_Target0 %id_88
- OpReturn
- OpFunctionEnd
- %id_src_MainPs = OpFunction %id_PS_OUTPUT None %id_89
- %id_i = OpFunctionParameter %id__ptr_Function_PS_INPUT
- %id_bb_entry = OpLabel
- %id_ps_output = OpVariable %id__ptr_Function_PS_OUTPUT Function
- %id_94 = OpExtInst %id_void %id_1 DebugScope %id_51
- %id_97 = OpExtInst %id_void %id_1 DebugDeclare %id_60 %id_i %id_58
- %id_99 = OpExtInst %id_void %id_1 DebugFunctionDefinition %id_51 %id_src_MainPs
- %id_100 = OpExtInst %id_void %id_1 DebugScope %id_54
- %id_102 = OpExtInst %id_void %id_1 DebugDeclare %id_56 %id_ps_output %id_58
- %id_106 = OpLoad %id_type_2d_image %id_g_tColor
- %id_109 = OpLoad %id_type_sampler %id_g_sAniso
- %id_114 = OpAccessChain %id__ptr_Function_v2float %id_i %id_int_0
- %id_115 = OpLoad %id_v2float %id_114
- %id_119 = OpSampledImage %id_type_sampled_image %id_106 %id_109
- %id_120 = OpImageSampleImplicitLod %id_v4float %id_119 %id_115 None
- %id_123 = OpAccessChain %id__ptr_Function_v4float %id_ps_output %id_int_0
- OpStore %id_123 %id_120
- %id_125 = OpLoad %id_PS_OUTPUT %id_ps_output
- OpReturnValue %id_125
- OpFunctionEnd
- )";
- CompileSuccessfully(ss.str());
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinition) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionFailFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_type_info %main
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunctionDefinition: expected operand Function "
- "must be a result id of DebugFunction"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionFailDefinition) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main_name
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunctionDefinition: expected operand Definition "
- "must be a result id of OpFunction"));
- }
- // TODO - Need to track in function scope
- TEST_F(ValidateVulkan100DebugInfo, DISABLED_DebugFunctionDefinitionDuplicate) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info1 = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %main_info2 = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def1 = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info1 %main
- %main_def2 = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info2 %main
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunctionDefinition: Was used multiple times in "
- "single function block"));
- }
- // TODO - Need to track in function scope
- TEST_F(ValidateVulkan100DebugInfo,
- DISABLED_DebugFunctionDefinitionDuplicateReference) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main
- OpReturn
- OpFunctionEnd
- %foo = OpFunction %void None %func
- %foo_entry = OpLabel
- %foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %foo
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunctionDefinition: Was referenced a "
- "DebugFunction that was already referenced before"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionWrongDefinition) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %foo_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main
- OpReturn
- OpFunctionEnd
- %foo = OpFunction %void None %func
- %foo_entry = OpLabel
- %foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %foo_info %main
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunctionDefinition: operand Definition must "
- "point to the OpFunction it is inside"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionNonEntryBlock) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string constants = R"(
- %false = OpConstantFalse %bool
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- OpSelectionMerge %merge_block None
- OpBranchConditional %false %second_block %merge_block
- %second_block = OpLabel
- OpReturn
- %merge_block = OpLabel
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, constants, dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugFunctionDefinition: must be in the entry basic "
- "block of the function"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugFunctionDefinitionMultiFunctions) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %comp_unit = OpExtInst %void %DbgExt DebugCompilationUnit %u32_2 %u32_4 %dbg_src %u32_5
- %main_type_info = OpExtInst %void %DbgExt DebugTypeFunction %u32_3 %void
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- %foo_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src %u32_1 %u32_1 %comp_unit %main_name %u32_3 %u32_1
- )";
- const std::string body = R"(
- %main_def = OpExtInst %void %DbgExt DebugFunctionDefinition %main_info %main
- OpReturn
- OpFunctionEnd
- %foo = OpFunction %void None %func
- %foo_entry = OpLabel
- %foo_def = OpExtInst %void %DbgExt DebugFunctionDefinition %foo_info %foo
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLine) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0
- %line2 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0
- %no_line = OpExtInst %void %DbgExt DebugNoLine
- %line3 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugNoLineOutOfBlock) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %no_line = OpExtInst %void %DbgExt DebugNoLine
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("debug info extension must appear in a function body"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineOutOfBlock) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %line = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, "", shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_LAYOUT, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("debug info extension must appear in a function body"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineSource) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- %int_name = OpString "int"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %int_info = OpExtInst %void %DbgExt DebugTypeBasic %int_name %u32_0 %u32_1 %u32_0
- )";
- const std::string body = R"(
- %line = OpExtInst %void %DbgExt DebugLine %int_info %u32_2 %u32_2 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugLine: expected operand Source must be a result "
- "id of DebugSource"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineFloat) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %f32_1 %u32_2 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugLine: expected operand Line Start must be a "
- "result id of 32-bit unsigned OpConstant"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineInt64) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u64_1 %u64_1 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugLine: expected operand Line Start must be a "
- "result id of 32-bit unsigned OpConstant"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineSpecConstant) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- %spec_int = OpSpecConstant %u32 2
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %spec_int %u32_1 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugLine: expected operand Line Start must be a "
- "result id of 32-bit unsigned OpConstant"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineLineEndSmaller) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_2 %u32_1 %u32_0 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("DebugLine: operand Line End (1) is less than Line Start (2)"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmaller) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_1 %u32_1 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("DebugLine: operand Column End (0) is less than Column "
- "Start (1) when Line Start equals Line End"));
- }
- TEST_F(ValidateVulkan100DebugInfo, DebugLineColumnEndSmallerMultiline) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "int main() { }"
- )";
- const std::string dbg_inst_header = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %code
- )";
- const std::string body = R"(
- %line1 = OpExtInst %void %DbgExt DebugLine %dbg_src %u32_1 %u32_2 %u32_1 %u32_0
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, shader_extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- } // namespace
- } // namespace val
- } // namespace spvtools
|