| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337 |
- // 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 "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 ValidateExtInst = spvtest::ValidateBase<bool>;
- using ValidateOldDebugInfo = spvtest::ValidateBase<std::string>;
- using ValidateOpenCL100DebugInfo = spvtest::ValidateBase<std::string>;
- using ValidateLocalDebugInfoOutOfFunction = spvtest::ValidateBase<std::string>;
- using ValidateOpenCL100DebugInfoDebugTypedef =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeEnum =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeComposite =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugTypeMember =
- 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 ValidateOpenCL100DebugInfoDebugFunctionDeclaration =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugLexicalBlock =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugLocalVariable =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugGlobalVariable =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugDeclare =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateOpenCL100DebugInfoDebugValue =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- using ValidateGlslStd450SqrtLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450FMinLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450FClampLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450SAbsLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450UMinLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450UClampLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450SinLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450PowLike = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450Pack = spvtest::ValidateBase<std::string>;
- using ValidateGlslStd450Unpack = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdSqrtLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdFMinLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdFClampLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdSAbsLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdUMinLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdUClampLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdUMul24Like = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdUMad24Like = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdLengthLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdDistanceLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdNormalizeLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdVStoreHalfLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdVLoadHalfLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdFractLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdFrexpLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdLdexpLike = spvtest::ValidateBase<std::string>;
- using ValidateOpenCLStdUpsampleLike = spvtest::ValidateBase<std::string>;
- using ValidateClspvReflection = spvtest::ValidateBase<bool>;
- // Returns number of components in Pack/Unpack extended instructions.
- // |ext_inst_name| is expected to be of the format "PackHalf2x16".
- // Number of components is assumed to be single-digit.
- uint32_t GetPackedNumComponents(const std::string& ext_inst_name) {
- const size_t x_index = ext_inst_name.find_last_of('x');
- const std::string num_components_str =
- ext_inst_name.substr(x_index - 1, x_index);
- return uint32_t(std::stoul(num_components_str));
- }
- // Returns packed bit width in Pack/Unpack extended instructions.
- // |ext_inst_name| is expected to be of the format "PackHalf2x16".
- uint32_t GetPackedBitWidth(const std::string& ext_inst_name) {
- const size_t x_index = ext_inst_name.find_last_of('x');
- const std::string packed_bit_width_str = ext_inst_name.substr(x_index + 1);
- return uint32_t(std::stoul(packed_bit_width_str));
- }
- std::string GenerateShaderCode(
- 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 << 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
- %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
- %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_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
- %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
- %main = OpFunction %void None %func
- %main_entry = OpLabel
- )";
- ss << body;
- ss << R"(
- OpReturn
- OpFunctionEnd)";
- return ss.str();
- }
- std::string GenerateKernelCode(
- const std::string& body,
- const std::string& capabilities_and_extensions = "",
- const std::string& memory_model = "Physical32") {
- std::ostringstream ss;
- ss << R"(
- OpCapability Addresses
- OpCapability Kernel
- OpCapability Linkage
- OpCapability GenericPointer
- OpCapability Int8
- OpCapability Int16
- OpCapability Int64
- OpCapability Float16
- OpCapability Float64
- OpCapability Vector16
- OpCapability Matrix
- )";
- ss << capabilities_and_extensions;
- ss << "%extinst = OpExtInstImport \"OpenCL.std\"\n";
- ss << "OpMemoryModel " << memory_model << " OpenCL\n";
- ss << R"(
- %void = OpTypeVoid
- %func = OpTypeFunction %void
- %bool = OpTypeBool
- %f16 = OpTypeFloat 16
- %f32 = OpTypeFloat 32
- %f64 = OpTypeFloat 64
- %u32 = OpTypeInt 32 0
- %u64 = OpTypeInt 64 0
- %u16 = OpTypeInt 16 0
- %u8 = OpTypeInt 8 0
- %f32vec2 = OpTypeVector %f32 2
- %f32vec3 = OpTypeVector %f32 3
- %f32vec4 = OpTypeVector %f32 4
- %f32vec8 = OpTypeVector %f32 8
- %f16vec8 = OpTypeVector %f16 8
- %f32vec16 = OpTypeVector %f32 16
- %f64vec2 = OpTypeVector %f64 2
- %f64vec3 = OpTypeVector %f64 3
- %f64vec4 = OpTypeVector %f64 4
- %u32vec2 = OpTypeVector %u32 2
- %u32vec3 = OpTypeVector %u32 3
- %u32vec4 = OpTypeVector %u32 4
- %u32vec8 = OpTypeVector %u32 8
- %u64vec2 = OpTypeVector %u64 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
- %f32vec8_01010101 = OpConstantComposite %f32vec8 %f32_0 %f32_1 %f32_0 %f32_1 %f32_0 %f32_1 %f32_0 %f32_1
- %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
- %u8_0 = OpConstant %u8 0
- %u8_1 = OpConstant %u8 1
- %u8_2 = OpConstant %u8 2
- %u8_3 = OpConstant %u8 3
- %u16_0 = OpConstant %u16 0
- %u16_1 = OpConstant %u16 1
- %u16_2 = OpConstant %u16 2
- %u16_3 = OpConstant %u16 3
- %u32_0 = OpConstant %u32 0
- %u32_1 = OpConstant %u32 1
- %u32_2 = OpConstant %u32 2
- %u32_3 = OpConstant %u32 3
- %u32_256 = OpConstant %u32 256
- %u64_0 = OpConstant %u64 0
- %u64_1 = OpConstant %u64 1
- %u64_2 = OpConstant %u64 2
- %u64_3 = OpConstant %u64 3
- %u64_256 = OpConstant %u64 256
- %u32vec2_01 = OpConstantComposite %u32vec2 %u32_0 %u32_1
- %u32vec2_12 = OpConstantComposite %u32vec2 %u32_1 %u32_2
- %u32vec3_012 = OpConstantComposite %u32vec3 %u32_0 %u32_1 %u32_2
- %u32vec4_0123 = OpConstantComposite %u32vec4 %u32_0 %u32_1 %u32_2 %u32_3
- %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
- %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
- %f16vec8_ptr_workgroup = OpTypePointer Workgroup %f16vec8
- %f16vec8_workgroup = OpVariable %f16vec8_ptr_workgroup Workgroup
- %f16_ptr_workgroup = OpTypePointer Workgroup %f16
- %u32vec8_ptr_workgroup = OpTypePointer Workgroup %u32vec8
- %u32vec8_workgroup = OpVariable %u32vec8_ptr_workgroup Workgroup
- %u32_ptr_workgroup = OpTypePointer Workgroup %u32
- %f32vec8_ptr_workgroup = OpTypePointer Workgroup %f32vec8
- %f32vec8_workgroup = OpVariable %f32vec8_ptr_workgroup Workgroup
- %f32_ptr_workgroup = OpTypePointer Workgroup %f32
- %u32arr = OpTypeArray %u32 %u32_256
- %u32arr_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %u32arr
- %u32arr_cross_workgroup = OpVariable %u32arr_ptr_cross_workgroup CrossWorkgroup
- %u32_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %u32
- %f32arr = OpTypeArray %f32 %u32_256
- %f32arr_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %f32arr
- %f32arr_cross_workgroup = OpVariable %f32arr_ptr_cross_workgroup CrossWorkgroup
- %f32_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %f32
- %f32vec2arr = OpTypeArray %f32vec2 %u32_256
- %f32vec2arr_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %f32vec2arr
- %f32vec2arr_cross_workgroup = OpVariable %f32vec2arr_ptr_cross_workgroup CrossWorkgroup
- %f32vec2_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %f32vec2
- %struct_arr = OpTypeArray %struct_f32_f32 %u32_256
- %struct_arr_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %struct_arr
- %struct_arr_cross_workgroup = OpVariable %struct_arr_ptr_cross_workgroup CrossWorkgroup
- %struct_ptr_cross_workgroup = OpTypePointer CrossWorkgroup %struct_f32_f32
- %f16vec8_ptr_uniform_constant = OpTypePointer UniformConstant %f16vec8
- %f16vec8_uniform_constant = OpVariable %f16vec8_ptr_uniform_constant UniformConstant
- %f16_ptr_uniform_constant = OpTypePointer UniformConstant %f16
- %u32vec8_ptr_uniform_constant = OpTypePointer UniformConstant %u32vec8
- %u32vec8_uniform_constant = OpVariable %u32vec8_ptr_uniform_constant UniformConstant
- %u32_ptr_uniform_constant = OpTypePointer UniformConstant %u32
- %f32vec8_ptr_uniform_constant = OpTypePointer UniformConstant %f32vec8
- %f32vec8_uniform_constant = OpVariable %f32vec8_ptr_uniform_constant UniformConstant
- %f32_ptr_uniform_constant = OpTypePointer UniformConstant %f32
- %f16vec8_ptr_input = OpTypePointer Input %f16vec8
- %f16vec8_input = OpVariable %f16vec8_ptr_input Input
- %f16_ptr_input = OpTypePointer Input %f16
- %u32vec8_ptr_input = OpTypePointer Input %u32vec8
- %u32vec8_input = OpVariable %u32vec8_ptr_input Input
- %u32_ptr_input = OpTypePointer Input %u32
- %f32_ptr_generic = OpTypePointer Generic %f32
- %u32_ptr_generic = OpTypePointer Generic %u32
- %f32_ptr_function = OpTypePointer Function %f32
- %f32vec2_ptr_function = OpTypePointer Function %f32vec2
- %u32_ptr_function = OpTypePointer Function %u32
- %u64_ptr_function = OpTypePointer Function %u64
- %u32vec2_ptr_function = OpTypePointer Function %u32vec2
- %u8arr = OpTypeArray %u8 %u32_256
- %u8arr_ptr_uniform_constant = OpTypePointer UniformConstant %u8arr
- %u8arr_uniform_constant = OpVariable %u8arr_ptr_uniform_constant UniformConstant
- %u8_ptr_uniform_constant = OpTypePointer UniformConstant %u8
- %u8_ptr_generic = OpTypePointer Generic %u8
- %main = OpFunction %void None %func
- %main_entry = OpLabel
- )";
- ss << body;
- ss << R"(
- OpReturn
- OpFunctionEnd)";
- return ss.str();
- }
- 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 << 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
- %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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", "", dbg_inst,
- 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_main"
- %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_linkage_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header + GetParam(), body, 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_name FlagIsPublic 1 %main
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_main"
- )";
- 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_linkage_name FlagIsPublic 1 %dbgNone
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v4f_main_f"
- )";
- 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_linkage_name FlagIsPublic 13 %main
- )";
- const std::string body = R"(
- %main_scope = OpExtInst %void %DbgExt DebugScope %main_info
- %foo = OpVariable %f32_ptr_function Function
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header,
- "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("forward referenced IDs have not been defined"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugInstructionWrongResultType) {
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected result type must be a result id of "
- "OpTypeVoid"));
- }
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- 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, DebugSourceFailFile) {
- const std::string src = R"(
- %code = OpString "main() {}"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %DbgExt %code
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand File must be a result id of "
- "OpString"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugSourceFailSource) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src %DbgExt
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- extension, "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("expected operand Text must be a result id of "
- "OpString"));
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugSourceNoText) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- )";
- const std::string dbg_inst = R"(
- %dbg_src = OpExtInst %void %DbgExt DebugSource %src
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst, "",
- extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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(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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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"
- %main_name = OpString "main"
- %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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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"
- %main_name = OpString "main"
- %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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(),
- "", 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(ValidateOpenCL100DebugInfo, DebugTypeFunction) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugTypeFunctionFailReturn) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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() {}"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(),
- "", 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(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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v4f_main_f"
- )";
- 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_linkage_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v4f_main_f"
- )";
- 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_linkage_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(),
- "", 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(),
- "", 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "",
- 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_P(ValidateGlslStd450SqrtLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32_0\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01\n";
- ss << "%val3 = OpExtInst %f64 %extinst " << ext_inst_name << " %f64_0\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateOpenCL100DebugInfo, DebugFunctionDeclaration) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "struct VS_OUTPUT {
- float4 pos : SV_POSITION;
- };
- main() {}
- "
- %main_name = OpString "main"
- %main_linkage_name = OpString "v4f_main_f"
- )";
- 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_linkage_name FlagIsPublic
- %main_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header,
- "", 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() {}
- "
- %main_name = OpString "main"
- %main_linkage_name = OpString "v4f_main_f"
- )";
- 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_linkage_name FlagIsPublic
- %main_info = OpExtInst %void %DbgExt DebugFunction )"
- << param.first;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "",
- 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_linkage_name FlagIsPublic 13 %main)",
- "Name"),
- std::make_pair(
- R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)",
- "Type"),
- std::make_pair(
- R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_linkage_name FlagIsPublic 13 %main)",
- "Source"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_linkage_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_linkage_name FlagIsPublic 13 %void)",
- "Function"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %main_linkage_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() {}
- "
- %main_name = OpString "main"
- %main_linkage_name = OpString "v4f_main_f"
- )";
- 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "",
- 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_linkage_name FlagIsPublic)",
- "Name"),
- std::make_pair(
- R"(%main_name %dbg_src %dbg_src 12 1 %comp_unit %main_linkage_name FlagIsPublic)",
- "Type"),
- std::make_pair(
- R"(%main_name %main_type_info %comp_unit 12 1 %comp_unit %main_linkage_name FlagIsPublic)",
- "Source"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %dbg_src %main_linkage_name FlagIsPublic)",
- "Parent"),
- std::make_pair(
- R"(%main_name %main_type_info %dbg_src 12 1 %comp_unit %void FlagIsPublic)",
- "Linkage Name"),
- }));
- TEST_F(ValidateOpenCL100DebugInfo, DebugLexicalBlock) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %main_name = 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)";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", dbg_inst_header,
- "", extension, "Vertex"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCL100DebugInfoDebugLexicalBlock, Fail) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "main() {}"
- %main_name = 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, "", ss.str(), "",
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(),
- "", 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(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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, ss.str(), 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(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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header,
- "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo("", "", dbg_inst_header,
- "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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"
- %main_name = OpString "main"
- )";
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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"
- %main_name = OpString "main"
- )";
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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"
- %main_name = OpString "main"
- )";
- 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, "", 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(src, size_const, ss.str(),
- "", 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(ValidateOpenCL100DebugInfo, DebugInlinedAt) {
- const std::string src = R"(
- %src = OpString "simple.hlsl"
- %code = OpString "void main() {}"
- %void_name = OpString "void"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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"
- %main_name = OpString "main"
- %main_linkage_name = OpString "v_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_info = OpExtInst %void %DbgExt DebugFunction %main_name %main_type_info %dbg_src 1 1 %comp_unit %main_linkage_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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, "", dbg_inst_header, body, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, 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
- )";
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, body, 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;
- const std::string extension = R"(
- %DbgExt = OpExtInstImport "OpenCL.DebugInfo.100"
- )";
- CompileSuccessfully(GenerateShaderCodeForDebugInfo(
- src, size_const, dbg_inst_header, ss.str(), 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_P(ValidateGlslStd450SqrtLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a float scalar "
- "or vector type"));
- }
- TEST_P(ValidateGlslStd450SqrtLike, IntOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllSqrtLike, ValidateGlslStd450SqrtLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "Round",
- "RoundEven",
- "FAbs",
- "Trunc",
- "FSign",
- "Floor",
- "Ceil",
- "Fract",
- "Sqrt",
- "InverseSqrt",
- "Normalize",
- }));
- TEST_P(ValidateGlslStd450FMinLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %f32vec2_12\n";
- ss << "%val3 = OpExtInst %f64 %extinst " << ext_inst_name
- << " %f64_0 %f64_0\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450FMinLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a float scalar "
- "or vector type"));
- }
- TEST_P(ValidateGlslStd450FMinLike, IntOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450FMinLike, IntOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllFMinLike, ValidateGlslStd450FMinLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "FMin",
- "FMax",
- "Step",
- "Reflect",
- "NMin",
- "NMax",
- }));
- TEST_P(ValidateGlslStd450FClampLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1 %f32_2\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %f32vec2_01 %f32vec2_12\n";
- ss << "%val3 = OpExtInst %f64 %extinst " << ext_inst_name
- << " %f64_0 %f64_0 %f64_1\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450FClampLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32_0 %f32_1 %f32_2\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a float scalar "
- "or vector type"));
- }
- TEST_P(ValidateGlslStd450FClampLike, IntOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450FClampLike, IntOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450FClampLike, IntOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f32_1 %f32_0 %u32_2\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllFClampLike, ValidateGlslStd450FClampLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "FClamp",
- "FMix",
- "SmoothStep",
- "Fma",
- "FaceForward",
- "NClamp",
- }));
- TEST_P(ValidateGlslStd450SAbsLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %s32 %extinst " << ext_inst_name << " %u32_1\n";
- ss << "%val2 = OpExtInst %s32 %extinst " << ext_inst_name << " %s32_1\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name << " %u32_1\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name << " %s32_1\n";
- ss << "%val5 = OpExtInst %s32vec2 %extinst " << ext_inst_name
- << " %s32vec2_01\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %s32vec2_01\n";
- ss << "%val8 = OpExtInst %s32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450SAbsLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be an int scalar "
- "or vector type"));
- }
- TEST_P(ValidateGlslStd450SAbsLike, FloatOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s32 %extinst " + ext_inst_name + " %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to be int scalars or "
- "vectors"));
- }
- TEST_P(ValidateGlslStd450SAbsLike, WrongDimOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s32 %extinst " + ext_inst_name + " %s32vec2_01\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same dimension as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450SAbsLike, WrongBitWidthOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s64 %extinst " + ext_inst_name + " %s32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same bit width as "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllSAbsLike, ValidateGlslStd450SAbsLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "SAbs",
- "SSign",
- "FindILsb",
- "FindUMsb",
- "FindSMsb",
- }));
- TEST_F(ValidateExtInst, FindUMsbNot32Bit) {
- const std::string body = R"(
- %val1 = OpExtInst %s64 %extinst FindUMsb %u64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FindUMsb: this instruction is currently "
- "limited to 32-bit width components"));
- }
- TEST_F(ValidateExtInst, FindSMsbNot32Bit) {
- const std::string body = R"(
- %val1 = OpExtInst %s64 %extinst FindSMsb %u64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FindSMsb: this instruction is currently "
- "limited to 32-bit width components"));
- }
- TEST_P(ValidateGlslStd450UMinLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %s32 %extinst " << ext_inst_name
- << " %u32_1 %s32_2\n";
- ss << "%val2 = OpExtInst %s32 %extinst " << ext_inst_name
- << " %s32_1 %u32_2\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %s32_2\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %s32_1 %u32_2\n";
- ss << "%val5 = OpExtInst %s32vec2 %extinst " << ext_inst_name
- << " %s32vec2_01 %u32vec2_01\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %s32vec2_01\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %s32vec2_01 %u32vec2_01\n";
- ss << "%val8 = OpExtInst %s32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %s32vec2_01\n";
- ss << "%val9 = OpExtInst %s64 %extinst " << ext_inst_name
- << " %u64_1 %s64_0\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450UMinLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0 %u32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be an int scalar "
- "or vector type"));
- }
- TEST_P(ValidateGlslStd450UMinLike, FloatOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s32 %extinst " + ext_inst_name + " %f32_0 %u32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to be int scalars or "
- "vectors"));
- }
- TEST_P(ValidateGlslStd450UMinLike, FloatOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s32 %extinst " + ext_inst_name + " %u32_0 %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to be int scalars or "
- "vectors"));
- }
- TEST_P(ValidateGlslStd450UMinLike, WrongDimOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %s32vec2_01 %s32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same dimension as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UMinLike, WrongDimOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %s32_0 %s32vec2_01\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same dimension as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UMinLike, WrongBitWidthOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s64 %extinst " + ext_inst_name + " %s32_0 %s64_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same bit width as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UMinLike, WrongBitWidthOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %s64 %extinst " + ext_inst_name + " %s64_0 %s32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same bit width as "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUMinLike, ValidateGlslStd450UMinLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "UMin",
- "SMin",
- "UMax",
- "SMax",
- }));
- TEST_P(ValidateGlslStd450UClampLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %s32 %extinst " << ext_inst_name
- << " %s32_0 %u32_1 %s32_2\n";
- ss << "%val2 = OpExtInst %s32 %extinst " << ext_inst_name
- << " %u32_0 %s32_1 %u32_2\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %s32_0 %u32_1 %s32_2\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %s32_1 %u32_2\n";
- ss << "%val5 = OpExtInst %s32vec2 %extinst " << ext_inst_name
- << " %s32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %s32vec2_01 %s32vec2_12\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %s32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val8 = OpExtInst %s32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %s32vec2_01 %s32vec2_12\n";
- ss << "%val9 = OpExtInst %s64 %extinst " << ext_inst_name
- << " %u64_1 %s64_0 %s64_1\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450UClampLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be an int scalar "
- "or vector type"));
- }
- TEST_P(ValidateGlslStd450UClampLike, FloatOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to be int scalars or "
- "vectors"));
- }
- TEST_P(ValidateGlslStd450UClampLike, FloatOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to be int scalars or "
- "vectors"));
- }
- TEST_P(ValidateGlslStd450UClampLike, FloatOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to be int scalars or "
- "vectors"));
- }
- TEST_P(ValidateGlslStd450UClampLike, WrongDimOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %s32vec2_01 %s32_0 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same dimension as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UClampLike, WrongDimOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %s32_0 %s32vec2_01 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same dimension as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UClampLike, WrongDimOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s32 %extinst " + ext_inst_name +
- " %s32_0 %u32_1 %s32vec2_01\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same dimension as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UClampLike, WrongBitWidthOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s64 %extinst " + ext_inst_name +
- " %s32_0 %s64_0 %s64_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same bit width as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UClampLike, WrongBitWidthOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s64 %extinst " + ext_inst_name +
- " %s64_0 %s32_0 %s64_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same bit width as "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450UClampLike, WrongBitWidthOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %s64 %extinst " + ext_inst_name +
- " %s64_0 %s64_0 %s32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected all operands to have the same bit width as "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUClampLike, ValidateGlslStd450UClampLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "UClamp",
- "SClamp",
- }));
- TEST_P(ValidateGlslStd450SinLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32_0\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450SinLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a 16 or 32-bit scalar "
- "or vector float type"));
- }
- TEST_P(ValidateGlslStd450SinLike, F64ResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f64 %extinst " + ext_inst_name + " %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a 16 or 32-bit scalar "
- "or vector float type"));
- }
- TEST_P(ValidateGlslStd450SinLike, IntOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllSinLike, ValidateGlslStd450SinLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "Radians",
- "Degrees",
- "Sin",
- "Cos",
- "Tan",
- "Asin",
- "Acos",
- "Atan",
- "Sinh",
- "Cosh",
- "Tanh",
- "Asinh",
- "Acosh",
- "Atanh",
- "Exp",
- "Exp2",
- "Log",
- "Log2",
- }));
- TEST_P(ValidateGlslStd450PowLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_1 %f32_1\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %f32vec2_12\n";
- CompileSuccessfully(GenerateShaderCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450PowLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_1 %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a 16 or 32-bit scalar "
- "or vector float type"));
- }
- TEST_P(ValidateGlslStd450PowLike, F64ResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f64 %extinst " + ext_inst_name + " %f32_1 %f32_0\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected Result Type to be a 16 or 32-bit scalar "
- "or vector float type"));
- }
- TEST_P(ValidateGlslStd450PowLike, IntOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateGlslStd450PowLike, IntOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllPowLike, ValidateGlslStd450PowLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "Atan2",
- "Pow",
- }));
- TEST_F(ValidateExtInst, GlslStd450DeterminantSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Determinant %f32mat22_1212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450DeterminantIncompatibleResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst Determinant %f32mat22_1212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Determinant: "
- "expected operand X component type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DeterminantNotMatrix) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Determinant %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Determinant: "
- "expected operand X to be a square matrix"));
- }
- TEST_F(ValidateExtInst, GlslStd450DeterminantMatrixNotSquare) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Determinant %f32mat23_121212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Determinant: "
- "expected operand X to be a square matrix"));
- }
- TEST_F(ValidateExtInst, GlslStd450MatrixInverseSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32mat22 %extinst MatrixInverse %f32mat22_1212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450MatrixInverseIncompatibleResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32mat33 %extinst MatrixInverse %f32mat22_1212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 MatrixInverse: "
- "expected operand X type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450MatrixInverseNotMatrix) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst MatrixInverse %f32mat22_1212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 MatrixInverse: "
- "expected Result Type to be a square matrix"));
- }
- TEST_F(ValidateExtInst, GlslStd450MatrixInverseMatrixNotSquare) {
- const std::string body = R"(
- %val1 = OpExtInst %f32mat23 %extinst MatrixInverse %f32mat23_121212
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 MatrixInverse: "
- "expected Result Type to be a square matrix"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Modf %f32_h %f32_output
- %val2 = OpExtInst %f32vec2 %extinst Modf %f32vec2_01 %f32vec2_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450ModfIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst Modf %f32_h %f32_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Modf: "
- "expected Result Type to be a scalar or vector "
- "float type"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfXNotOfResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Modf %f64_0 %f32_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Modf: "
- "expected operand X type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfINotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Modf %f32_h %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Modf: "
- "expected operand I to be a pointer"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfIDataNotOfResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Modf %f32_h %f32vec2_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Modf: "
- "expected operand I data type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfStructSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_f32 %extinst ModfStruct %f32_h
- %val2 = OpExtInst %struct_f32vec2_f32vec2 %extinst ModfStruct %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450ModfStructResultTypeNotStruct) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst ModfStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 ModfStruct: "
- "expected Result Type to be a struct with two "
- "identical scalar or vector float type members"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfStructResultTypeStructWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_f32_f32 %extinst ModfStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 ModfStruct: "
- "expected Result Type to be a struct with two "
- "identical scalar or vector float type members"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfStructResultTypeStructWrongFirstMember) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_u32_f32 %extinst ModfStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 ModfStruct: "
- "expected Result Type to be a struct with two "
- "identical scalar or vector float type members"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfStructResultTypeStructMembersNotEqual) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_f64 %extinst ModfStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 ModfStruct: "
- "expected Result Type to be a struct with two "
- "identical scalar or vector float type members"));
- }
- TEST_F(ValidateExtInst, GlslStd450ModfStructXWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_f32 %extinst ModfStruct %f64_0
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 ModfStruct: "
- "expected operand X type to be equal to members of "
- "Result Type struct"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Frexp %f32_h %u32_output
- %val2 = OpExtInst %f32vec2 %extinst Frexp %f32vec2_01 %u32vec2_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst Frexp %f32_h %u32_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Frexp: "
- "expected Result Type to be a scalar or vector "
- "float type"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpWrongXType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Frexp %u32_1 %u32_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Frexp: "
- "expected operand X type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpExpNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Frexp %f32_1 %u32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Frexp: "
- "expected operand Exp to be a pointer"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpExpNotInt32Pointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Frexp %f32_1 %f32_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Frexp: "
- "expected operand Exp data type to be a 32-bit int "
- "scalar or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpExpWrongComponentNumber) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Frexp %f32vec2_01 %u32_output
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Frexp: "
- "expected operand Exp data type to have the same "
- "component number as Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450LdexpSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Ldexp %f32_h %u32_2
- %val2 = OpExtInst %f32vec2 %extinst Ldexp %f32vec2_01 %u32vec2_12
- %val3 = OpExtInst %f32 %extinst Ldexp %f32_h %u64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450LdexpIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst Ldexp %f32_h %u32_2
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Ldexp: "
- "expected Result Type to be a scalar or vector "
- "float type"));
- }
- TEST_F(ValidateExtInst, GlslStd450LdexpWrongXType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Ldexp %u32_1 %u32_2
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Ldexp: "
- "expected operand X type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450LdexpFloatExp) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Ldexp %f32_1 %f32_2
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Ldexp: "
- "expected operand Exp to be a 32-bit int scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450LdexpExpWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Ldexp %f32vec2_12 %u32_2
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Ldexp: "
- "expected operand Exp to have the same component "
- "number as Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpStructSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_u32 %extinst FrexpStruct %f32_h
- %val2 = OpExtInst %struct_f32vec2_u32vec2 %extinst FrexpStruct %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpStructResultTypeNotStruct) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst FrexpStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FrexpStruct: "
- "expected Result Type to be a struct with two members, "
- "first member a float scalar or vector, second member "
- "a 32-bit int scalar or vector with the same number of "
- "components as the first member"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpStructResultTypeStructWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_u32_f32 %extinst FrexpStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FrexpStruct: "
- "expected Result Type to be a struct with two members, "
- "first member a float scalar or vector, second member "
- "a 32-bit int scalar or vector with the same number of "
- "components as the first member"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpStructResultTypeStructWrongMember1) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_u32_u32 %extinst FrexpStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FrexpStruct: "
- "expected Result Type to be a struct with two members, "
- "first member a float scalar or vector, second member "
- "a 32-bit int scalar or vector with the same number of "
- "components as the first member"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpStructResultTypeStructWrongMember2) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_f32 %extinst FrexpStruct %f32_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FrexpStruct: "
- "expected Result Type to be a struct with two members, "
- "first member a float scalar or vector, second member "
- "a 32-bit int scalar or vector with the same number of "
- "components as the first member"));
- }
- TEST_F(ValidateExtInst, GlslStd450FrexpStructXWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f32_u32 %extinst FrexpStruct %f64_0
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FrexpStruct: "
- "expected operand X type to be equal to the first "
- "member of Result Type struct"));
- }
- TEST_F(ValidateExtInst,
- GlslStd450FrexpStructResultTypeStructRightInt16Member2) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f16_u16 %extinst FrexpStruct %f16_h
- )";
- const std::string extension = R"(
- OpExtension "SPV_AMD_gpu_shader_int16"
- )";
- CompileSuccessfully(GenerateShaderCode(body, extension));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst,
- GlslStd450FrexpStructResultTypeStructWrongInt16Member2) {
- const std::string body = R"(
- %val1 = OpExtInst %struct_f16_u16 %extinst FrexpStruct %f16_h
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 FrexpStruct: "
- "expected Result Type to be a struct with two members, "
- "first member a float scalar or vector, second member "
- "a 32-bit int scalar or vector with the same number of "
- "components as the first member"));
- }
- TEST_P(ValidateGlslStd450Pack, Success) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string vec_str =
- num_components == 2 ? " %f32vec2_01\n" : " %f32vec4_0123\n";
- std::ostringstream body;
- body << "%val1 = OpExtInst %u" << total_bit_width << " %extinst "
- << ext_inst_name << vec_str;
- body << "%val2 = OpExtInst %s" << total_bit_width << " %extinst "
- << ext_inst_name << vec_str;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450Pack, Float32ResultType) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string vec_str =
- num_components == 2 ? " %f32vec2_01\n" : " %f32vec4_0123\n";
- std::ostringstream body;
- body << "%val1 = OpExtInst %f" << total_bit_width << " %extinst "
- << ext_inst_name << vec_str;
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected Result Type to be " << total_bit_width
- << "-bit int scalar type";
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Pack, Int16ResultType) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string vec_str =
- num_components == 2 ? " %f32vec2_01\n" : " %f32vec4_0123\n";
- std::ostringstream body;
- body << "%val1 = OpExtInst %u16 %extinst " << ext_inst_name << vec_str;
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected Result Type to be " << total_bit_width
- << "-bit int scalar type";
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Pack, VNotVector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- std::ostringstream body;
- body << "%val1 = OpExtInst %u" << total_bit_width << " %extinst "
- << ext_inst_name << " %f32_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected operand V to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Pack, VNotFloatVector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string vec_str =
- num_components == 2 ? " %u32vec2_01\n" : " %u32vec4_0123\n";
- std::ostringstream body;
- body << "%val1 = OpExtInst %u" << total_bit_width << " %extinst "
- << ext_inst_name << vec_str;
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected operand V to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Pack, VNotFloat32Vector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string vec_str =
- num_components == 2 ? " %f64vec2_01\n" : " %f64vec4_0123\n";
- std::ostringstream body;
- body << "%val1 = OpExtInst %u" << total_bit_width << " %extinst "
- << ext_inst_name << vec_str;
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected operand V to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Pack, VWrongSizeVector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string vec_str =
- num_components == 4 ? " %f32vec2_01\n" : " %f32vec4_0123\n";
- std::ostringstream body;
- body << "%val1 = OpExtInst %u" << total_bit_width << " %extinst "
- << ext_inst_name << vec_str;
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected operand V to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- INSTANTIATE_TEST_SUITE_P(AllPack, ValidateGlslStd450Pack,
- ::testing::ValuesIn(std::vector<std::string>{
- "PackSnorm4x8",
- "PackUnorm4x8",
- "PackSnorm2x16",
- "PackUnorm2x16",
- "PackHalf2x16",
- }));
- TEST_F(ValidateExtInst, PackDouble2x32Success) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst PackDouble2x32 %u32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, PackDouble2x32Float32ResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst PackDouble2x32 %u32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 PackDouble2x32: expected Result Type to "
- "be 64-bit float scalar type"));
- }
- TEST_F(ValidateExtInst, PackDouble2x32Int64ResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u64 %extinst PackDouble2x32 %u32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 PackDouble2x32: expected Result Type to "
- "be 64-bit float scalar type"));
- }
- TEST_F(ValidateExtInst, PackDouble2x32VNotVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst PackDouble2x32 %u64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 PackDouble2x32: expected operand V to be "
- "a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, PackDouble2x32VNotIntVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst PackDouble2x32 %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 PackDouble2x32: expected operand V to be "
- "a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, PackDouble2x32VNotInt32Vector) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst PackDouble2x32 %u64vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 PackDouble2x32: expected operand V to be "
- "a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, PackDouble2x32VWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst PackDouble2x32 %u32vec4_0123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 PackDouble2x32: expected operand V to be "
- "a 32-bit int vector of size 2"));
- }
- TEST_P(ValidateGlslStd450Unpack, Success) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string result_type_str =
- num_components == 2 ? "%f32vec2" : " %f32vec4";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %u" << total_bit_width << "_1\n";
- body << "%val2 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %s" << total_bit_width << "_1\n";
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateGlslStd450Unpack, ResultTypeNotVector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string result_type_str = "%f32";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %u" << total_bit_width << "_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected Result Type to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Unpack, ResultTypeNotFloatVector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string result_type_str =
- num_components == 2 ? "%u32vec2" : " %u32vec4";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %u" << total_bit_width << "_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected Result Type to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Unpack, ResultTypeNotFloat32Vector) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string result_type_str =
- num_components == 2 ? "%f64vec2" : " %f64vec4";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %u" << total_bit_width << "_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected Result Type to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Unpack, ResultTypeWrongSize) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string result_type_str =
- num_components == 4 ? "%f32vec2" : " %f32vec4";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %u" << total_bit_width << "_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected Result Type to be a 32-bit float vector of size "
- << num_components;
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Unpack, ResultPNotInt) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const std::string result_type_str =
- num_components == 2 ? "%f32vec2" : " %f32vec4";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %f" << total_bit_width << "_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected operand P to be a " << total_bit_width
- << "-bit int scalar";
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- TEST_P(ValidateGlslStd450Unpack, ResultPWrongBitWidth) {
- const std::string ext_inst_name = GetParam();
- const uint32_t num_components = GetPackedNumComponents(ext_inst_name);
- const uint32_t packed_bit_width = GetPackedBitWidth(ext_inst_name);
- const uint32_t total_bit_width = num_components * packed_bit_width;
- const uint32_t wrong_bit_width = total_bit_width == 32 ? 64 : 32;
- const std::string result_type_str =
- num_components == 2 ? "%f32vec2" : " %f32vec4";
- std::ostringstream body;
- body << "%val1 = OpExtInst " << result_type_str << " %extinst "
- << ext_inst_name << " %u" << wrong_bit_width << "_1\n";
- std::ostringstream expected;
- expected << "GLSL.std.450 " << ext_inst_name
- << ": expected operand P to be a " << total_bit_width
- << "-bit int scalar";
- CompileSuccessfully(GenerateShaderCode(body.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(expected.str()));
- }
- INSTANTIATE_TEST_SUITE_P(AllUnpack, ValidateGlslStd450Unpack,
- ::testing::ValuesIn(std::vector<std::string>{
- "UnpackSnorm4x8",
- "UnpackUnorm4x8",
- "UnpackSnorm2x16",
- "UnpackUnorm2x16",
- "UnpackHalf2x16",
- }));
- TEST_F(ValidateExtInst, UnpackDouble2x32Success) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec2 %extinst UnpackDouble2x32 %f64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, UnpackDouble2x32ResultTypeNotVector) {
- const std::string body = R"(
- %val1 = OpExtInst %u64 %extinst UnpackDouble2x32 %f64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 UnpackDouble2x32: expected Result Type "
- "to be a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, UnpackDouble2x32ResultTypeNotIntVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst UnpackDouble2x32 %f64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 UnpackDouble2x32: expected Result Type "
- "to be a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, UnpackDouble2x32ResultTypeNotInt32Vector) {
- const std::string body = R"(
- %val1 = OpExtInst %u64vec2 %extinst UnpackDouble2x32 %f64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 UnpackDouble2x32: expected Result Type "
- "to be a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, UnpackDouble2x32ResultTypeWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec4 %extinst UnpackDouble2x32 %f64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 UnpackDouble2x32: expected Result Type "
- "to be a 32-bit int vector of size 2"));
- }
- TEST_F(ValidateExtInst, UnpackDouble2x32VNotFloat) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec2 %extinst UnpackDouble2x32 %u64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 UnpackDouble2x32: expected operand V to "
- "be a 64-bit float scalar"));
- }
- TEST_F(ValidateExtInst, UnpackDouble2x32VNotFloat64) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec2 %extinst UnpackDouble2x32 %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 UnpackDouble2x32: expected operand V to "
- "be a 64-bit float scalar"));
- }
- TEST_F(ValidateExtInst, GlslStd450LengthSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Length %f32_1
- %val2 = OpExtInst %f32 %extinst Length %f32vec2_01
- %val3 = OpExtInst %f32 %extinst Length %f32vec4_0123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450LengthIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst Length %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Length: "
- "expected Result Type to be a float scalar type"));
- }
- TEST_F(ValidateExtInst, GlslStd450LengthIntX) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Length %u32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Length: "
- "expected operand X to be of float scalar or "
- "vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450LengthDifferentType) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst Length %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Length: "
- "expected operand X component type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Distance %f32_0 %f32_1
- %val2 = OpExtInst %f32 %extinst Distance %f32vec2_01 %f32vec2_12
- %val3 = OpExtInst %f32 %extinst Distance %f32vec4_0123 %f32vec4_1234
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst Distance %f32vec2_01 %f32vec2_12
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Distance: "
- "expected Result Type to be a float scalar type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceIntP0) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Distance %u32_0 %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Distance: "
- "expected operand P0 to be of float scalar or "
- "vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceF64VectorP0) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Distance %f64vec2_01 %f32vec2_12
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Distance: "
- "expected operand P0 component type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceIntP1) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Distance %f32_0 %u32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Distance: "
- "expected operand P1 to be of float scalar or "
- "vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceF64VectorP1) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Distance %f32vec2_12 %f64vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Distance: "
- "expected operand P1 component type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450DistanceDifferentSize) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Distance %f32vec2_01 %f32vec4_0123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Distance: "
- "expected operands P0 and P1 to have the same number "
- "of components"));
- }
- TEST_F(ValidateExtInst, GlslStd450CrossSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst Cross %f32vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450CrossIntVectorResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec3 %extinst Cross %f32vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Cross: "
- "expected Result Type to be a float vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450CrossResultTypeWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Cross %f32vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Cross: "
- "expected Result Type to have 3 components"));
- }
- TEST_F(ValidateExtInst, GlslStd450CrossXWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst Cross %f64vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Cross: "
- "expected operand X type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450CrossYWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst Cross %f32vec3_123 %f64vec3_012
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Cross: "
- "expected operand Y type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450RefractSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst Refract %f32_1 %f32_1 %f32_1
- %val2 = OpExtInst %f32vec2 %extinst Refract %f32vec2_01 %f32vec2_01 %f16_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450RefractIntVectorResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec2 %extinst Refract %f32vec2_01 %f32vec2_01 %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Refract: "
- "expected Result Type to be a float scalar or "
- "vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450RefractIntVectorI) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Refract %u32vec2_01 %f32vec2_01 %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Refract: "
- "expected operand I to be of type equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450RefractIntVectorN) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Refract %f32vec2_01 %u32vec2_01 %f32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Refract: "
- "expected operand N to be of type equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450RefractIntEta) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Refract %f32vec2_01 %f32vec2_01 %u32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Refract: "
- "expected operand Eta to be a float scalar"));
- }
- TEST_F(ValidateExtInst, GlslStd450RefractFloat64Eta) {
- // SPIR-V issue 337: Eta can be 64-bit float scalar.
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Refract %f32vec2_01 %f32vec2_01 %f64_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), Eq(""));
- }
- TEST_F(ValidateExtInst, GlslStd450RefractVectorEta) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst Refract %f32vec2_01 %f32vec2_01 %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 Refract: "
- "expected operand Eta to be a float scalar"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtCentroid %f32_input
- %val2 = OpExtInst %f32vec2 %extinst InterpolateAtCentroid %f32vec2_input
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidNoCapability) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtCentroid %f32_input
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid requires "
- "capability InterpolationFunction"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst InterpolateAtCentroid %f32_input
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid: "
- "expected Result Type to be a 32-bit float scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidF64ResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst InterpolateAtCentroid %f32_input
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid: "
- "expected Result Type to be a 32-bit float scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtCentroid %f32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid: "
- "expected Interpolant to be a pointer"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidWrongDataType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtCentroid %f32vec2_input
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid: "
- "expected Interpolant data type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidWrongStorageClass) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtCentroid %f32_output
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid: "
- "expected Interpolant storage class to be Input"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtCentroidWrongExecutionModel) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtCentroid %f32_input
- )";
- CompileSuccessfully(GenerateShaderCode(
- body, "OpCapability InterpolationFunction\n", "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtCentroid requires "
- "Fragment execution model"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_input %u32_1
- %val2 = OpExtInst %f32vec2 %extinst InterpolateAtSample %f32vec2_input %u32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleNoCapability) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_input %u32_1
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample requires "
- "capability InterpolationFunction"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst InterpolateAtSample %f32_input %u32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Result Type to be a 32-bit float scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleF64ResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst InterpolateAtSample %f32_input %u32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Result Type to be a 32-bit float scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_1 %u32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Interpolant to be a pointer"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleWrongDataType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32vec2_input %u32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Interpolant data type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleWrongStorageClass) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_output %u32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Interpolant storage class to be Input"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleFloatSample) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_input %f32_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Sample to be 32-bit integer"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleU64Sample) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_input %u64_1
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample: "
- "expected Sample to be 32-bit integer"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtSampleWrongExecutionModel) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtSample %f32_input %u32_1
- )";
- CompileSuccessfully(GenerateShaderCode(
- body, "OpCapability InterpolationFunction\n", "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtSample requires "
- "Fragment execution model"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %f32vec2_01
- %val2 = OpExtInst %f32vec2 %extinst InterpolateAtOffset %f32vec2_input %f32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetNoCapability) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_CAPABILITY, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset requires "
- "capability InterpolationFunction"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst InterpolateAtOffset %f32_input %f32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Result Type to be a 32-bit float scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetF64ResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst InterpolateAtOffset %f32_input %f32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Result Type to be a 32-bit float scalar "
- "or vector type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_1 %f32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Interpolant to be a pointer"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetWrongDataType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32vec2_input %f32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Interpolant data type to be equal to "
- "Result Type"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetWrongStorageClass) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_output %f32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Interpolant storage class to be Input"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetOffsetNotVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %f32_0
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Offset to be a vector of 2 32-bit floats"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetOffsetNotVector2) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %f32vec3_012
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Offset to be a vector of 2 32-bit floats"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetOffsetNotFloatVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %u32vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Offset to be a vector of 2 32-bit floats"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetOffsetNotFloat32Vector) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %f64vec2_01
- )";
- CompileSuccessfully(
- GenerateShaderCode(body, "OpCapability InterpolationFunction\n"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset: "
- "expected Offset to be a vector of 2 32-bit floats"));
- }
- TEST_F(ValidateExtInst, GlslStd450InterpolateAtOffsetWrongExecutionModel) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst InterpolateAtOffset %f32_input %f32vec2_01
- )";
- CompileSuccessfully(GenerateShaderCode(
- body, "OpCapability InterpolationFunction\n", "Vertex"));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("GLSL.std.450 InterpolateAtOffset requires "
- "Fragment execution model"));
- }
- TEST_P(ValidateOpenCLStdSqrtLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32_0\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01\n";
- ss << "%val3 = OpExtInst %f32vec4 %extinst " << ext_inst_name
- << " %f32vec4_0123\n";
- ss << "%val4 = OpExtInst %f64 %extinst " << ext_inst_name << " %f64_0\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdSqrtLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float scalar "
- "or vector type"));
- }
- TEST_P(ValidateOpenCLStdSqrtLike, IntOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(
- AllSqrtLike, ValidateOpenCLStdSqrtLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "acos", "acosh", "acospi", "asin",
- "asinh", "asinpi", "atan", "atanh",
- "atanpi", "cbrt", "ceil", "cos",
- "cosh", "cospi", "erfc", "erf",
- "exp", "exp2", "exp10", "expm1",
- "fabs", "floor", "log", "log2",
- "log10", "log1p", "logb", "rint",
- "round", "rsqrt", "sin", "sinh",
- "sinpi", "sqrt", "tan", "tanh",
- "tanpi", "tgamma", "trunc", "half_cos",
- "half_exp", "half_exp2", "half_exp10", "half_log",
- "half_log2", "half_log10", "half_recip", "half_rsqrt",
- "half_sin", "half_sqrt", "half_tan", "lgamma",
- "native_cos", "native_exp", "native_exp2", "native_exp10",
- "native_log", "native_log2", "native_log10", "native_recip",
- "native_rsqrt", "native_sin", "native_sqrt", "native_tan",
- "degrees", "radians", "sign",
- }));
- TEST_P(ValidateOpenCLStdFMinLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %f32vec2_12\n";
- ss << "%val3 = OpExtInst %f64 %extinst " << ext_inst_name
- << " %f64_0 %f64_0\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdFMinLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float scalar "
- "or vector type"));
- }
- TEST_P(ValidateOpenCLStdFMinLike, IntOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateOpenCLStdFMinLike, IntOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllFMinLike, ValidateOpenCLStdFMinLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "atan2", "atan2pi", "copysign",
- "fdim", "fmax", "fmin",
- "fmod", "maxmag", "minmag",
- "hypot", "nextafter", "pow",
- "powr", "remainder", "half_divide",
- "half_powr", "native_divide", "native_powr",
- "step", "fmax_common", "fmin_common",
- }));
- TEST_P(ValidateOpenCLStdFClampLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1 %f32_2\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %f32vec2_01 %f32vec2_12\n";
- ss << "%val3 = OpExtInst %f64 %extinst " << ext_inst_name
- << " %f64_0 %f64_0 %f64_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdFClampLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32_0 %f32_1 %f32_2\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float scalar "
- "or vector type"));
- }
- TEST_P(ValidateOpenCLStdFClampLike, IntOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateOpenCLStdFClampLike, IntOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- TEST_P(ValidateOpenCLStdFClampLike, IntOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f32_1 %f32_0 %u32_2\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllFClampLike, ValidateOpenCLStdFClampLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "fma",
- "mad",
- "fclamp",
- "mix",
- "smoothstep",
- }));
- TEST_P(ValidateOpenCLStdSAbsLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name << " %u32_1\n";
- ss << "%val2 = OpExtInst %u32 %extinst " << ext_inst_name << " %u32_1\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name << " %u32_1\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name << " %u32_1\n";
- ss << "%val5 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01\n";
- ss << "%val8 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdSAbsLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be an int scalar "
- "or vector type"));
- }
- TEST_P(ValidateOpenCLStdSAbsLike, FloatOperand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdSAbsLike, U64Operand) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u64_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllSAbsLike, ValidateOpenCLStdSAbsLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "s_abs",
- "clz",
- "ctz",
- "popcount",
- "u_abs",
- }));
- TEST_P(ValidateOpenCLStdUMinLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val2 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val5 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val8 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val9 = OpExtInst %u64 %extinst " << ext_inst_name
- << " %u64_1 %u64_0\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdUMinLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0 %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be an int scalar "
- "or vector type"));
- }
- TEST_P(ValidateOpenCLStdUMinLike, FloatOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0 %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMinLike, FloatOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u32_0 %f32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMinLike, U64Operand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u64_0 %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMinLike, U64Operand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u32_0 %u64_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUMinLike, ValidateOpenCLStdUMinLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "s_max",
- "u_max",
- "s_min",
- "u_min",
- "s_abs_diff",
- "s_add_sat",
- "u_add_sat",
- "s_mul_hi",
- "rotate",
- "s_sub_sat",
- "u_sub_sat",
- "s_hadd",
- "u_hadd",
- "s_rhadd",
- "u_rhadd",
- "u_abs_diff",
- "u_mul_hi",
- }));
- TEST_P(ValidateOpenCLStdUClampLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val2 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val5 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val8 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val9 = OpExtInst %u64 %extinst " << ext_inst_name
- << " %u64_1 %u64_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdUClampLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be an int scalar "
- "or vector type"));
- }
- TEST_P(ValidateOpenCLStdUClampLike, FloatOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUClampLike, FloatOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUClampLike, FloatOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUClampLike, U64Operand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUClampLike, U64Operand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUClampLike, U64Operand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUClampLike, ValidateOpenCLStdUClampLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "s_clamp",
- "u_clamp",
- "s_mad_hi",
- "u_mad_sat",
- "s_mad_sat",
- "u_mad_hi",
- }));
- // -------------------------------------------------------------
- TEST_P(ValidateOpenCLStdUMul24Like, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val2 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val5 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- ss << "%val8 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdUMul24Like, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32_0 %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a 32-bit int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdUMul24Like, U64ResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u64 %extinst " + ext_inst_name + " %u64_0 %u64_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a 32-bit int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdUMul24Like, FloatOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_0 %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMul24Like, FloatOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u32_0 %f32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMul24Like, U64Operand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u64_0 %u32_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMul24Like, U64Operand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %u32_0 %u64_0\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUMul24Like, ValidateOpenCLStdUMul24Like,
- ::testing::ValuesIn(std::vector<std::string>{
- "s_mul24",
- "u_mul24",
- }));
- TEST_P(ValidateOpenCLStdUMad24Like, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val2 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val3 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val4 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1 %u32_2\n";
- ss << "%val5 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val6 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val7 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- ss << "%val8 = OpExtInst %u32vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01 %u32vec2_12\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdUMad24Like, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a 32-bit int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, U64ResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u64 %extinst " + ext_inst_name +
- " %u64_0 %u64_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a 32-bit int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, FloatOperand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, FloatOperand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, FloatOperand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, U64Operand1) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32_0 %u32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, U64Operand2) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %f32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdUMad24Like, U64Operand3) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %u32_0 %u32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected types of all operands to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUMad24Like, ValidateOpenCLStdUMad24Like,
- ::testing::ValuesIn(std::vector<std::string>{
- "s_mad24",
- "u_mad24",
- }));
- TEST_F(ValidateExtInst, OpenCLStdCrossSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst cross %f32vec3_012 %f32vec3_123
- %val2 = OpExtInst %f32vec4 %extinst cross %f32vec4_0123 %f32vec4_0123
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdCrossIntVectorResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32vec3 %extinst cross %f32vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std cross: "
- "expected Result Type to be a float vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdCrossResultTypeWrongSize) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst cross %f32vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std cross: "
- "expected Result Type to have 3 or 4 components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdCrossXWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst cross %f64vec3_012 %f32vec3_123
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std cross: "
- "expected operand X type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdCrossYWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst cross %f32vec3_123 %f64vec3_012
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std cross: "
- "expected operand Y type to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdLengthLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32vec2_01\n";
- ss << "%val2 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32vec4_0123\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdLengthLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected Result Type to be a float scalar type"));
- }
- TEST_P(ValidateOpenCLStdLengthLike, IntX) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f32 %extinst " + ext_inst_name + " %u32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P to be a float scalar or vector"));
- }
- TEST_P(ValidateOpenCLStdLengthLike, VectorTooBig) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f32vec8_01010101\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P to have no more than 4 components"));
- }
- TEST_P(ValidateOpenCLStdLengthLike, DifferentType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f64 %extinst " + ext_inst_name + " %f32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P component type to be equal to "
- "Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllLengthLike, ValidateOpenCLStdLengthLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "length",
- "fast_length",
- }));
- TEST_P(ValidateOpenCLStdDistanceLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32vec2_01 %f32vec2_01\n";
- ss << "%val2 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32vec4_0123 %f32vec4_1234\n";
- ss << "%val3 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdDistanceLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %u32 %extinst " + ext_inst_name +
- " %f32vec2_01 %f32vec2_12\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected Result Type to be a float scalar type"));
- }
- TEST_P(ValidateOpenCLStdDistanceLike, IntP0) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %u32vec2_01 %f32vec2_12\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P0 to be of float scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdDistanceLike, VectorTooBig) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f32vec8_01010101 %f32vec8_01010101\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P0 to have no more than 4 components"));
- }
- TEST_P(ValidateOpenCLStdDistanceLike, F64P0) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32 %extinst " + ext_inst_name +
- " %f64vec2_01 %f32vec2_12\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P0 component type to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdDistanceLike, DifferentOperands) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f64 %extinst " + ext_inst_name +
- " %f64vec2_01 %f32vec2_12\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operands P0 and P1 to be of the same type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllDistanceLike, ValidateOpenCLStdDistanceLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "distance",
- "fast_distance",
- }));
- TEST_P(ValidateOpenCLStdNormalizeLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01\n";
- ss << "%val2 = OpExtInst %f32vec4 %extinst " << ext_inst_name
- << " %f32vec4_0123\n";
- ss << "%val3 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32_2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdNormalizeLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %u32 %extinst " + ext_inst_name + " %f32_2\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected Result Type to be a float scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdNormalizeLike, VectorTooBig) {
- const std::string ext_inst_name = GetParam();
- const std::string body = "%val1 = OpExtInst %f32vec8 %extinst " +
- ext_inst_name + " %f32vec8_01010101\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected Result Type to have no more than 4 components"));
- }
- TEST_P(ValidateOpenCLStdNormalizeLike, DifferentType) {
- const std::string ext_inst_name = GetParam();
- const std::string body =
- "%val1 = OpExtInst %f64vec2 %extinst " + ext_inst_name + " %f32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand P type to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllNormalizeLike, ValidateOpenCLStdNormalizeLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "normalize",
- "fast_normalize",
- }));
- TEST_F(ValidateExtInst, OpenCLStdBitselectSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst bitselect %f32_2 %f32_1 %f32_1
- %val2 = OpExtInst %f32vec4 %extinst bitselect %f32vec4_0123 %f32vec4_1234 %f32vec4_0123
- %val3 = OpExtInst %u32 %extinst bitselect %u32_2 %u32_1 %u32_1
- %val4 = OpExtInst %u32vec4 %extinst bitselect %u32vec4_0123 %u32vec4_0123 %u32vec4_0123
- %val5 = OpExtInst %u64 %extinst bitselect %u64_2 %u64_1 %u64_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdBitselectWrongResultType) {
- const std::string body = R"(
- %val3 = OpExtInst %struct_f32_f32 %extinst bitselect %u32_2 %u32_1 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std bitselect: "
- "expected Result Type to be an int or float scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdBitselectAWrongType) {
- const std::string body = R"(
- %val3 = OpExtInst %u32 %extinst bitselect %f32_2 %u32_1 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std bitselect: "
- "expected types of all operands to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdBitselectBWrongType) {
- const std::string body = R"(
- %val3 = OpExtInst %u32 %extinst bitselect %u32_2 %f32_1 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std bitselect: "
- "expected types of all operands to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdBitselectCWrongType) {
- const std::string body = R"(
- %val3 = OpExtInst %u32 %extinst bitselect %u32_2 %u32_1 %f32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std bitselect: "
- "expected types of all operands to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst select %f32_2 %f32_1 %u32_1
- %val2 = OpExtInst %f32vec4 %extinst select %f32vec4_0123 %f32vec4_1234 %u32vec4_0123
- %val3 = OpExtInst %u32 %extinst select %u32_2 %u32_1 %u32_1
- %val4 = OpExtInst %u32vec4 %extinst select %u32vec4_0123 %u32vec4_0123 %u32vec4_0123
- %val5 = OpExtInst %u64 %extinst select %u64_2 %u64_1 %u64_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectWrongResultType) {
- const std::string body = R"(
- %val3 = OpExtInst %struct_f32_f32 %extinst select %u32_2 %u32_1 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std select: "
- "expected Result Type to be an int or float scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectAWrongType) {
- const std::string body = R"(
- %val3 = OpExtInst %u32 %extinst select %f32_2 %u32_1 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std select: "
- "expected operand A type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectBWrongType) {
- const std::string body = R"(
- %val3 = OpExtInst %u32 %extinst select %u32_2 %f32_1 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std select: "
- "expected operand B type to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectCWrongType) {
- const std::string body = R"(
- %val3 = OpExtInst %f32 %extinst select %f32_2 %f32_1 %f32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std select: "
- "expected operand C to be an int scalar or vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectCWrongComponentNumber) {
- const std::string body = R"(
- %val3 = OpExtInst %f32vec2 %extinst select %f32vec2_12 %f32vec2_01 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std select: "
- "expected operand C to have the same number of "
- "components as Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdSelectCWrongBitWidth) {
- const std::string body = R"(
- %val3 = OpExtInst %f32vec2 %extinst select %f32vec2_12 %f32vec2_01 %u64vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std select: "
- "expected operand C to have the same bit width as Result Type"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, SuccessPhysical32) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_1 %u32_1 %ptr" << rounding_mode << "\n";
- ss << "%val2 = OpExtInst %void %extinst " << ext_inst_name
- << " %f64_0 %u32_2 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- ss << "%val2 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec4_0123 %u32_0 %ptr" << rounding_mode << "\n";
- ss << "%val3 = OpExtInst %void %extinst " << ext_inst_name
- << " %f64vec2_01 %u32_2 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, SuccessPhysical64) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_1 %u64_1 %ptr" << rounding_mode << "\n";
- ss << "%val2 = OpExtInst %void %extinst " << ext_inst_name
- << " %f64_0 %u64_2 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u64_1 %ptr" << rounding_mode << "\n";
- ss << "%val2 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec4_0123 %u64_0 %ptr" << rounding_mode << "\n";
- ss << "%val3 = OpExtInst %void %extinst " << ext_inst_name
- << " %f64vec2_01 %u64_2 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, NonVoidResultType) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_1 %u32_1 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be void"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, WrongDataType) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f64vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Data to be a 32 or 64-bit float scalar"));
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f64_0 %u32_1 %ptr" << rounding_mode << "\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Data to be a 32 or 64-bit float vector"));
- }
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, AddressingModelLogical) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_0 %u32_1 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Logical"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- " can only be used with physical addressing models"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, OffsetNotSizeT) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_0 %u32_1 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": "
- "expected operand Offset to be of type size_t (64-bit integer "
- "for the addressing model used in the module)"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, PNotPointer) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_0 %u32_1 %f16_ptr_workgroup" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %f16_ptr_workgroup" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 89[%_ptr_Workgroup_half] cannot be a type"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, ConstPointer) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_uniform_constant "
- "%f16vec8_uniform_constant %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_0 %u32_1 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand P storage class to be Generic, "
- "CrossWorkgroup, Workgroup or Function"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, PDataTypeInt) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %u32_ptr_workgroup %u32vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_0 %u32_1 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand P data type to be 16-bit float scalar"));
- }
- TEST_P(ValidateOpenCLStdVStoreHalfLike, PDataTypeFloat32) {
- const std::string ext_inst_name = GetParam();
- const std::string rounding_mode =
- ext_inst_name.substr(ext_inst_name.length() - 2) == "_r" ? " RTE" : "";
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- if (std::string::npos == ext_inst_name.find("halfn")) {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32_0 %u32_1 %ptr" << rounding_mode << "\n";
- } else {
- ss << "%val1 = OpExtInst %void %extinst " << ext_inst_name
- << " %f32vec2_01 %u32_1 %ptr" << rounding_mode << "\n";
- }
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand P data type to be 16-bit float scalar"));
- }
- INSTANTIATE_TEST_SUITE_P(AllVStoreHalfLike, ValidateOpenCLStdVStoreHalfLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "vstore_half",
- "vstore_half_r",
- "vstore_halfn",
- "vstore_halfn_r",
- "vstorea_halfn",
- "vstorea_halfn_r",
- }));
- TEST_P(ValidateOpenCLStdVLoadHalfLike, SuccessPhysical32) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %ptr 2\n";
- ss << "%val2 = OpExtInst %f32vec3 %extinst " << ext_inst_name
- << " %u32_1 %ptr 3\n";
- ss << "%val3 = OpExtInst %f32vec4 %extinst " << ext_inst_name
- << " %u32_1 %ptr 4\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, SuccessPhysical64) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u64_1 %ptr 2\n";
- ss << "%val2 = OpExtInst %f32vec3 %extinst " << ext_inst_name
- << " %u64_1 %ptr 3\n";
- ss << "%val3 = OpExtInst %f32vec4 %extinst " << ext_inst_name
- << " %u64_1 %ptr 4\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, ResultTypeNotFloatVector) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %u32_1 %ptr 1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float vector type"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, AddressingModelLogical) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Logical"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- " can only be used with physical addressing models"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, OffsetNotSizeT) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u64_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand Offset to be of type size_t (32-bit "
- "integer for the addressing model used in the module)"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, PNotPointer) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %f16_ptr_workgroup 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 89[%_ptr_Workgroup_half] cannot be a type"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, OffsetWrongStorageType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_input %f16vec8_input %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand P storage class to be UniformConstant, "
- "Generic, CrossWorkgroup, Workgroup or Function"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, PDataTypeInt) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %u32_ptr_workgroup %u32vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand P data type to be 16-bit float scalar"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, PDataTypeFloat32) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected operand P data type to be 16-bit float scalar"));
- }
- TEST_P(ValidateOpenCLStdVLoadHalfLike, WrongN) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_workgroup %f16vec8_workgroup %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %u32_1 %ptr 3\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected literal N to be equal to the number of "
- "components of Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllVLoadHalfLike, ValidateOpenCLStdVLoadHalfLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "vload_halfn",
- "vloada_halfn",
- }));
- TEST_F(ValidateExtInst, VLoadNSuccessFloatPhysical32) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst vloadn %u32_1 %ptr 2\n";
- ss << "%val2 = OpExtInst %f32vec3 %extinst vloadn %u32_1 %ptr 3\n";
- ss << "%val3 = OpExtInst %f32vec4 %extinst vloadn %u32_1 %ptr 4\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VLoadNSuccessIntPhysical32) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %u32_ptr_uniform_constant "
- "%u32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %u32vec2 %extinst vloadn %u32_1 %ptr 2\n";
- ss << "%val2 = OpExtInst %u32vec3 %extinst vloadn %u32_1 %ptr 3\n";
- ss << "%val3 = OpExtInst %u32vec4 %extinst vloadn %u32_1 %ptr 4\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VLoadNSuccessFloatPhysical64) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst vloadn %u64_1 %ptr 2\n";
- ss << "%val2 = OpExtInst %f32vec3 %extinst vloadn %u64_1 %ptr 3\n";
- ss << "%val3 = OpExtInst %f32vec4 %extinst vloadn %u64_1 %ptr 4\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VLoadNSuccessIntPhysical64) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %u32_ptr_uniform_constant "
- "%u32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %u32vec2 %extinst vloadn %u64_1 %ptr 2\n";
- ss << "%val2 = OpExtInst %u32vec3 %extinst vloadn %u64_1 %ptr 3\n";
- ss << "%val3 = OpExtInst %u32vec4 %extinst vloadn %u64_1 %ptr 4\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VLoadNWrongResultType) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vloadn %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std vloadn: "
- "expected Result Type to be an int or float vector type"));
- }
- TEST_F(ValidateExtInst, VLoadNAddressingModelLogical) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst vloadn %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Logical"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vloadn can only be used with physical "
- "addressing models"));
- }
- TEST_F(ValidateExtInst, VLoadNOffsetNotSizeT) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst vloadn %u64_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std vloadn: expected operand Offset to be of type size_t "
- "(32-bit integer for the addressing model used in the module)"));
- }
- TEST_F(ValidateExtInst, VLoadNPNotPointer) {
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32vec2 %extinst vloadn %u32_1 "
- "%f32_ptr_uniform_constant 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 120[%_ptr_UniformConstant_float] cannot be a "
- "type"));
- }
- TEST_F(ValidateExtInst, VLoadNWrongStorageClass) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %u32_ptr_input %u32vec8_input %u32_1\n";
- ss << "%val1 = OpExtInst %u32vec2 %extinst vloadn %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vloadn: expected operand P storage class "
- "to be UniformConstant, Generic, CrossWorkgroup, "
- "Workgroup or Function"));
- }
- TEST_F(ValidateExtInst, VLoadNWrongComponentType) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %u32vec2 %extinst vloadn %u32_1 %ptr 2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vloadn: expected operand P data type to be "
- "equal to component type of Result Type"));
- }
- TEST_F(ValidateExtInst, VLoadNWrongN) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst vloadn %u32_1 %ptr 3\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vloadn: expected literal N to be equal to "
- "the number of components of Result Type"));
- }
- TEST_F(ValidateExtInst, VLoadHalfSuccessPhysical32) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_uniform_constant "
- "%f16vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u32_1 %ptr\n";
- ss << "%val2 = OpExtInst %f64 %extinst vload_half %u32_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VLoadHalfSuccessPhysical64) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_uniform_constant "
- "%f16vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u64_1 %ptr\n";
- ss << "%val2 = OpExtInst %f64 %extinst vload_half %u64_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VLoadHalfWrongResultType) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_uniform_constant "
- "%f16vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %u32 %extinst vload_half %u32_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vload_half: "
- "expected Result Type to be a float scalar type"));
- }
- TEST_F(ValidateExtInst, VLoadHalfAddressingModelLogical) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_uniform_constant "
- "%f16vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u32_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Logical"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vload_half can only be used with physical "
- "addressing models"));
- }
- TEST_F(ValidateExtInst, VLoadHalfOffsetNotSizeT) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_uniform_constant "
- "%f16vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u64_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std vload_half: expected operand Offset to be of type size_t "
- "(32-bit integer for the addressing model used in the module)"));
- }
- TEST_F(ValidateExtInst, VLoadHalfPNotPointer) {
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u32_1 "
- "%f16_ptr_uniform_constant\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 114[%_ptr_UniformConstant_half] cannot be a "
- "type"));
- }
- TEST_F(ValidateExtInst, VLoadHalfWrongStorageClass) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f16_ptr_input %f16vec8_input %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u32_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std vload_half: expected operand P storage class to be "
- "UniformConstant, Generic, CrossWorkgroup, Workgroup or Function"));
- }
- TEST_F(ValidateExtInst, VLoadHalfPDataTypeInt) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %u32_ptr_uniform_constant "
- "%u32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u32_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vload_half: expected operand P data type "
- "to be 16-bit float scalar"));
- }
- TEST_F(ValidateExtInst, VLoadHalfPDataTypeFloat32) {
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst vload_half %u32_1 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vload_half: expected operand P data type "
- "to be 16-bit float scalar"));
- }
- TEST_F(ValidateExtInst, VStoreNSuccessFloatPhysical32) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32vec2_01 %u32_1 %ptr_g\n";
- ss << "%val2 = OpExtInst %void %extinst vstoren %f32vec4_0123 %u32_1 "
- "%ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VStoreNSuccessFloatPhysical64) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32vec2_01 %u64_1 %ptr_g\n";
- ss << "%val2 = OpExtInst %void %extinst vstoren %f32vec4_0123 %u64_1 "
- "%ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VStoreNSuccessIntPhysical32) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %u32_ptr_workgroup %u32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %u32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %u32vec2_01 %u32_1 %ptr_g\n";
- ss << "%val2 = OpExtInst %void %extinst vstoren %u32vec4_0123 %u32_1 "
- "%ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VStoreNSuccessIntPhysical64) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %u32_ptr_workgroup %u32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %u32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %u32vec2_01 %u64_1 %ptr_g\n";
- ss << "%val2 = OpExtInst %void %extinst vstoren %u32vec4_0123 %u64_1 "
- "%ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, VStoreNResultTypeNotVoid) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %f32 %extinst vstoren %f32vec2_01 %u32_1 %ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vstoren: expected Result Type to be void"));
- }
- TEST_F(ValidateExtInst, VStoreNDataWrongType) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32_1 %u32_1 %ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std vstoren: expected Data to be an int or float vector"));
- }
- TEST_F(ValidateExtInst, VStoreNAddressingModelLogical) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32vec2_01 %u32_1 %ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Logical"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vstoren can only be used with physical "
- "addressing models"));
- }
- TEST_F(ValidateExtInst, VStoreNOffsetNotSizeT) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32vec2_01 %u32_1 %ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str(), "", "Physical64"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std vstoren: expected operand Offset to be of type size_t "
- "(64-bit integer for the addressing model used in the module)"));
- }
- TEST_F(ValidateExtInst, VStoreNPNotPointer) {
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32vec2_01 %u32_1 "
- "%f32_ptr_generic\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 127[%_ptr_Generic_float] cannot be a type"));
- }
- TEST_F(ValidateExtInst, VStoreNWrongStorageClass) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %f32vec2_01 %u32_1 %ptr_w\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std vstoren: expected operand P storage class "
- "to be Generic, CrossWorkgroup, Workgroup or Function"));
- }
- TEST_F(ValidateExtInst, VStorePWrongDataType) {
- std::ostringstream ss;
- ss << "%ptr_w = OpAccessChain %f32_ptr_workgroup %f32vec8_workgroup %u32_1\n";
- ss << "%ptr_g = OpPtrCastToGeneric %f32_ptr_generic %ptr_w\n";
- ss << "%val1 = OpExtInst %void %extinst vstoren %u32vec2_01 %u32_1 %ptr_g\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std vstoren: expected operand P data type to "
- "be equal to the type of operand Data components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle %f32vec4_0123 %u32vec2_01
- %val2 = OpExtInst %f32vec4 %extinst shuffle %f32vec4_0123 %u32vec4_0123
- %val3 = OpExtInst %u32vec2 %extinst shuffle %u32vec4_0123 %u32vec2_01
- %val4 = OpExtInst %u32vec4 %extinst shuffle %u32vec4_0123 %u32vec4_0123
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleWrongResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst shuffle %f32vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected Result Type to be an int or float vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleResultTypeInvalidNumComponents) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst shuffle %f32vec4_0123 %u32vec3_012
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected Result Type to have 2, 4, 8 or 16 components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleXWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle %f32_0 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected operand X to be an int or float vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleXInvalidNumComponents) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle %f32vec3_012 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected operand X to have 2, 4, 8 or 16 components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleXInvalidComponentType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle %f64vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std shuffle: "
- "expected operand X and Result Type to have equal component types"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleShuffleMaskNotIntVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle %f32vec4_0123 %f32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected operand Shuffle Mask to be an int vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleShuffleMaskInvalidNumComponents) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec4 %extinst shuffle %f32vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected operand Shuffle Mask to have the same number "
- "of components as Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffleShuffleMaskInvalidBitWidth) {
- const std::string body = R"(
- %val1 = OpExtInst %f64vec2 %extinst shuffle %f64vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle: "
- "expected operand Shuffle Mask components to have the "
- "same bit width as Result Type components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2Success) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle2 %f32vec4_0123 %f32vec4_0123 %u32vec2_01
- %val2 = OpExtInst %f32vec4 %extinst shuffle2 %f32vec4_0123 %f32vec4_0123 %u32vec4_0123
- %val3 = OpExtInst %u32vec2 %extinst shuffle2 %u32vec4_0123 %u32vec4_0123 %u32vec2_01
- %val4 = OpExtInst %u32vec4 %extinst shuffle2 %u32vec4_0123 %u32vec4_0123 %u32vec4_0123
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2WrongResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst shuffle2 %f32vec4_0123 %f32vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected Result Type to be an int or float vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2ResultTypeInvalidNumComponents) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec3 %extinst shuffle2 %f32vec4_0123 %f32vec4_0123 %u32vec3_012
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected Result Type to have 2, 4, 8 or 16 components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2XWrongType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle2 %f32_0 %f32_0 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected operand X to be an int or float vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2YTypeDifferentFromX) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle2 %f32vec2_01 %f32vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected operands X and Y to be of the same type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2XInvalidNumComponents) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle2 %f32vec3_012 %f32vec3_012 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected operand X to have 2, 4, 8 or 16 components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2XInvalidComponentType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle2 %f64vec4_0123 %f64vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std shuffle2: "
- "expected operand X and Result Type to have equal component types"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2ShuffleMaskNotIntVector) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec2 %extinst shuffle2 %f32vec4_0123 %f32vec4_0123 %f32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected operand Shuffle Mask to be an int vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2ShuffleMaskInvalidNumComponents) {
- const std::string body = R"(
- %val1 = OpExtInst %f32vec4 %extinst shuffle2 %f32vec4_0123 %f32vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected operand Shuffle Mask to have the same number "
- "of components as Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdShuffle2ShuffleMaskInvalidBitWidth) {
- const std::string body = R"(
- %val1 = OpExtInst %f64vec2 %extinst shuffle2 %f64vec4_0123 %f64vec4_0123 %u32vec2_01
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std shuffle2: "
- "expected operand Shuffle Mask components to have the "
- "same bit width as Result Type components"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrintfSuccess) {
- const std::string body = R"(
- %format = OpAccessChain %u8_ptr_uniform_constant %u8arr_uniform_constant %u32_0
- %val1 = OpExtInst %u32 %extinst printf %format %u32_0 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdPrintfBoolResultType) {
- const std::string body = R"(
- %format = OpAccessChain %u8_ptr_uniform_constant %u8arr_uniform_constant %u32_0
- %val1 = OpExtInst %bool %extinst printf %format %u32_0 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std printf: expected Result Type to be a 32-bit int type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrintfU64ResultType) {
- const std::string body = R"(
- %format = OpAccessChain %u8_ptr_uniform_constant %u8arr_uniform_constant %u32_0
- %val1 = OpExtInst %u64 %extinst printf %format %u32_0 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std printf: expected Result Type to be a 32-bit int type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst printf %u8_ptr_uniform_constant %u32_0 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 137[%_ptr_UniformConstant_uchar] cannot be a "
- "type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotUniformConstStorageClass) {
- const std::string body = R"(
- %format_const = OpAccessChain %u8_ptr_uniform_constant %u8arr_uniform_constant %u32_0
- %format = OpBitcast %u8_ptr_generic %format_const
- %val1 = OpExtInst %u32 %extinst printf %format %u32_0 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std printf: expected Format storage class to "
- "be UniformConstant"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrintfFormatNotU8Pointer) {
- const std::string body = R"(
- %format = OpAccessChain %u32_ptr_uniform_constant %u32vec8_uniform_constant %u32_0
- %val1 = OpExtInst %u32 %extinst printf %format %u32_0 %u32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std printf: expected Format data type to be 8-bit int"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchU32Success) {
- const std::string body = R"(
- %ptr = OpAccessChain %u32_ptr_cross_workgroup %u32arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchU32Physical64Success) {
- const std::string body = R"(
- %ptr = OpAccessChain %u32_ptr_cross_workgroup %u32arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u64_256
- )";
- CompileSuccessfully(GenerateKernelCode(body, "", "Physical64"));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchF32Success) {
- const std::string body = R"(
- %ptr = OpAccessChain %f32_ptr_cross_workgroup %f32arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchF32Vec2Success) {
- const std::string body = R"(
- %ptr = OpAccessChain %f32vec2_ptr_cross_workgroup %f32vec2arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchResultTypeNotVoid) {
- const std::string body = R"(
- %ptr = OpAccessChain %u32_ptr_cross_workgroup %u32arr_cross_workgroup %u32_0
- %val1 = OpExtInst %u32 %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std prefetch: expected Result Type to be void"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchPtrNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %void %extinst prefetch %u32_ptr_cross_workgroup %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 99[%_ptr_CrossWorkgroup_uint] cannot be a "
- "type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchPtrNotCrossWorkgroup) {
- const std::string body = R"(
- %ptr = OpAccessChain %u8_ptr_uniform_constant %u8arr_uniform_constant %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std prefetch: expected operand Ptr storage "
- "class to be CrossWorkgroup"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchInvalidDataType) {
- const std::string body = R"(
- %ptr = OpAccessChain %struct_ptr_cross_workgroup %struct_arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std prefetch: expected Ptr data type to be int "
- "or float scalar or vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchAddressingModelLogical) {
- const std::string body = R"(
- %ptr = OpAccessChain %u32_ptr_cross_workgroup %u32arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body, "", "Logical"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std prefetch can only be used with physical "
- "addressing models"));
- }
- TEST_F(ValidateExtInst, OpenCLStdPrefetchNumElementsNotSizeT) {
- const std::string body = R"(
- %ptr = OpAccessChain %f32_ptr_cross_workgroup %f32arr_cross_workgroup %u32_0
- %val1 = OpExtInst %void %extinst prefetch %ptr %u32_256
- )";
- CompileSuccessfully(GenerateKernelCode(body, "", "Physical64"));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std prefetch: expected operand Num Elements to "
- "be of type size_t (64-bit integer for the addressing "
- "model used in the module)"));
- }
- TEST_P(ValidateOpenCLStdFractLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_f32 = OpVariable %f32_ptr_function Function\n";
- ss << "%var_f32vec2 = OpVariable %f32vec2_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %var_f32\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %var_f32vec2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdFractLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_f32 = OpVariable %f32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %f32_0 %var_f32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdFractLike, XWrongType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_f32 = OpVariable %f32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f64_0 %var_f32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected type of operand X to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdFractLike, NotPointer) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_f32 = OpVariable %f32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected the last operand to be a pointer"));
- }
- TEST_P(ValidateOpenCLStdFractLike, PointerInvalidStorageClass) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32_0 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected storage class of the pointer to be "
- "Generic, CrossWorkgroup, Workgroup or Function"));
- }
- TEST_P(ValidateOpenCLStdFractLike, PointerWrongDataType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_u32 = OpVariable %u32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %var_u32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": expected data type of the pointer to be equal to Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllFractLike, ValidateOpenCLStdFractLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "fract",
- "modf",
- "sincos",
- }));
- TEST_F(ValidateExtInst, OpenCLStdRemquoSuccess) {
- const std::string body = R"(
- %var_u32 = OpVariable %u32_ptr_function Function
- %var_u32vec2 = OpVariable %u32vec2_ptr_function Function
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %f32_2 %var_u32
- %val2 = OpExtInst %f32vec2 %extinst remquo %f32vec2_01 %f32vec2_12 %var_u32vec2
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoIntResultType) {
- const std::string body = R"(
- %var_u32 = OpVariable %u32_ptr_function Function
- %val1 = OpExtInst %u32 %extinst remquo %f32_3 %f32_2 %var_u32
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected Result Type to be a float scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoXWrongType) {
- const std::string body = R"(
- %var_u32 = OpVariable %f32_ptr_function Function
- %val1 = OpExtInst %f32 %extinst remquo %u32_3 %f32_2 %var_u32
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected type of operand X to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoYWrongType) {
- const std::string body = R"(
- %var_u32 = OpVariable %f32_ptr_function Function
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %u32_2 %var_u32
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected type of operand Y to be equal to Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoNotPointer) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %f32_2 %f32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected the last operand to be a pointer"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoPointerWrongStorageClass) {
- const std::string body = R"(
- %ptr = OpAccessChain %f32_ptr_uniform_constant %f32vec8_uniform_constant %u32_1
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %f32_2 %ptr
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected storage class of the pointer to be Generic, "
- "CrossWorkgroup, Workgroup or Function"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoPointerWrongDataType) {
- const std::string body = R"(
- %var_f32 = OpVariable %f32_ptr_function Function
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %f32_2 %var_f32
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected data type of the pointer to be a 32-bit int "
- "scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoPointerWrongDataTypeWidth) {
- const std::string body = R"(
- %var_u64 = OpVariable %u64_ptr_function Function
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %f32_2 %var_u64
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected data type of the pointer to be a 32-bit int "
- "scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdRemquoPointerWrongNumberOfComponents) {
- const std::string body = R"(
- %var_u32vec2 = OpVariable %u32vec2_ptr_function Function
- %val1 = OpExtInst %f32 %extinst remquo %f32_3 %f32_2 %var_u32vec2
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std remquo: "
- "expected data type of the pointer to have the same number "
- "of components as Result Type"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_u32 = OpVariable %u32_ptr_function Function\n";
- ss << "%var_u32vec2 = OpVariable %u32vec2_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %var_u32\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %var_u32vec2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdFrexpLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_u32 = OpVariable %u32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %f32_0 %var_u32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, XWrongType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_u32 = OpVariable %u32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f64_0 %var_u32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected type of operand X to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, NotPointer) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected the last operand to be a pointer"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, PointerInvalidStorageClass) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%ptr = OpAccessChain %f32_ptr_uniform_constant "
- "%f32vec8_uniform_constant %u32_1\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name << " %f32_0 %ptr\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected storage class of the pointer to be "
- "Generic, CrossWorkgroup, Workgroup or Function"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, PointerDataTypeFloat) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_f32 = OpVariable %f32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %var_f32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected data type of the pointer to be a 32-bit "
- "int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, PointerDataTypeU64) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_u64 = OpVariable %u64_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %var_u64\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected data type of the pointer to be a 32-bit "
- "int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdFrexpLike, PointerDataTypeDiffSize) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%var_u32 = OpVariable %u32_ptr_function Function\n";
- ss << "%val1 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_01 %var_u32\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected data type of the pointer to have the same "
- "number of components as Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllFrexpLike, ValidateOpenCLStdFrexpLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "frexp",
- "lgamma_r",
- }));
- TEST_F(ValidateExtInst, OpenCLStdIlogbSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst ilogb %f32_3
- %val2 = OpExtInst %u32vec2 %extinst ilogb %f32vec2_12
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdIlogbFloatResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst ilogb %f32_3
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std ilogb: "
- "expected Result Type to be a 32-bit int scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdIlogbIntX) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst ilogb %u32_3
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std ilogb: "
- "expected operand X to be a float scalar or vector"));
- }
- TEST_F(ValidateExtInst, OpenCLStdIlogbDiffSize) {
- const std::string body = R"(
- %val2 = OpExtInst %u32vec2 %extinst ilogb %f32_1
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std ilogb: "
- "expected operand X to have the same number of "
- "components as Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdNanSuccess) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst nan %u32_3
- %val2 = OpExtInst %f32vec2 %extinst nan %u32vec2_12
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateExtInst, OpenCLStdNanIntResultType) {
- const std::string body = R"(
- %val1 = OpExtInst %u32 %extinst nan %u32_3
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std nan: "
- "expected Result Type to be a float scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdNanFloatNancode) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst nan %f32_3
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std nan: "
- "expected Nancode to be an int scalar or vector type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdNanFloatDiffSize) {
- const std::string body = R"(
- %val1 = OpExtInst %f32 %extinst nan %u32vec2_12
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std nan: "
- "expected Nancode to have the same number of "
- "components as Result Type"));
- }
- TEST_F(ValidateExtInst, OpenCLStdNanFloatDiffBitWidth) {
- const std::string body = R"(
- %val1 = OpExtInst %f64 %extinst nan %u32_2
- )";
- CompileSuccessfully(GenerateKernelCode(body));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std nan: "
- "expected Nancode to have the same bit width as Result Type"));
- }
- TEST_P(ValidateOpenCLStdLdexpLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %u32_1\n";
- ss << "%val2 = OpExtInst %f32vec2 %extinst " << ext_inst_name
- << " %f32vec2_12 %u32vec2_12\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdLdexpLike, IntResultType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %f32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be a float scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdLdexpLike, XWrongType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %u32_0 %u32_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected type of operand X to be equal to Result Type"));
- }
- TEST_P(ValidateOpenCLStdLdexpLike, ExponentNotInt) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %f32_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected the exponent to be a 32-bit int scalar or vector"));
- }
- TEST_P(ValidateOpenCLStdLdexpLike, ExponentNotInt32) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %u64_1\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected the exponent to be a 32-bit int scalar or vector"));
- }
- TEST_P(ValidateOpenCLStdLdexpLike, ExponentWrongSize) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f32 %extinst " << ext_inst_name
- << " %f32_0 %u32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected the exponent to have the same number of "
- "components as Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllLdexpLike, ValidateOpenCLStdLdexpLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "ldexp",
- "pown",
- "rootn",
- }));
- TEST_P(ValidateOpenCLStdUpsampleLike, Success) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u16 %extinst " << ext_inst_name << " %u8_1 %u8_2\n";
- ss << "%val2 = OpExtInst %u32 %extinst " << ext_inst_name
- << " %u16_1 %u16_2\n";
- ss << "%val3 = OpExtInst %u64 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- ss << "%val4 = OpExtInst %u64vec2 %extinst " << ext_inst_name
- << " %u32vec2_01 %u32vec2_01\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ValidateOpenCLStdUpsampleLike, FloatResultType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %f64 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Result Type to be an int scalar or vector type"));
- }
- TEST_P(ValidateOpenCLStdUpsampleLike, InvalidResultTypeBitWidth) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u8 %extinst " << ext_inst_name << " %u8_1 %u8_2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "OpenCL.std " + ext_inst_name +
- ": expected bit width of Result Type components to be 16, 32 or 64"));
- }
- TEST_P(ValidateOpenCLStdUpsampleLike, LoHiDiffType) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u64 %extinst " << ext_inst_name
- << " %u32_1 %u16_2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Hi and Lo operands to have the same type"));
- }
- TEST_P(ValidateOpenCLStdUpsampleLike, DiffNumberOfComponents) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u64vec2 %extinst " << ext_inst_name
- << " %u32_1 %u32_2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected Hi and Lo operands to have the same number "
- "of components as Result Type"));
- }
- TEST_P(ValidateOpenCLStdUpsampleLike, HiLoWrongBitWidth) {
- const std::string ext_inst_name = GetParam();
- std::ostringstream ss;
- ss << "%val1 = OpExtInst %u64 %extinst " << ext_inst_name
- << " %u16_1 %u16_2\n";
- CompileSuccessfully(GenerateKernelCode(ss.str()));
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("OpenCL.std " + ext_inst_name +
- ": expected bit width of components of Hi and Lo operands to "
- "be half of the bit width of components of Result Type"));
- }
- INSTANTIATE_TEST_SUITE_P(AllUpsampleLike, ValidateOpenCLStdUpsampleLike,
- ::testing::ValuesIn(std::vector<std::string>{
- "u_upsample",
- "s_upsample",
- }));
- TEST_F(ValidateClspvReflection, RequiresNonSemanticExtension) {
- const std::string text = R"(
- OpCapability Shader
- OpCapability Linkage
- %1 = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("NonSemantic extended instruction sets cannot be "
- "declared without SPV_KHR_non_semantic_info"));
- }
- TEST_F(ValidateClspvReflection, MissingVersion) {
- const std::string text = R"(
- OpCapability Shader
- OpCapability Linkage
- OpExtension "SPV_KHR_non_semantic_info"
- %1 = OpExtInstImport "NonSemantic.ClspvReflection."
- OpMemoryModel Logical GLSL450
- %2 = OpTypeVoid
- %3 = OpTypeInt 32 0
- %4 = OpConstant %3 1
- %5 = OpExtInst %2 %1 SpecConstantWorkDim %4
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Missing NonSemantic.ClspvReflection import version"));
- }
- TEST_F(ValidateClspvReflection, BadVersion0) {
- const std::string text = R"(
- OpCapability Shader
- OpCapability Linkage
- OpExtension "SPV_KHR_non_semantic_info"
- %1 = OpExtInstImport "NonSemantic.ClspvReflection.0"
- OpMemoryModel Logical GLSL450
- %2 = OpTypeVoid
- %3 = OpTypeInt 32 0
- %4 = OpConstant %3 1
- %5 = OpExtInst %2 %1 SpecConstantWorkDim %4
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Unknown NonSemantic.ClspvReflection import version"));
- }
- TEST_F(ValidateClspvReflection, BadVersionNotANumber) {
- const std::string text = R"(
- OpCapability Shader
- OpCapability Linkage
- OpExtension "SPV_KHR_non_semantic_info"
- %1 = OpExtInstImport "NonSemantic.ClspvReflection.1a"
- OpMemoryModel Logical GLSL450
- %2 = OpTypeVoid
- %3 = OpTypeInt 32 0
- %4 = OpConstant %3 1
- %5 = OpExtInst %2 %1 SpecConstantWorkDim %4
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("NonSemantic.ClspvReflection import does not encode "
- "the version correctly"));
- }
- TEST_F(ValidateClspvReflection, Kernel) {
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateClspvReflection, KernelNotAFunction) {
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo_name %foo_name
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Kernel does not reference a function"));
- }
- TEST_F(ValidateClspvReflection, KernelNotAnEntryPoint) {
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %bar = OpFunction %void None %void_fn
- %bar_entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %bar %foo_name
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Kernel does not reference an entry-point"));
- }
- TEST_F(ValidateClspvReflection, KernelNotGLCompute) {
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Fragment %foo "foo"
- OpExecutionMode %foo OriginUpperLeft
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Kernel must refer only to GLCompute entry-points"));
- }
- TEST_F(ValidateClspvReflection, KernelNameMismatch) {
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "bar"
- %void = OpTypeVoid
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- )";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Name must match an entry-point for Kernel"));
- }
- using ArgumentBasics =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- INSTANTIATE_TEST_SUITE_P(
- ValidateClspvReflectionArgumentKernel, ArgumentBasics,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair("ArgumentStorageBuffer", "%int_0 %int_0"),
- std::make_pair("ArgumentUniform", "%int_0 %int_0"),
- std::make_pair("ArgumentPodStorageBuffer",
- "%int_0 %int_0 %int_0 %int_4"),
- std::make_pair("ArgumentPodUniform", "%int_0 %int_0 %int_0 %int_4"),
- std::make_pair("ArgumentPodPushConstant", "%int_0 %int_4"),
- std::make_pair("ArgumentSampledImage", "%int_0 %int_0"),
- std::make_pair("ArgumentStorageImage", "%int_0 %int_0"),
- std::make_pair("ArgumentSampler", "%int_0 %int_0"),
- std::make_pair("ArgumentWorkgroup", "%int_0 %int_0")}));
- TEST_P(ArgumentBasics, KernelNotAnExtendedInstruction) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string extra = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_4 = OpConstant %int 4
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %in = OpExtInst %void %ext )" +
- ext_inst + " %int_0 %int_0 " + extra;
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Kernel must be a Kernel extended instruction"));
- }
- TEST_P(ArgumentBasics, KernelFromDifferentImport) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string extra = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- %ext2 = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_4 = OpConstant %int 4
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext2 Kernel %foo %foo_name
- %in = OpExtInst %void %ext )" +
- ext_inst + " %decl %int_0 " + extra;
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("Kernel must be from the same extended instruction import"));
- }
- TEST_P(ArgumentBasics, KernelWrongExtendedInstruction) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string extra = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_4 = OpConstant %int 4
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext ArgumentInfo %foo_name
- %in = OpExtInst %void %ext )" +
- ext_inst + " %decl %int_0 " + extra;
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Kernel must be a Kernel extended instruction"));
- }
- TEST_P(ArgumentBasics, ArgumentInfo) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string operands = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %in_name = OpString "in"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_4 = OpConstant %int 4
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- %info = OpExtInst %void %ext ArgumentInfo %in_name
- %in = OpExtInst %void %ext )" +
- ext_inst + " %decl %int_0 " + operands + " %info";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_P(ArgumentBasics, ArgumentInfoNotAnExtendedInstruction) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string operands = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_4 = OpConstant %int 4
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- %in = OpExtInst %void %ext )" +
- ext_inst + " %decl %int_0 " + operands + " %int_0";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("ArgInfo must be an ArgumentInfo extended instruction"));
- }
- TEST_P(ArgumentBasics, ArgumentInfoFromDifferentImport) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string operands = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- %ext2 = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %in_name = OpString "in"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_4 = OpConstant %int 4
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- %info = OpExtInst %void %ext2 ArgumentInfo %in_name
- %in = OpExtInst %void %ext )" +
- ext_inst + " %decl %int_0 " + operands + " %info";
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("ArgInfo must be from the same extended instruction import"));
- }
- using Uint32Constant =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- INSTANTIATE_TEST_SUITE_P(
- ValidateClspvReflectionUint32Constants, Uint32Constant,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair("ArgumentStorageBuffer %decl %float_0 %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentStorageBuffer %decl %null %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentStorageBuffer %decl %int_0 %float_0 %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentStorageBuffer %decl %int_0 %null %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentStorageBuffer %decl %int_0 %int_0 %float_0",
- "Binding"),
- std::make_pair("ArgumentStorageBuffer %decl %int_0 %int_0 %null",
- "Binding"),
- std::make_pair("ArgumentUniform %decl %float_0 %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentUniform %decl %null %int_0 %int_0", "Ordinal"),
- std::make_pair("ArgumentUniform %decl %int_0 %float_0 %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentUniform %decl %int_0 %null %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentUniform %decl %int_0 %int_0 %float_0",
- "Binding"),
- std::make_pair("ArgumentUniform %decl %int_0 %int_0 %null", "Binding"),
- std::make_pair("ArgumentSampledImage %decl %float_0 %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentSampledImage %decl %null %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentSampledImage %decl %int_0 %float_0 %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentSampledImage %decl %int_0 %null %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentSampledImage %decl %int_0 %int_0 %float_0",
- "Binding"),
- std::make_pair("ArgumentSampledImage %decl %int_0 %int_0 %null",
- "Binding"),
- std::make_pair("ArgumentStorageImage %decl %float_0 %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentStorageImage %decl %null %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentStorageImage %decl %int_0 %float_0 %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentStorageImage %decl %int_0 %null %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentStorageImage %decl %int_0 %int_0 %float_0",
- "Binding"),
- std::make_pair("ArgumentStorageImage %decl %int_0 %int_0 %null",
- "Binding"),
- std::make_pair("ArgumentSampler %decl %float_0 %int_0 %int_0",
- "Ordinal"),
- std::make_pair("ArgumentSampler %decl %null %int_0 %int_0", "Ordinal"),
- std::make_pair("ArgumentSampler %decl %int_0 %float_0 %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentSampler %decl %int_0 %null %int_0",
- "DescriptorSet"),
- std::make_pair("ArgumentSampler %decl %int_0 %int_0 %float_0",
- "Binding"),
- std::make_pair("ArgumentSampler %decl %int_0 %int_0 %null", "Binding"),
- std::make_pair("ArgumentPodStorageBuffer %decl %float_0 %int_0 %int_0 "
- "%int_0 %int_4",
- "Ordinal"),
- std::make_pair(
- "ArgumentPodStorageBuffer %decl %null %int_0 %int_0 %int_0 %int_4",
- "Ordinal"),
- std::make_pair("ArgumentPodStorageBuffer %decl %int_0 %float_0 %int_0 "
- "%int_0 %int_4",
- "DescriptorSet"),
- std::make_pair(
- "ArgumentPodStorageBuffer %decl %int_0 %null %int_0 %int_0 %int_4",
- "DescriptorSet"),
- std::make_pair("ArgumentPodStorageBuffer %decl %int_0 %int_0 %float_0 "
- "%int_0 %int_4",
- "Binding"),
- std::make_pair(
- "ArgumentPodStorageBuffer %decl %int_0 %int_0 %null %int_0 %int_4",
- "Binding"),
- std::make_pair("ArgumentPodStorageBuffer %decl %int_0 %int_0 %int_0 "
- "%float_0 %int_4",
- "Offset"),
- std::make_pair(
- "ArgumentPodStorageBuffer %decl %int_0 %int_0 %int_0 %null %int_4",
- "Offset"),
- std::make_pair("ArgumentPodStorageBuffer %decl %int_0 %int_0 %int_0 "
- "%int_0 %float_0",
- "Size"),
- std::make_pair(
- "ArgumentPodStorageBuffer %decl %int_0 %int_0 %int_0 %int_0 %null",
- "Size"),
- std::make_pair(
- "ArgumentPodUniform %decl %float_0 %int_0 %int_0 %int_0 %int_4",
- "Ordinal"),
- std::make_pair(
- "ArgumentPodUniform %decl %null %int_0 %int_0 %int_0 %int_4",
- "Ordinal"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %float_0 %int_0 %int_0 %int_4",
- "DescriptorSet"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %null %int_0 %int_0 %int_4",
- "DescriptorSet"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %int_0 %float_0 %int_0 %int_4",
- "Binding"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %int_0 %null %int_0 %int_4",
- "Binding"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %int_0 %int_0 %float_0 %int_4",
- "Offset"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %int_0 %int_0 %null %int_4",
- "Offset"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %int_0 %int_0 %int_0 %float_0",
- "Size"),
- std::make_pair(
- "ArgumentPodUniform %decl %int_0 %int_0 %int_0 %int_0 %null",
- "Size"),
- std::make_pair("ArgumentPodPushConstant %decl %float_0 %int_0 %int_4",
- "Ordinal"),
- std::make_pair("ArgumentPodPushConstant %decl %null %int_0 %int_4",
- "Ordinal"),
- std::make_pair("ArgumentPodPushConstant %decl %int_0 %float_0 %int_4",
- "Offset"),
- std::make_pair("ArgumentPodPushConstant %decl %int_0 %null %int_4",
- "Offset"),
- std::make_pair("ArgumentPodPushConstant %decl %int_0 %int_0 %float_0",
- "Size"),
- std::make_pair("ArgumentPodPushConstant %decl %int_0 %int_0 %null",
- "Size"),
- std::make_pair("ArgumentWorkgroup %decl %float_0 %int_0 %int_4",
- "Ordinal"),
- std::make_pair("ArgumentWorkgroup %decl %null %int_0 %int_4",
- "Ordinal"),
- std::make_pair("ArgumentWorkgroup %decl %int_0 %float_0 %int_4",
- "SpecId"),
- std::make_pair("ArgumentWorkgroup %decl %int_0 %null %int_4", "SpecId"),
- std::make_pair("ArgumentWorkgroup %decl %int_0 %int_0 %float_0",
- "ElemSize"),
- std::make_pair("ArgumentWorkgroup %decl %int_0 %int_0 %null",
- "ElemSize"),
- std::make_pair("SpecConstantWorkgroupSize %float_0 %int_0 %int_4", "X"),
- std::make_pair("SpecConstantWorkgroupSize %null %int_0 %int_4", "X"),
- std::make_pair("SpecConstantWorkgroupSize %int_0 %float_0 %int_4", "Y"),
- std::make_pair("SpecConstantWorkgroupSize %int_0 %null %int_4", "Y"),
- std::make_pair("SpecConstantWorkgroupSize %int_0 %int_0 %float_0", "Z"),
- std::make_pair("SpecConstantWorkgroupSize %int_0 %int_0 %null", "Z"),
- std::make_pair("SpecConstantGlobalOffset %float_0 %int_0 %int_4", "X"),
- std::make_pair("SpecConstantGlobalOffset %null %int_0 %int_4", "X"),
- std::make_pair("SpecConstantGlobalOffset %int_0 %float_0 %int_4", "Y"),
- std::make_pair("SpecConstantGlobalOffset %int_0 %null %int_4", "Y"),
- std::make_pair("SpecConstantGlobalOffset %int_0 %int_0 %float_0", "Z"),
- std::make_pair("SpecConstantGlobalOffset %int_0 %int_0 %null", "Z"),
- std::make_pair("SpecConstantWorkDim %float_0", "Dim"),
- std::make_pair("SpecConstantWorkDim %null", "Dim"),
- std::make_pair("PushConstantGlobalOffset %float_0 %int_0", "Offset"),
- std::make_pair("PushConstantGlobalOffset %null %int_0", "Offset"),
- std::make_pair("PushConstantGlobalOffset %int_0 %float_0", "Size"),
- std::make_pair("PushConstantGlobalOffset %int_0 %null", "Size"),
- std::make_pair("PushConstantEnqueuedLocalSize %float_0 %int_0",
- "Offset"),
- std::make_pair("PushConstantEnqueuedLocalSize %null %int_0", "Offset"),
- std::make_pair("PushConstantEnqueuedLocalSize %int_0 %float_0", "Size"),
- std::make_pair("PushConstantEnqueuedLocalSize %int_0 %null", "Size"),
- std::make_pair("PushConstantGlobalSize %float_0 %int_0", "Offset"),
- std::make_pair("PushConstantGlobalSize %null %int_0", "Offset"),
- std::make_pair("PushConstantGlobalSize %int_0 %float_0", "Size"),
- std::make_pair("PushConstantGlobalSize %int_0 %null", "Size"),
- std::make_pair("PushConstantRegionOffset %float_0 %int_0", "Offset"),
- std::make_pair("PushConstantRegionOffset %null %int_0", "Offset"),
- std::make_pair("PushConstantRegionOffset %int_0 %float_0", "Size"),
- std::make_pair("PushConstantRegionOffset %int_0 %null", "Size"),
- std::make_pair("PushConstantNumWorkgroups %float_0 %int_0", "Offset"),
- std::make_pair("PushConstantNumWorkgroups %null %int_0", "Offset"),
- std::make_pair("PushConstantNumWorkgroups %int_0 %float_0", "Size"),
- std::make_pair("PushConstantNumWorkgroups %int_0 %null", "Size"),
- std::make_pair("PushConstantRegionGroupOffset %float_0 %int_0",
- "Offset"),
- std::make_pair("PushConstantRegionGroupOffset %null %int_0", "Offset"),
- std::make_pair("PushConstantRegionGroupOffset %int_0 %float_0", "Size"),
- std::make_pair("PushConstantRegionGroupOffset %int_0 %null", "Size"),
- std::make_pair("ConstantDataStorageBuffer %float_0 %int_0 %data",
- "DescriptorSet"),
- std::make_pair("ConstantDataStorageBuffer %null %int_0 %data",
- "DescriptorSet"),
- std::make_pair("ConstantDataStorageBuffer %int_0 %float_0 %data",
- "Binding"),
- std::make_pair("ConstantDataStorageBuffer %int_0 %null %data",
- "Binding"),
- std::make_pair("ConstantDataUniform %float_0 %int_0 %data",
- "DescriptorSet"),
- std::make_pair("ConstantDataUniform %null %int_0 %data",
- "DescriptorSet"),
- std::make_pair("ConstantDataUniform %int_0 %float_0 %data", "Binding"),
- std::make_pair("ConstantDataUniform %int_0 %null %data", "Binding"),
- std::make_pair("LiteralSampler %float_0 %int_0 %int_4",
- "DescriptorSet"),
- std::make_pair("LiteralSampler %null %int_0 %int_4", "DescriptorSet"),
- std::make_pair("LiteralSampler %int_0 %float_0 %int_4", "Binding"),
- std::make_pair("LiteralSampler %int_0 %null %int_4", "Binding"),
- std::make_pair("LiteralSampler %int_0 %int_0 %float_0", "Mask"),
- std::make_pair("LiteralSampler %int_0 %int_0 %null", "Mask"),
- std::make_pair(
- "PropertyRequiredWorkgroupSize %decl %float_0 %int_1 %int_4", "X"),
- std::make_pair(
- "PropertyRequiredWorkgroupSize %decl %null %int_1 %int_4", "X"),
- std::make_pair(
- "PropertyRequiredWorkgroupSize %decl %int_1 %float_0 %int_4", "Y"),
- std::make_pair(
- "PropertyRequiredWorkgroupSize %decl %int_1 %null %int_4", "Y"),
- std::make_pair(
- "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %float_0", "Z"),
- std::make_pair(
- "PropertyRequiredWorkgroupSize %decl %int_1 %int_1 %null", "Z")}));
- TEST_P(Uint32Constant, Invalid) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string name = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %data = OpString "1234"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_1 = OpConstant %int 1
- %int_4 = OpConstant %int 4
- %null = OpConstantNull %int
- %float = OpTypeFloat 32
- %float_0 = OpConstant %float 0
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- %inst = OpExtInst %void %ext )" +
- ext_inst;
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(name + " must be a 32-bit unsigned integer OpConstant"));
- }
- using StringOperand =
- spvtest::ValidateBase<std::pair<std::string, std::string>>;
- INSTANTIATE_TEST_SUITE_P(
- ValidateClspvReflectionStringOperands, StringOperand,
- ::testing::ValuesIn(std::vector<std::pair<std::string, std::string>>{
- std::make_pair("ConstantDataStorageBuffer %int_0 %int_0 %int_0",
- "Data"),
- std::make_pair("ConstantDataUniform %int_0 %int_0 %int_0", "Data")}));
- TEST_P(StringOperand, Invalid) {
- const std::string ext_inst = std::get<0>(GetParam());
- const std::string name = std::get<1>(GetParam());
- const std::string text = R"(
- OpCapability Shader
- OpExtension "SPV_KHR_non_semantic_info"
- %ext = OpExtInstImport "NonSemantic.ClspvReflection.1"
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %foo "foo"
- OpExecutionMode %foo LocalSize 1 1 1
- %foo_name = OpString "foo"
- %data = OpString "1234"
- %void = OpTypeVoid
- %int = OpTypeInt 32 0
- %int_0 = OpConstant %int 0
- %int_1 = OpConstant %int 1
- %int_4 = OpConstant %int 4
- %null = OpConstantNull %int
- %float = OpTypeFloat 32
- %float_0 = OpConstant %float 0
- %void_fn = OpTypeFunction %void
- %foo = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %decl = OpExtInst %void %ext Kernel %foo %foo_name
- %inst = OpExtInst %void %ext )" +
- ext_inst;
- CompileSuccessfully(text);
- ASSERT_EQ(SPV_ERROR_INVALID_ID, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(), HasSubstr(name + " must be an OpString"));
- }
- } // namespace
- } // namespace val
- } // namespace spvtools
|