| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982 |
- // Copyright (c) 2015-2016 The Khronos Group 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.
- // Validation tests for Logical Layout
- #include <sstream>
- #include <string>
- #include <tuple>
- #include <utility>
- #include <vector>
- #include "gmock/gmock.h"
- #include "source/assembly_grammar.h"
- #include "source/spirv_target_env.h"
- #include "spirv-tools/libspirv.h"
- #include "test/test_fixture.h"
- #include "test/unit_spirv.h"
- #include "test/val/val_fixtures.h"
- namespace spvtools {
- namespace val {
- namespace {
- using spvtest::ScopedContext;
- using testing::Combine;
- using testing::Eq;
- using testing::HasSubstr;
- using testing::Values;
- using testing::ValuesIn;
- // Parameter for validation test fixtures. The first std::string is a
- // capability name that will begin the assembly under test, the second the
- // remainder assembly, and the std::vector at the end determines whether the
- // test expects success or failure. See below for details and convenience
- // methods to access each one.
- //
- // The assembly to test is composed from a variable top line and a fixed
- // remainder. The top line will be an OpCapability instruction, while the
- // remainder will be some assembly text that succeeds or fails to assemble
- // depending on which capability was chosen. For instance, the following will
- // succeed:
- //
- // OpCapability Pipes ; implies Kernel
- // OpLifetimeStop %1 0 ; requires Kernel
- //
- // and the following will fail:
- //
- // OpCapability Kernel
- // %1 = OpTypeNamedBarrier ; requires NamedBarrier
- //
- // So how does the test parameter capture which capabilities should cause
- // success and which shouldn't? The answer is in the last element: it's a
- // std::vector of capabilities that make the remainder assembly succeed. So if
- // the first-line capability exists in that std::vector, success is expected;
- // otherwise, failure is expected in the tests.
- //
- // We will use testing::Combine() to vary the first line: when we combine
- // AllCapabilities() with a single remainder assembly, we generate enough test
- // cases to try the assembly with every possible capability that could be
- // declared. However, Combine() only produces tuples -- it cannot produce, say,
- // a struct. Therefore, this type must be a tuple.
- using CapTestParameter =
- std::tuple<std::string, std::pair<std::string, std::vector<std::string>>>;
- const std::string& Capability(const CapTestParameter& p) {
- return std::get<0>(p);
- }
- const std::string& Remainder(const CapTestParameter& p) {
- return std::get<1>(p).first;
- }
- const std::vector<std::string>& MustSucceed(const CapTestParameter& p) {
- return std::get<1>(p).second;
- }
- // Creates assembly to test from p.
- std::string MakeAssembly(const CapTestParameter& p) {
- std::ostringstream ss;
- const std::string& capability = Capability(p);
- if (!capability.empty()) {
- ss << "OpCapability " << capability << "\n";
- }
- ss << Remainder(p);
- return ss.str();
- }
- // Expected validation result for p.
- spv_result_t ExpectedResult(const CapTestParameter& p) {
- const auto& caps = MustSucceed(p);
- auto found = find(begin(caps), end(caps), Capability(p));
- return (found == end(caps)) ? SPV_ERROR_INVALID_CAPABILITY : SPV_SUCCESS;
- }
- // Assembles using v1.0, unless the parameter's capability requires v1.1.
- using ValidateCapability = spvtest::ValidateBase<CapTestParameter>;
- // Always assembles using v1.1.
- using ValidateCapabilityV11 = spvtest::ValidateBase<CapTestParameter>;
- // Always assembles using Vulkan 1.0.
- // TODO(dneto): Refactor all these tests to scale better across environments.
- using ValidateCapabilityVulkan10 = spvtest::ValidateBase<CapTestParameter>;
- // Always assembles using OpenGL 4.0.
- using ValidateCapabilityOpenGL40 = spvtest::ValidateBase<CapTestParameter>;
- // Always assembles using Vulkan 1.1.
- using ValidateCapabilityVulkan11 = spvtest::ValidateBase<CapTestParameter>;
- // Always assembles using Vulkan 1.2.
- using ValidateCapabilityVulkan12 = spvtest::ValidateBase<CapTestParameter>;
- TEST_F(ValidateCapability, Default) {
- const char str[] = R"(
- OpCapability Kernel
- OpCapability Linkage
- OpCapability Matrix
- OpMemoryModel Logical OpenCL
- %f32 = OpTypeFloat 32
- %vec3 = OpTypeVector %f32 3
- %mat33 = OpTypeMatrix %vec3 3
- )";
- CompileSuccessfully(str);
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- // clang-format off
- const std::vector<std::string>& AllCapabilities() {
- static const auto r = new std::vector<std::string>{
- "",
- "Matrix",
- "Shader",
- "Geometry",
- "Tessellation",
- "Addresses",
- "Linkage",
- "Kernel",
- "Vector16",
- "Float16Buffer",
- "Float16",
- "Float64",
- "Int64",
- "Int64Atomics",
- "ImageBasic",
- "ImageReadWrite",
- "ImageMipmap",
- "Pipes",
- "Groups",
- "DeviceEnqueue",
- "LiteralSampler",
- "AtomicStorage",
- "Int16",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "ImageRect",
- "SampledRect",
- "GenericPointer",
- "Int8",
- "InputAttachment",
- "SparseResidency",
- "MinLod",
- "Sampled1D",
- "Image1D",
- "SampledCubeArray",
- "SampledBuffer",
- "ImageBuffer",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "ImageQuery",
- "DerivativeControl",
- "InterpolationFunction",
- "TransformFeedback",
- "GeometryStreams",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "SubgroupDispatch",
- "NamedBarrier",
- "PipeStorage",
- "GroupNonUniform",
- "GroupNonUniformVote",
- "GroupNonUniformArithmetic",
- "GroupNonUniformBallot",
- "GroupNonUniformShuffle",
- "GroupNonUniformShuffleRelative",
- "GroupNonUniformClustered",
- "GroupNonUniformQuad",
- "DrawParameters",
- "StorageBuffer16BitAccess",
- "StorageUniformBufferBlock16",
- "UniformAndStorageBuffer16BitAccess",
- "StorageUniform16",
- "StoragePushConstant16",
- "StorageInputOutput16",
- "DeviceGroup",
- "MultiView",
- "VariablePointersStorageBuffer",
- "VariablePointers"};
- return *r;
- }
- const std::vector<std::string>& AllSpirV15Capabilities() {
- static const auto r = new std::vector<std::string>{
- "",
- "Matrix",
- "Shader",
- "Geometry",
- "Tessellation",
- "Addresses",
- "Linkage",
- "Kernel",
- "Vector16",
- "Float16Buffer",
- "Float16",
- "Float64",
- "Int64",
- "Int64Atomics",
- "ImageBasic",
- "ImageReadWrite",
- "ImageMipmap",
- "Pipes",
- "Groups",
- "DeviceEnqueue",
- "LiteralSampler",
- "AtomicStorage",
- "Int16",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "ImageRect",
- "SampledRect",
- "GenericPointer",
- "Int8",
- "InputAttachment",
- "SparseResidency",
- "MinLod",
- "Sampled1D",
- "Image1D",
- "SampledCubeArray",
- "SampledBuffer",
- "ImageBuffer",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "ImageQuery",
- "DerivativeControl",
- "InterpolationFunction",
- "TransformFeedback",
- "GeometryStreams",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "SubgroupDispatch",
- "NamedBarrier",
- "PipeStorage",
- "GroupNonUniform",
- "GroupNonUniformVote",
- "GroupNonUniformArithmetic",
- "GroupNonUniformBallot",
- "GroupNonUniformShuffle",
- "GroupNonUniformShuffleRelative",
- "GroupNonUniformClustered",
- "GroupNonUniformQuad",
- "DrawParameters",
- "StorageBuffer16BitAccess",
- "StorageUniformBufferBlock16",
- "UniformAndStorageBuffer16BitAccess",
- "StorageUniform16",
- "StoragePushConstant16",
- "StorageInputOutput16",
- "DeviceGroup",
- "MultiView",
- "VariablePointersStorageBuffer",
- "VariablePointers",
- "DenormPreserve",
- "DenormFlushToZero",
- "SignedZeroInfNanPreserve",
- "RoundingModeRTE",
- "RoundingModeRTZ",
- // Omitted due to extra validation requirements on memory model.
- //"VulkanMemoryModel",
- //"VulkanMemoryModelDeviceScope",
- "StorageBuffer8BitAccess",
- "UniformAndStorageBuffer8BitAccess",
- "StoragePushConstant8",
- "ShaderViewportIndex",
- "ShaderLayer",
- "PhysicalStorageBufferAddresses",
- "RuntimeDescriptorArray",
- "UniformTexelBufferArrayDynamicIndexing",
- "StorageTexelBufferArrayDynamicIndexing",
- "UniformBufferArrayNonUniformIndexing",
- "SampledImageArrayNonUniformIndexing",
- "StorageBufferArrayNonUniformIndexing",
- "StorageImageArrayNonUniformIndexing",
- "InputAttachmentArrayNonUniformIndexing",
- "UniformTexelBufferArrayNonUniformIndexing",
- "StorageTexelBufferArrayNonUniformIndexing"};
- return *r;
- }
- const std::vector<std::string>& AllSpirV10Capabilities() {
- static const auto r = new std::vector<std::string>{
- "",
- "Matrix",
- "Shader",
- "Geometry",
- "Tessellation",
- "Addresses",
- "Linkage",
- "Kernel",
- "Vector16",
- "Float16Buffer",
- "Float16",
- "Float64",
- "Int64",
- "Int64Atomics",
- "ImageBasic",
- "ImageReadWrite",
- "ImageMipmap",
- "Pipes",
- "Groups",
- "DeviceEnqueue",
- "LiteralSampler",
- "AtomicStorage",
- "Int16",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "ImageRect",
- "SampledRect",
- "GenericPointer",
- "Int8",
- "InputAttachment",
- "SparseResidency",
- "MinLod",
- "Sampled1D",
- "Image1D",
- "SampledCubeArray",
- "SampledBuffer",
- "ImageBuffer",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "ImageQuery",
- "DerivativeControl",
- "InterpolationFunction",
- "TransformFeedback",
- "GeometryStreams",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport"};
- return *r;
- }
- const std::vector<std::string>& AllVulkan10Capabilities() {
- static const auto r = new std::vector<std::string>{
- "",
- "Matrix",
- "Shader",
- "InputAttachment",
- "Sampled1D",
- "Image1D",
- "SampledBuffer",
- "ImageBuffer",
- "ImageQuery",
- "DerivativeControl",
- "Geometry",
- "Tessellation",
- "Float16",
- "Float64",
- "Int64",
- "Int64Atomics",
- "Int16",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "Int8",
- "SparseResidency",
- "MinLod",
- "SampledCubeArray",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "InterpolationFunction",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "TransformFeedback",
- "GeometryStreams"};
- return *r;
- }
- const std::vector<std::string>& AllVulkan11Capabilities() {
- static const auto r = new std::vector<std::string>{
- "",
- "Matrix",
- "Shader",
- "InputAttachment",
- "Sampled1D",
- "Image1D",
- "SampledBuffer",
- "ImageBuffer",
- "ImageQuery",
- "DerivativeControl",
- "Geometry",
- "Tessellation",
- "Float16",
- "Float64",
- "Int64",
- "Int64Atomics",
- "Int16",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "Int8",
- "SparseResidency",
- "MinLod",
- "SampledCubeArray",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "InterpolationFunction",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "GroupNonUniform",
- "GroupNonUniformVote",
- "GroupNonUniformArithmetic",
- "GroupNonUniformBallot",
- "GroupNonUniformShuffle",
- "GroupNonUniformShuffleRelative",
- "GroupNonUniformClustered",
- "GroupNonUniformQuad",
- "DrawParameters",
- "StorageBuffer16BitAccess",
- "StorageUniformBufferBlock16",
- "UniformAndStorageBuffer16BitAccess",
- "StorageUniform16",
- "StoragePushConstant16",
- "StorageInputOutput16",
- "DeviceGroup",
- "MultiView",
- "VariablePointersStorageBuffer",
- "VariablePointers",
- "TransformFeedback",
- "GeometryStreams"};
- return *r;
- }
- const std::vector<std::string>& AllVulkan12Capabilities() {
- static const auto r = new std::vector<std::string>{
- "",
- "Matrix",
- "Shader",
- "InputAttachment",
- "Sampled1D",
- "Image1D",
- "SampledBuffer",
- "ImageBuffer",
- "ImageQuery",
- "DerivativeControl",
- "Geometry",
- "Tessellation",
- "Float16",
- "Float64",
- "Int64",
- "Int64Atomics",
- "Int16",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "Int8",
- "SparseResidency",
- "MinLod",
- "SampledCubeArray",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "InterpolationFunction",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "GroupNonUniform",
- "GroupNonUniformVote",
- "GroupNonUniformArithmetic",
- "GroupNonUniformBallot",
- "GroupNonUniformShuffle",
- "GroupNonUniformShuffleRelative",
- "GroupNonUniformClustered",
- "GroupNonUniformQuad",
- "DrawParameters",
- "StorageBuffer16BitAccess",
- "StorageUniformBufferBlock16",
- "UniformAndStorageBuffer16BitAccess",
- "StorageUniform16",
- "StoragePushConstant16",
- "StorageInputOutput16",
- "DeviceGroup",
- "MultiView",
- "VariablePointersStorageBuffer",
- "VariablePointers",
- "TransformFeedback",
- "GeometryStreams",
- "DenormPreserve",
- "DenormFlushToZero",
- "SignedZeroInfNanPreserve",
- "RoundingModeRTE",
- "RoundingModeRTZ",
- "VulkanMemoryModel",
- "VulkanMemoryModelDeviceScope",
- "StorageBuffer8BitAccess",
- "UniformAndStorageBuffer8BitAccess",
- "StoragePushConstant8",
- "ShaderViewportIndex",
- "ShaderLayer",
- "PhysicalStorageBufferAddresses",
- "RuntimeDescriptorArray",
- "UniformTexelBufferArrayDynamicIndexing",
- "StorageTexelBufferArrayDynamicIndexing",
- "UniformBufferArrayNonUniformIndexing",
- "SampledImageArrayNonUniformIndexing",
- "StorageBufferArrayNonUniformIndexing",
- "StorageImageArrayNonUniformIndexing",
- "InputAttachmentArrayNonUniformIndexing",
- "UniformTexelBufferArrayNonUniformIndexing",
- "StorageTexelBufferArrayNonUniformIndexing"};
- return *r;
- }
- const std::vector<std::string>& MatrixDependencies() {
- static const auto r = new std::vector<std::string>{
- "Matrix",
- "Shader",
- "Geometry",
- "Tessellation",
- "AtomicStorage",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "ImageRect",
- "SampledRect",
- "InputAttachment",
- "SparseResidency",
- "MinLod",
- "SampledCubeArray",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "ImageQuery",
- "DerivativeControl",
- "InterpolationFunction",
- "TransformFeedback",
- "GeometryStreams",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "DrawParameters",
- "MultiView",
- "VariablePointersStorageBuffer",
- "VariablePointers"};
- return *r;
- }
- const std::vector<std::string>& ShaderDependencies() {
- static const auto r = new std::vector<std::string>{
- "Shader",
- "Geometry",
- "Tessellation",
- "AtomicStorage",
- "TessellationPointSize",
- "GeometryPointSize",
- "ImageGatherExtended",
- "StorageImageMultisample",
- "UniformBufferArrayDynamicIndexing",
- "SampledImageArrayDynamicIndexing",
- "StorageBufferArrayDynamicIndexing",
- "StorageImageArrayDynamicIndexing",
- "ClipDistance",
- "CullDistance",
- "ImageCubeArray",
- "SampleRateShading",
- "ImageRect",
- "SampledRect",
- "InputAttachment",
- "SparseResidency",
- "MinLod",
- "SampledCubeArray",
- "ImageMSArray",
- "StorageImageExtendedFormats",
- "ImageQuery",
- "DerivativeControl",
- "InterpolationFunction",
- "TransformFeedback",
- "GeometryStreams",
- "StorageImageReadWithoutFormat",
- "StorageImageWriteWithoutFormat",
- "MultiViewport",
- "DrawParameters",
- "MultiView",
- "VariablePointersStorageBuffer",
- "VariablePointers"};
- return *r;
- }
- const std::vector<std::string>& TessellationDependencies() {
- static const auto r = new std::vector<std::string>{
- "Tessellation",
- "TessellationPointSize"};
- return *r;
- }
- const std::vector<std::string>& GeometryDependencies() {
- static const auto r = new std::vector<std::string>{
- "Geometry",
- "GeometryPointSize",
- "GeometryStreams",
- "MultiViewport"};
- return *r;
- }
- const std::vector<std::string>& GeometryTessellationDependencies() {
- static const auto r = new std::vector<std::string>{
- "Tessellation",
- "TessellationPointSize",
- "Geometry",
- "GeometryPointSize",
- "GeometryStreams",
- "MultiViewport"};
- return *r;
- }
- // Returns the names of capabilities that directly depend on Kernel,
- // plus itself.
- const std::vector<std::string>& KernelDependencies() {
- static const auto r = new std::vector<std::string>{
- "Kernel",
- "Vector16",
- "Float16Buffer",
- "ImageBasic",
- "ImageReadWrite",
- "ImageMipmap",
- "Pipes",
- "DeviceEnqueue",
- "LiteralSampler",
- "SubgroupDispatch",
- "NamedBarrier",
- "PipeStorage"};
- return *r;
- }
- const std::vector<std::string>& KernelAndGroupNonUniformDependencies() {
- static const auto r = new std::vector<std::string>{
- "Kernel",
- "Vector16",
- "Float16Buffer",
- "ImageBasic",
- "ImageReadWrite",
- "ImageMipmap",
- "Pipes",
- "DeviceEnqueue",
- "LiteralSampler",
- "SubgroupDispatch",
- "NamedBarrier",
- "PipeStorage",
- "GroupNonUniform",
- "GroupNonUniformVote",
- "GroupNonUniformArithmetic",
- "GroupNonUniformBallot",
- "GroupNonUniformShuffle",
- "GroupNonUniformShuffleRelative",
- "GroupNonUniformClustered",
- "GroupNonUniformQuad"};
- return *r;
- }
- const std::vector<std::string>& AddressesDependencies() {
- static const auto r = new std::vector<std::string>{
- "Addresses",
- "GenericPointer"};
- return *r;
- }
- const std::vector<std::string>& Sampled1DDependencies() {
- static const auto r = new std::vector<std::string>{
- "Sampled1D",
- "Image1D"};
- return *r;
- }
- const std::vector<std::string>& SampledRectDependencies() {
- static const auto r = new std::vector<std::string>{
- "SampledRect",
- "ImageRect"};
- return *r;
- }
- const std::vector<std::string>& SampledBufferDependencies() {
- static const auto r = new std::vector<std::string>{
- "SampledBuffer",
- "ImageBuffer"};
- return *r;
- }
- const char kOpenCLMemoryModel[] = \
- " OpCapability Kernel"
- " OpMemoryModel Logical OpenCL ";
- const char kGLSL450MemoryModel[] = \
- " OpCapability Shader"
- " OpMemoryModel Logical GLSL450 ";
- const char kVoidFVoid[] = \
- " %void = OpTypeVoid"
- " %void_f = OpTypeFunction %void"
- " %func = OpFunction %void None %void_f"
- " %label = OpLabel"
- " OpReturn"
- " OpFunctionEnd ";
- const char kVoidFVoid2[] = \
- " %void_f = OpTypeFunction %voidt"
- " %func = OpFunction %voidt None %void_f"
- " %label = OpLabel"
- " OpReturn"
- " OpFunctionEnd ";
- INSTANTIATE_TEST_SUITE_P(ExecutionModel, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint TessellationControl %func \"shader\"" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint TessellationEvaluation %func \"shader\"" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Geometry %func \"shader\"" +
- " OpExecutionMode %func InputPoints" +
- " OpExecutionMode %func OutputPoints" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Fragment %func \"shader\"" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint GLCompute %func \"shader\"" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Kernel %func \"shader\"" +
- std::string(kVoidFVoid), KernelDependencies())
- )));
- INSTANTIATE_TEST_SUITE_P(AddressingAndMemoryModel, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(" OpCapability Shader"
- " OpMemoryModel Logical Simple"
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), AllCapabilities()),
- std::make_pair(" OpCapability Shader"
- " OpMemoryModel Logical GLSL450"
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), AllCapabilities()),
- std::make_pair(" OpCapability Kernel"
- " OpMemoryModel Logical OpenCL"
- " OpEntryPoint Kernel %func \"compute\"" +
- std::string(kVoidFVoid), AllCapabilities()),
- std::make_pair(" OpCapability Shader"
- " OpMemoryModel Physical32 Simple"
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), AddressesDependencies()),
- std::make_pair(" OpCapability Shader"
- " OpMemoryModel Physical32 GLSL450"
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), AddressesDependencies()),
- std::make_pair(" OpCapability Kernel"
- " OpMemoryModel Physical32 OpenCL"
- " OpEntryPoint Kernel %func \"compute\"" +
- std::string(kVoidFVoid), AddressesDependencies()),
- std::make_pair(" OpCapability Shader"
- " OpMemoryModel Physical64 Simple"
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), AddressesDependencies()),
- std::make_pair(" OpCapability Shader"
- " OpMemoryModel Physical64 GLSL450"
- " OpEntryPoint Vertex %func \"shader\"" +
- std::string(kVoidFVoid), AddressesDependencies()),
- std::make_pair(" OpCapability Kernel"
- " OpMemoryModel Physical64 OpenCL"
- " OpEntryPoint Kernel %func \"compute\"" +
- std::string(kVoidFVoid), AddressesDependencies())
- )));
- INSTANTIATE_TEST_SUITE_P(ExecutionMode, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func Invocations 42" +
- " OpExecutionMode %func InputPoints" +
- " OpExecutionMode %func OutputPoints" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func SpacingEqual" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func SpacingFractionalEven" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func SpacingFractionalOdd" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func VertexOrderCw" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func VertexOrderCcw" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func PixelCenterInteger" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func OriginLowerLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func EarlyFragmentTests" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func PointMode" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" "
- "OpExecutionMode %func Xfb" +
- std::string(kVoidFVoid), std::vector<std::string>{"TransformFeedback"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func DepthReplacing" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func DepthGreater" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func DepthLess" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Fragment %func \"shader\" "
- "OpExecutionMode %func DepthUnchanged" +
- " OpExecutionMode %func OriginUpperLeft" +
- std::string(kVoidFVoid), ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"shader\" "
- "OpExecutionMode %func LocalSize 42 42 42" +
- std::string(kVoidFVoid), AllCapabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Kernel %func \"shader\" "
- "OpExecutionMode %func LocalSizeHint 42 42 42" +
- std::string(kVoidFVoid), KernelDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func InputPoints" +
- " OpExecutionMode %func OutputPoints" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func InputLines" +
- " OpExecutionMode %func OutputLineStrip" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func InputLinesAdjacency" +
- " OpExecutionMode %func OutputLineStrip" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func Triangles" +
- " OpExecutionMode %func OutputTriangleStrip" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func Triangles" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func InputTrianglesAdjacency" +
- " OpExecutionMode %func OutputTriangleStrip" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func Quads" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func Isolines" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func OutputVertices 42" +
- " OpExecutionMode %func OutputPoints" +
- " OpExecutionMode %func InputPoints" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint TessellationControl %func \"shader\" "
- "OpExecutionMode %func OutputVertices 42" +
- std::string(kVoidFVoid), TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func OutputPoints" +
- " OpExecutionMode %func InputPoints" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func OutputLineStrip" +
- " OpExecutionMode %func InputLines" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Geometry %func \"shader\" "
- "OpExecutionMode %func OutputTriangleStrip" +
- " OpExecutionMode %func Triangles" +
- std::string(kVoidFVoid), GeometryDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Kernel %func \"shader\" "
- "OpExecutionMode %func VecTypeHint 2" +
- std::string(kVoidFVoid), KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Kernel %func \"shader\" "
- "OpExecutionMode %func ContractionOff" +
- std::string(kVoidFVoid), KernelDependencies()))));
- // clang-format on
- INSTANTIATE_TEST_SUITE_P(
- ExecutionModeV11, ValidateCapabilityV11,
- Combine(ValuesIn(AllCapabilities()),
- Values(std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"shader\" "
- "OpExecutionMode %func SubgroupSize 1" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"SubgroupDispatch"}),
- std::make_pair(
- std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"shader\" "
- "OpExecutionMode %func SubgroupsPerWorkgroup 65535" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"SubgroupDispatch"}))));
- // clang-format off
- INSTANTIATE_TEST_SUITE_P(StorageClass, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer UniformConstant %intt\n"
- " %var = OpVariable %ptrt UniformConstant\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Kernel %func \"compute\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer Input %intt"
- " %var = OpVariable %ptrt Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer Uniform %intt\n"
- " %var = OpVariable %ptrt Uniform\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer Output %intt\n"
- " %var = OpVariable %ptrt Output\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer Workgroup %intt\n"
- " %var = OpVariable %ptrt Workgroup\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer CrossWorkgroup %intt\n"
- " %var = OpVariable %ptrt CrossWorkgroup\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Kernel %func \"compute\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer Private %intt\n"
- " %var = OpVariable %ptrt Private\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- " OpEntryPoint Kernel %func \"compute\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer PushConstant %intt\n"
- " %var = OpVariable %ptrt PushConstant\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer AtomicCounter %intt\n"
- " %var = OpVariable %ptrt AtomicCounter\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"AtomicStorage"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\"" +
- " %intt = OpTypeInt 32 0\n"
- " %ptrt = OpTypePointer Image %intt\n"
- " %var = OpVariable %ptrt Image\n" + std::string(kVoidFVoid),
- AllCapabilities())
- )));
- INSTANTIATE_TEST_SUITE_P(Dim, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt 1D 0 0 0 0 Unknown" + std::string(kVoidFVoid2),
- Sampled1DDependencies()),
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt 2D 0 0 0 0 Unknown" + std::string(kVoidFVoid2),
- AllCapabilities()),
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt 3D 0 0 0 0 Unknown" + std::string(kVoidFVoid2),
- AllCapabilities()),
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt Cube 0 0 0 0 Unknown" + std::string(kVoidFVoid2),
- ShaderDependencies()),
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt Rect 0 0 0 0 Unknown" + std::string(kVoidFVoid2),
- SampledRectDependencies()),
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt Buffer 0 0 0 0 Unknown" + std::string(kVoidFVoid2),
- SampledBufferDependencies()),
- std::make_pair(" OpCapability ImageBasic" +
- std::string(kOpenCLMemoryModel) +
- std::string(" OpEntryPoint Kernel %func \"compute\"") +
- " %voidt = OpTypeVoid"
- " %imgt = OpTypeImage %voidt SubpassData 0 0 0 2 Unknown" + std::string(kVoidFVoid2),
- std::vector<std::string>{"InputAttachment"})
- )));
- // NOTE: All Sampler Address Modes require kernel capabilities but the
- // OpConstantSampler requires LiteralSampler which depends on Kernel
- INSTANTIATE_TEST_SUITE_P(SamplerAddressingMode, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\""
- " %samplert = OpTypeSampler"
- " %sampler = OpConstantSampler %samplert None 1 Nearest" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"LiteralSampler"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\""
- " %samplert = OpTypeSampler"
- " %sampler = OpConstantSampler %samplert ClampToEdge 1 Nearest" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"LiteralSampler"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\""
- " %samplert = OpTypeSampler"
- " %sampler = OpConstantSampler %samplert Clamp 1 Nearest" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"LiteralSampler"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\""
- " %samplert = OpTypeSampler"
- " %sampler = OpConstantSampler %samplert Repeat 1 Nearest" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"LiteralSampler"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- " OpEntryPoint Vertex %func \"shader\""
- " %samplert = OpTypeSampler"
- " %sampler = OpConstantSampler %samplert RepeatMirrored 1 Nearest" +
- std::string(kVoidFVoid),
- std::vector<std::string>{"LiteralSampler"})
- )));
- // TODO(umar): Sampler Filter Mode
- // TODO(umar): Image Format
- // TODO(umar): Image Channel Order
- // TODO(umar): Image Channel Data Type
- // TODO(umar): Image Operands
- // TODO(umar): FP Fast Math Mode
- // TODO(umar): FP Rounding Mode
- // TODO(umar): Linkage Type
- // TODO(umar): Access Qualifier
- // TODO(umar): Function Parameter Attribute
- INSTANTIATE_TEST_SUITE_P(Decoration, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var RelaxedPrecision\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Private %intt\n"
- "%var = OpVariable %ptr Private\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- // Block applies to struct type.
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %block Block\n"
- "%intt = OpTypeInt 32 0\n"
- "%block = OpTypeStruct %intt\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- // BufferBlock applies to struct type.
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %block BufferBlock\n"
- "%intt = OpTypeInt 32 0\n"
- "%block = OpTypeStruct %intt\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpMemberDecorate %structt 0 RowMajor\n"
- "%floatt = OpTypeFloat 32\n"
- "%float2 = OpTypeVector %floatt 2\n"
- "%mat2x2 = OpTypeMatrix %float2 2\n"
- "%structt = OpTypeStruct %mat2x2\n" + std::string(kVoidFVoid),
- MatrixDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpMemberDecorate %structt 0 ColMajor\n"
- "%floatt = OpTypeFloat 32\n"
- "%float2 = OpTypeVector %floatt 2\n"
- "%mat2x2 = OpTypeMatrix %float2 2\n"
- "%structt = OpTypeStruct %mat2x2\n" + std::string(kVoidFVoid),
- MatrixDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %array ArrayStride 4\n"
- "%intt = OpTypeInt 32 0\n"
- "%array = OpTypeRuntimeArray %intt\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpMemberDecorate %structt 0 MatrixStride 8\n"
- "%floatt = OpTypeFloat 32\n"
- "%float2 = OpTypeVector %floatt 2\n"
- "%mat2x2 = OpTypeMatrix %float2 2\n"
- "%structt = OpTypeStruct %mat2x2\n" + std::string(kVoidFVoid),
- MatrixDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %struct GLSLShared\n"
- "%struct = OpTypeStruct\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %struct GLSLPacked\n"
- "%struct = OpTypeStruct\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %struct CPacked\n"
- "%struct = OpTypeStruct\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var NoPerspective\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Flat\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Patch\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Centroid\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Sample\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"SampleRateShading"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Invariant\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Restrict\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Aliased\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Volatile\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %var Constant\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Coherent\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- // NonWritable must target something valid, such as a storage image.
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var NonWritable "
- "%float = OpTypeFloat 32 "
- "%imstor = OpTypeImage %float 2D 0 0 0 2 Unknown "
- "%ptr = OpTypePointer UniformConstant %imstor "
- "%var = OpVariable %ptr UniformConstant "
- + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var NonReadable "
- "%float = OpTypeFloat 32 "
- "%imstor = OpTypeImage %float 2D 0 0 0 2 Unknown "
- "%ptr = OpTypePointer UniformConstant %imstor "
- "%var = OpVariable %ptr UniformConstant "
- + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- // Uniform must target a non-void value.
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %int0 Uniform\n"
- "%intt = OpTypeInt 32 0\n" +
- "%int0 = OpConstantNull %intt"
- + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %intt SaturatedConversion\n"
- "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Stream 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Output %intt\n"
- "%var = OpVariable %ptr Output\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"GeometryStreams"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpMemberDecorate %struct 0 Location 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%struct = OpTypeStruct %intt\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Component 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Index 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var Binding 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Uniform %intt\n"
- "%var = OpVariable %ptr Uniform\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var DescriptorSet 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Uniform %intt\n"
- "%var = OpVariable %ptr Uniform\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpMemberDecorate %structt 0 Offset 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%structt = OpTypeStruct %intt\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var XfbBuffer 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Uniform %intt\n"
- "%var = OpVariable %ptr Uniform\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"TransformFeedback"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var XfbStride 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Uniform %intt\n"
- "%var = OpVariable %ptr Uniform\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"TransformFeedback"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %intt FuncParamAttr Zext\n"
- "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %intt FPFastMathMode Fast\n"
- "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %intt LinkageAttributes \"other\" Import\n"
- "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"Linkage"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %intt NoContraction\n"
- "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %var InputAttachmentIndex 0\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer UniformConstant %intt\n"
- "%var = OpVariable %ptr UniformConstant\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"InputAttachment"}),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %intt Alignment 4\n"
- "%intt = OpTypeInt 32 0\n" + std::string(kVoidFVoid),
- KernelDependencies())
- )));
- // clang-format on
- INSTANTIATE_TEST_SUITE_P(
- DecorationSpecId, ValidateCapability,
- Combine(
- ValuesIn(AllSpirV10Capabilities()),
- Values(std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %1 SpecId 1\n"
- "%intt = OpTypeInt 32 0\n"
- "%1 = OpSpecConstant %intt 0\n" +
- std::string(kVoidFVoid),
- ShaderDependencies()))));
- INSTANTIATE_TEST_SUITE_P(
- DecorationV11, ValidateCapabilityV11,
- Combine(ValuesIn(AllCapabilities()),
- Values(std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %p MaxByteOffset 0 "
- "%i32 = OpTypeInt 32 0 "
- "%pi32 = OpTypePointer Workgroup %i32 "
- "%p = OpVariable %pi32 Workgroup " +
- std::string(kVoidFVoid),
- AddressesDependencies()),
- // Trying to test OpDecorate here, but if this fails due to
- // incorrect OpMemoryModel validation, that must also be
- // fixed.
- std::make_pair(
- std::string("OpMemoryModel Logical OpenCL "
- "OpEntryPoint Kernel %func \"compute\" \n"
- "OpDecorate %1 SpecId 1 "
- "%intt = OpTypeInt 32 0 "
- "%1 = OpSpecConstant %intt 0") +
- std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(
- std::string("OpMemoryModel Logical Simple "
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpDecorate %1 SpecId 1 "
- "%intt = OpTypeInt 32 0 "
- "%1 = OpSpecConstant %intt 0") +
- std::string(kVoidFVoid),
- ShaderDependencies()))));
- // clang-format off
- INSTANTIATE_TEST_SUITE_P(BuiltIn, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn Position\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- // Just mentioning PointSize, ClipDistance, or CullDistance as a BuiltIn does
- // not trigger the requirement for the associated capability.
- // See https://github.com/KhronosGroup/SPIRV-Tools/issues/365
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn PointSize\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn ClipDistance\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn CullDistance\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn VertexId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn InstanceId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn PrimitiveId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- GeometryTessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn InvocationId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- GeometryTessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn Layer\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- GeometryDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn ViewportIndex\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"MultiViewport"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn TessLevelOuter\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn TessLevelInner\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn TessCoord\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn PatchVertices\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- TessellationDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn FragCoord\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn PointCoord\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn FrontFacing\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn SampleId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"SampleRateShading"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn SamplePosition\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- std::vector<std::string>{"SampleRateShading"}),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn SampleMask\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn FragDepth\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn HelperInvocation\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn VertexIndex\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn InstanceIndex\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn NumWorkgroups\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn WorkgroupId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn LocalInvocationId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn GlobalInvocationId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn LocalInvocationIndex\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- AllCapabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn WorkDim\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn GlobalSize\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn EnqueuedWorkgroupSize\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn GlobalOffset\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn GlobalLinearId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn SubgroupSize\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelAndGroupNonUniformDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn SubgroupMaxSize\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn NumSubgroups\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelAndGroupNonUniformDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn NumEnqueuedSubgroups\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn SubgroupId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelAndGroupNonUniformDependencies()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n" +
- "OpDecorate %var BuiltIn SubgroupLocalInvocationId\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- KernelAndGroupNonUniformDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn VertexIndex\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies()),
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "OpDecorate %var BuiltIn InstanceIndex\n"
- "%intt = OpTypeInt 32 0\n"
- "%ptr = OpTypePointer Input %intt\n"
- "%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
- ShaderDependencies())
- )));
- // Ensure that mere mention of PointSize, ClipDistance, or CullDistance as
- // BuiltIns does not trigger the requirement for the associated
- // capability.
- // See https://github.com/KhronosGroup/SPIRV-Tools/issues/365
- INSTANTIATE_TEST_SUITE_P(BuiltIn, ValidateCapabilityVulkan10,
- Combine(
- // All capabilities to try.
- ValuesIn(AllSpirV10Capabilities()),
- Values(
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn PointSize\n"
- "%float = OpTypeFloat 32\n"
- "%ptr_output_float = OpTypePointer Output %float\n"
- "%var = OpVariable %ptr_output_float Output\n" + std::string(kVoidFVoid),
- // Capabilities which should succeed.
- AllVulkan10Capabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpMemberDecorate %block 0 BuiltIn ClipDistance\n"
- "%f32 = OpTypeFloat 32\n"
- "%intt = OpTypeInt 32 0\n"
- "%intt_4 = OpConstant %intt 4\n"
- "%f32arr4 = OpTypeArray %f32 %intt_4\n"
- "%block = OpTypeStruct %f32arr4\n" + std::string(kVoidFVoid),
- AllVulkan10Capabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" \n"
- "OpMemberDecorate %block 0 BuiltIn CullDistance\n"
- "%f32 = OpTypeFloat 32\n"
- "%intt = OpTypeInt 32 0\n"
- "%intt_4 = OpConstant %intt 4\n"
- "%f32arr4 = OpTypeArray %f32 %intt_4\n"
- "%block = OpTypeStruct %f32arr4\n" + std::string(kVoidFVoid),
- AllVulkan10Capabilities())
- )));
- INSTANTIATE_TEST_SUITE_P(BuiltIn, ValidateCapabilityOpenGL40,
- Combine(
- // OpenGL 4.0 is based on SPIR-V 1.0
- ValuesIn(AllSpirV10Capabilities()),
- Values(
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn PointSize\n"
- "%float = OpTypeFloat 32\n"
- "%ptr_output_float = OpTypePointer Output %float\n"
- "%var = OpVariable %ptr_output_float Output\n" + std::string(kVoidFVoid),
- AllSpirV10Capabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn ClipDistance\n"
- "%float = OpTypeFloat 32\n"
- "%int = OpTypeInt 32 0\n"
- "%int_1 = OpConstant %int 1\n"
- "%array = OpTypeArray %float %int_1\n"
- "%ptr = OpTypePointer Output %array\n"
- "%var = OpVariable %ptr Output\n" + std::string(kVoidFVoid),
- AllSpirV10Capabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn CullDistance\n"
- "%float = OpTypeFloat 32\n"
- "%int = OpTypeInt 32 0\n"
- "%int_1 = OpConstant %int 1\n"
- "%array = OpTypeArray %float %int_1\n"
- "%ptr = OpTypePointer Output %array\n"
- "%var = OpVariable %ptr Output\n" + std::string(kVoidFVoid),
- AllSpirV10Capabilities())
- )));
- INSTANTIATE_TEST_SUITE_P(Capabilities, ValidateCapabilityVulkan11,
- Combine(
- // All capabilities to try.
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn PointSize\n"
- "%float = OpTypeFloat 32\n"
- "%ptr_output_float = OpTypePointer Output %float\n"
- "%var = OpVariable %ptr_output_float Output\n" + std::string(kVoidFVoid),
- AllVulkan11Capabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn CullDistance\n"
- "%float = OpTypeFloat 32\n"
- "%int = OpTypeInt 32 0\n"
- "%int_1 = OpConstant %int 1\n"
- "%array = OpTypeArray %float %int_1\n"
- "%ptr = OpTypePointer Output %array\n"
- "%var = OpVariable %ptr Output\n" + std::string(kVoidFVoid),
- AllVulkan11Capabilities())
- )));
- INSTANTIATE_TEST_SUITE_P(Capabilities, ValidateCapabilityVulkan12,
- Combine(
- // All capabilities to try.
- ValuesIn(AllSpirV15Capabilities()),
- Values(
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn PointSize\n"
- "%float = OpTypeFloat 32\n"
- "%ptr_output_float = OpTypePointer Output %float\n"
- "%var = OpVariable %ptr_output_float Output\n" + std::string(kVoidFVoid),
- AllVulkan12Capabilities()),
- std::make_pair(std::string(kGLSL450MemoryModel) +
- "OpEntryPoint Vertex %func \"shader\" %var\n" +
- "OpDecorate %var BuiltIn CullDistance\n"
- "%float = OpTypeFloat 32\n"
- "%int = OpTypeInt 32 0\n"
- "%int_1 = OpConstant %int 1\n"
- "%array = OpTypeArray %float %int_1\n"
- "%ptr = OpTypePointer Output %array\n"
- "%var = OpVariable %ptr Output\n" + std::string(kVoidFVoid),
- AllVulkan12Capabilities())
- )));
- // TODO(umar): Selection Control
- // TODO(umar): Loop Control
- // TODO(umar): Function Control
- // TODO(umar): Memory Semantics
- // TODO(umar): Memory Access
- // TODO(umar): Scope
- // TODO(umar): Group Operation
- // TODO(umar): Kernel Enqueue Flags
- // TODO(umar): Kernel Profiling Flags
- INSTANTIATE_TEST_SUITE_P(MatrixOp, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(
- std::make_pair(std::string(kOpenCLMemoryModel) +
- "OpEntryPoint Kernel %func \"compute\" \n" +
- "%f32 = OpTypeFloat 32\n"
- "%vec3 = OpTypeVector %f32 3\n"
- "%mat33 = OpTypeMatrix %vec3 3\n" + std::string(kVoidFVoid),
- MatrixDependencies()))));
- // clang-format on
- #if 0
- // TODO([email protected]) The following test is not valid as it generates
- // invalid combinations of images, instructions and image operands.
- //
- // Creates assembly containing an OpImageFetch instruction using operands for
- // the image-operands part. The assembly defines constants %fzero and %izero
- // that can be used for operands where IDs are required. The assembly is valid,
- // apart from not declaring any capabilities required by the operands.
- string ImageOperandsTemplate(const std::string& operands) {
- ostringstream ss;
- // clang-format off
- ss << R"(
- OpCapability Kernel
- OpCapability Linkage
- OpMemoryModel Logical OpenCL
- %i32 = OpTypeInt 32 0
- %f32 = OpTypeFloat 32
- %v4i32 = OpTypeVector %i32 4
- %timg = OpTypeImage %i32 2D 0 0 0 0 Unknown
- %pimg = OpTypePointer UniformConstant %timg
- %tfun = OpTypeFunction %i32
- %vimg = OpVariable %pimg UniformConstant
- %izero = OpConstant %i32 0
- %fzero = OpConstant %f32 0.
- %main = OpFunction %i32 None %tfun
- %lbl = OpLabel
- %img = OpLoad %timg %vimg
- %r1 = OpImageFetch %v4i32 %img %izero )" << operands << R"(
- OpReturnValue %izero
- OpFunctionEnd
- )";
- // clang-format on
- return ss.str();
- }
- INSTANTIATE_TEST_SUITE_P(
- TwoImageOperandsMask, ValidateCapability,
- Combine(
- ValuesIn(AllCapabilities()),
- Values(std::make_pair(ImageOperandsTemplate("Bias|Lod %fzero %fzero"),
- ShaderDependencies()),
- std::make_pair(ImageOperandsTemplate("Lod|Offset %fzero %izero"),
- std::vector<std::string>{"ImageGatherExtended"}),
- std::make_pair(ImageOperandsTemplate("Sample|MinLod %izero %fzero"),
- std::vector<std::string>{"MinLod"}),
- std::make_pair(ImageOperandsTemplate("Lod|Sample %fzero %izero"),
- AllCapabilities()))), );
- #endif
- // TODO(umar): Instruction capability checks
- spv_result_t spvCoreOperandTableNameLookup(spv_target_env env,
- const spv_operand_table table,
- const spv_operand_type_t type,
- const char* name,
- const size_t nameLength) {
- if (!table) return SPV_ERROR_INVALID_TABLE;
- if (!name) return SPV_ERROR_INVALID_POINTER;
- for (uint64_t typeIndex = 0; typeIndex < table->count; ++typeIndex) {
- const auto& group = table->types[typeIndex];
- if (type != group.type) continue;
- for (uint64_t index = 0; index < group.count; ++index) {
- const auto& entry = group.entries[index];
- // Check for min version only.
- if (spvVersionForTargetEnv(env) >= entry.minVersion &&
- nameLength == strlen(entry.name) &&
- !strncmp(entry.name, name, nameLength)) {
- return SPV_SUCCESS;
- }
- }
- }
- return SPV_ERROR_INVALID_LOOKUP;
- }
- // True if capability exists in core spec of env.
- bool Exists(const std::string& capability, spv_target_env env) {
- ScopedContext sc(env);
- return SPV_SUCCESS ==
- spvCoreOperandTableNameLookup(env, sc.context->operand_table,
- SPV_OPERAND_TYPE_CAPABILITY,
- capability.c_str(), capability.size());
- }
- TEST_P(ValidateCapability, Capability) {
- const std::string capability = Capability(GetParam());
- spv_target_env env = SPV_ENV_UNIVERSAL_1_0;
- if (!capability.empty()) {
- if (Exists(capability, SPV_ENV_UNIVERSAL_1_0))
- env = SPV_ENV_UNIVERSAL_1_0;
- else if (Exists(capability, SPV_ENV_UNIVERSAL_1_1))
- env = SPV_ENV_UNIVERSAL_1_1;
- else if (Exists(capability, SPV_ENV_UNIVERSAL_1_2))
- env = SPV_ENV_UNIVERSAL_1_2;
- else
- env = SPV_ENV_UNIVERSAL_1_3;
- }
- const std::string test_code = MakeAssembly(GetParam());
- CompileSuccessfully(test_code, env);
- ASSERT_EQ(ExpectedResult(GetParam()), ValidateInstructions(env))
- << "target env: " << spvTargetEnvDescription(env) << "\ntest code:\n"
- << test_code;
- }
- TEST_P(ValidateCapabilityV11, Capability) {
- const std::string capability = Capability(GetParam());
- if (Exists(capability, SPV_ENV_UNIVERSAL_1_1)) {
- const std::string test_code = MakeAssembly(GetParam());
- CompileSuccessfully(test_code, SPV_ENV_UNIVERSAL_1_1);
- ASSERT_EQ(ExpectedResult(GetParam()),
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_1))
- << test_code;
- }
- }
- TEST_P(ValidateCapabilityVulkan10, Capability) {
- const std::string capability = Capability(GetParam());
- if (Exists(capability, SPV_ENV_VULKAN_1_0)) {
- const std::string test_code = MakeAssembly(GetParam());
- CompileSuccessfully(test_code, SPV_ENV_VULKAN_1_0);
- ASSERT_EQ(ExpectedResult(GetParam()),
- ValidateInstructions(SPV_ENV_VULKAN_1_0))
- << test_code;
- }
- }
- TEST_P(ValidateCapabilityVulkan11, Capability) {
- const std::string capability = Capability(GetParam());
- if (Exists(capability, SPV_ENV_VULKAN_1_1)) {
- const std::string test_code = MakeAssembly(GetParam());
- CompileSuccessfully(test_code, SPV_ENV_VULKAN_1_1);
- ASSERT_EQ(ExpectedResult(GetParam()),
- ValidateInstructions(SPV_ENV_VULKAN_1_1))
- << test_code;
- }
- }
- TEST_P(ValidateCapabilityVulkan12, Capability) {
- const std::string capability = Capability(GetParam());
- if (Exists(capability, SPV_ENV_VULKAN_1_2)) {
- const std::string test_code = MakeAssembly(GetParam());
- CompileSuccessfully(test_code, SPV_ENV_VULKAN_1_2);
- ASSERT_EQ(ExpectedResult(GetParam()),
- ValidateInstructions(SPV_ENV_VULKAN_1_2))
- << test_code;
- }
- }
- TEST_P(ValidateCapabilityOpenGL40, Capability) {
- const std::string capability = Capability(GetParam());
- if (Exists(capability, SPV_ENV_OPENGL_4_0)) {
- const std::string test_code = MakeAssembly(GetParam());
- CompileSuccessfully(test_code, SPV_ENV_OPENGL_4_0);
- ASSERT_EQ(ExpectedResult(GetParam()),
- ValidateInstructions(SPV_ENV_OPENGL_4_0))
- << test_code;
- }
- }
- TEST_F(ValidateCapability, SemanticsIdIsAnIdNotALiteral) {
- // From https://github.com/KhronosGroup/SPIRV-Tools/issues/248
- // The validator was interpreting the memory semantics ID number
- // as the value to be checked rather than an ID that references
- // another value to be checked.
- // In this case a raw ID of 64 was mistaken to mean a literal
- // semantic value of UniformMemory, which would require the Shader
- // capability.
- const char str[] = R"(
- OpCapability Kernel
- OpCapability Linkage
- OpMemoryModel Logical OpenCL
- ; %i32 has ID 1
- %i32 = OpTypeInt 32 0
- %tf = OpTypeFunction %i32
- %pi32 = OpTypePointer CrossWorkgroup %i32
- %var = OpVariable %pi32 CrossWorkgroup
- %c = OpConstant %i32 100
- %scope = OpConstant %i32 1 ; Device scope
- ; Fake an instruction with 64 as the result id.
- ; !64 = OpConstantNull %i32
- !0x3002e !1 !64
- %f = OpFunction %i32 None %tf
- %l = OpLabel
- %result = OpAtomicIAdd %i32 %var %scope !64 %c
- OpReturnValue %result
- OpFunctionEnd
- )";
- CompileSuccessfully(str);
- // Since we are forcing usage of <id> 64, the "id bound" in the binary header
- // must be overwritten so that <id> 64 is considered within bound.
- // ID Bound is at index 3 of the binary. Set it to 65.
- OverwriteAssembledBinary(3, 65);
- ASSERT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateCapability, IntSignednessKernelGood) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Linkage
- OpMemoryModel Logical OpenCL
- %i32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateCapability, IntSignednessKernelBad) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Linkage
- OpMemoryModel Logical OpenCL
- %i32 = OpTypeInt 32 1
- )";
- CompileSuccessfully(spirv);
- EXPECT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions());
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("The Signedness in OpTypeInt must always be 0 when "
- "Kernel capability is used."));
- }
- TEST_F(ValidateCapability, IntSignednessShaderGood) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability Linkage
- OpMemoryModel Logical GLSL450
- %u32 = OpTypeInt 32 0
- %i32 = OpTypeInt 32 1
- )";
- CompileSuccessfully(spirv);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
- }
- TEST_F(ValidateCapability, NonVulkan10Capability) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability Linkage
- OpMemoryModel Logical GLSL450
- %u32 = OpTypeInt 32 0
- %i32 = OpTypeInt 32 1
- )";
- CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_VULKAN_1_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Linkage is not allowed by Vulkan 1.0"));
- }
- TEST_F(ValidateCapability, Vulkan10EnabledByExtension) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability DrawParameters
- OpExtension "SPV_KHR_shader_draw_parameters"
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %func "shader"
- OpMemberDecorate %block 0 BuiltIn PointSize
- %f32 = OpTypeFloat 32
- %block = OpTypeStruct %f32
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
- }
- TEST_F(ValidateCapability, Vulkan10NotEnabledByExtension) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability DrawParameters
- OpMemoryModel Logical GLSL450
- OpEntryPoint Vertex %func "shader"
- OpDecorate %intt BuiltIn PointSize
- %intt = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_VULKAN_1_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_VULKAN_1_0));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("Capability DrawParameters is not allowed by Vulkan 1.0"));
- }
- TEST_F(ValidateCapability, NonOpenCL12FullCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Pipes
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_1_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_1_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("Capability Pipes is not allowed by OpenCL 1.2 Full Profile"));
- }
- TEST_F(ValidateCapability, OpenCL12FullEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability ImageBasic
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_1_2);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_1_2));
- }
- TEST_F(ValidateCapability, OpenCL12FullNotEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_1_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_1_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability Sampled1D is not allowed by OpenCL 1.2 Full Profile"));
- }
- TEST_F(ValidateCapability, NonOpenCL12EmbeddedCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Int64
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_1_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability Int64 is not allowed by OpenCL 1.2 Embedded Profile"));
- }
- TEST_F(ValidateCapability, OpenCL12EmbeddedEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability ImageBasic
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_1_2));
- }
- TEST_F(ValidateCapability, OpenCL12EmbeddedNotEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_1_2));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Sampled1D is not allowed by OpenCL 1.2 "
- "Embedded Profile"));
- }
- TEST_F(ValidateCapability, OpenCL12EmbeddedNoLongerEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Pipes
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_1_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_1_2));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Pipes is not allowed by OpenCL 1.2 "
- "Embedded Profile"));
- }
- TEST_F(ValidateCapability, OpenCL20FullCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Groups
- OpCapability Pipes
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_2_0));
- }
- TEST_F(ValidateCapability, NonOpenCL20FullCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Matrix
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_2_0));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability Matrix is not allowed by OpenCL 2.0/2.1 Full Profile"));
- }
- TEST_F(ValidateCapability, OpenCL20FullEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability ImageBasic
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_2_0));
- }
- TEST_F(ValidateCapability, OpenCL20FullNotEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_2_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Sampled1D is not allowed by OpenCL 2.0/2.1 "
- "Full Profile"));
- }
- TEST_F(ValidateCapability, NonOpenCL20EmbeddedCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Int64
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Int64 is not allowed by OpenCL 2.0/2.1 "
- "Embedded Profile"));
- }
- TEST_F(ValidateCapability, OpenCL20EmbeddedEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability ImageBasic
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_0));
- }
- TEST_F(ValidateCapability, OpenCL20EmbeddedNotEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Sampled1D is not allowed by OpenCL 2.0/2.1 "
- "Embedded Profile"));
- }
- TEST_F(ValidateCapability, OpenCL22FullCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability PipeStorage
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_2);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_2_2));
- }
- TEST_F(ValidateCapability, NonOpenCL22FullCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Matrix
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_2_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr("Capability Matrix is not allowed by OpenCL 2.2 Full Profile"));
- }
- TEST_F(ValidateCapability, OpenCL22FullEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability ImageBasic
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_2);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_2_2));
- }
- TEST_F(ValidateCapability, OpenCL22FullNotEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_2_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_2_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability Sampled1D is not allowed by OpenCL 2.2 Full Profile"));
- }
- TEST_F(ValidateCapability, NonOpenCL22EmbeddedCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Int64
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )";
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_2));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "Capability Int64 is not allowed by OpenCL 2.2 Embedded Profile"));
- }
- TEST_F(ValidateCapability, OpenCL22EmbeddedEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability ImageBasic
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_2);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_2));
- }
- TEST_F(ValidateCapability, OpenCL22EmbeddedNotEnabledByCapability) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability Linkage
- OpCapability Sampled1D
- OpMemoryModel Physical64 OpenCL
- %u32 = OpTypeInt 32 0
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_OPENCL_EMBEDDED_2_2);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_OPENCL_EMBEDDED_2_2));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Capability Sampled1D is not allowed by OpenCL 2.2 "
- "Embedded Profile"));
- }
- // Three tests to check enablement of an enum (a decoration) which is not
- // in core, and is directly enabled by a capability, but not directly enabled
- // by an extension. See https://github.com/KhronosGroup/SPIRV-Tools/issues/1596
- TEST_F(ValidateCapability, DecorationFromExtensionMissingEnabledByCapability) {
- // Decoration ViewportRelativeNV is enabled by ShaderViewportMaskNV, which in
- // turn is enabled by SPV_NV_viewport_array2.
- const std::string spirv = R"(
- OpCapability Shader
- OpMemoryModel Logical Simple
- OpDecorate %void ViewportRelativeNV
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Operand 2 of Decorate requires one of these "
- "capabilities: ShaderViewportMaskNV"));
- }
- TEST_F(ValidateCapability, CapabilityEnabledByMissingExtension) {
- // Capability ShaderViewportMaskNV is enabled by SPV_NV_viewport_array2.
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability ShaderViewportMaskNV
- OpMemoryModel Logical Simple
- )" + std::string(kVoidFVoid);
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("operand ShaderViewportMaskNV(5255) requires one of "
- "these extensions: SPV_NV_viewport_array2"));
- }
- TEST_F(ValidateCapability,
- DecorationEnabledByCapabilityEnabledByPresentExtension) {
- // Decoration ViewportRelativeNV is enabled by ShaderViewportMaskNV, which in
- // turn is enabled by SPV_NV_viewport_array2.
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability Linkage
- OpCapability ShaderViewportMaskNV
- OpExtension "SPV_NV_viewport_array2"
- OpMemoryModel Logical Simple
- OpDecorate %void ViewportRelativeNV
- %void = OpTypeVoid
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_0))
- << getDiagnosticString();
- }
- // Three tests to check enablement of an instruction which is not in core, and
- // is directly enabled by a capability, but not directly enabled by an
- // extension. See https://github.com/KhronosGroup/SPIRV-Tools/issues/1624
- // Instruction OpSubgroupShuffleINTEL is enabled by SubgroupShuffleINTEL, which
- // in turn is enabled by SPV_INTEL_subgroups.
- TEST_F(ValidateCapability, InstructionFromExtensionMissingEnabledByCapability) {
- // Decoration ViewportRelativeNV is enabled by ShaderViewportMaskNV, which in
- // turn is enabled by SPV_NV_viewport_array2.
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- ; OpCapability SubgroupShuffleINTEL
- OpExtension "SPV_INTEL_subgroups"
- OpMemoryModel Physical32 OpenCL
- OpEntryPoint Kernel %main "main"
- %void = OpTypeVoid
- %uint = OpTypeInt 32 0
- %voidfn = OpTypeFunction %void
- %zero = OpConstant %uint 0
- %main = OpFunction %void None %voidfn
- %entry = OpLabel
- %foo = OpSubgroupShuffleINTEL %uint %zero %zero
- OpReturn
- OpFunctionEnd
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_ERROR_INVALID_CAPABILITY,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("Opcode SubgroupShuffleINTEL requires one of these "
- "capabilities: SubgroupShuffleINTEL"));
- }
- TEST_F(ValidateCapability,
- InstructionEnablingCapabilityEnabledByMissingExtension) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability SubgroupShuffleINTEL
- ; OpExtension "SPV_INTEL_subgroups"
- OpMemoryModel Physical32 OpenCL
- OpEntryPoint Kernel %main "main"
- %void = OpTypeVoid
- %uint = OpTypeInt 32 0
- %voidfn = OpTypeFunction %void
- %zero = OpConstant %uint 0
- %main = OpFunction %void None %voidfn
- %entry = OpLabel
- %foo = OpSubgroupShuffleINTEL %uint %zero %zero
- OpReturn
- OpFunctionEnd
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_0));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("operand SubgroupShuffleINTEL(5568) requires one of "
- "these extensions: SPV_INTEL_subgroups"));
- }
- TEST_F(ValidateCapability,
- InstructionEnabledByCapabilityEnabledByPresentExtension) {
- const std::string spirv = R"(
- OpCapability Kernel
- OpCapability Addresses
- OpCapability SubgroupShuffleINTEL
- OpExtension "SPV_INTEL_subgroups"
- OpMemoryModel Physical32 OpenCL
- OpEntryPoint Kernel %main "main"
- %void = OpTypeVoid
- %uint = OpTypeInt 32 0
- %voidfn = OpTypeFunction %void
- %zero = OpConstant %uint 0
- %main = OpFunction %void None %voidfn
- %entry = OpLabel
- %foo = OpSubgroupShuffleINTEL %uint %zero %zero
- OpReturn
- OpFunctionEnd
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_0))
- << getDiagnosticString();
- }
- TEST_F(ValidateCapability, VulkanMemoryModelWithVulkanKHR) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability VulkanMemoryModelKHR
- OpCapability Linkage
- OpExtension "SPV_KHR_vulkan_memory_model"
- OpMemoryModel Logical VulkanKHR
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_3))
- << getDiagnosticString();
- }
- TEST_F(ValidateCapability, VulkanMemoryModelWithGLSL450) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability VulkanMemoryModelKHR
- OpCapability Linkage
- OpExtension "SPV_KHR_vulkan_memory_model"
- OpMemoryModel Logical GLSL450
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_3);
- EXPECT_EQ(SPV_ERROR_INVALID_DATA,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_3));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("VulkanMemoryModelKHR capability must only be "
- "specified if the VulkanKHR memory model is used"));
- }
- // In the grammar, SubgroupEqMask and SubgroupMaskKHR have different enabling
- // lists of extensions.
- TEST_F(ValidateCapability, SubgroupEqMaskEnabledByExtension) {
- const std::string spirv = R"(
- OpCapability Shader
- OpCapability SubgroupBallotKHR
- OpExtension "SPV_KHR_shader_ballot"
- OpMemoryModel Logical Simple
- OpEntryPoint GLCompute %main "main"
- OpDecorate %var BuiltIn SubgroupEqMask
- %void = OpTypeVoid
- %uint = OpTypeInt 32 0
- %ptr_uint = OpTypePointer Private %uint
- %var = OpVariable %ptr_uint Private
- %fn = OpTypeFunction %void
- %main = OpFunction %void None %fn
- %entry = OpLabel
- %val = OpLoad %uint %var
- OpReturn
- OpFunctionEnd
- )";
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_0);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_0))
- << getDiagnosticString();
- }
- // Test that extensions incorporated into SPIR-V 1.5 no longer require
- // the associated OpExtension instruction. Test one capability per extension.
- struct CapabilityExtensionVersionCase {
- std::string capability;
- std::string capability_new_name;
- std::string extension;
- spv_target_env last_version_requiring_extension;
- spv_target_env first_version_in_core;
- };
- using ValidateCapabilityExtensionVersionTest =
- spvtest::ValidateBase<CapabilityExtensionVersionCase>;
- // Returns a minimal shader module with the given capability instruction.
- std::string MinimalShaderModuleWithCapability(std::string cap) {
- std::string mem_model =
- (cap.find("VulkanMemory") == 0) ? "VulkanKHR" : "GLSL450";
- std::string extra_cap = (cap.find("VulkanMemoryModelDeviceScope") == 0)
- ? "\nOpCapability VulkanMemoryModelKHR\n"
- : "";
- return std::string("OpCapability ") + cap + extra_cap + R"(
- OpCapability Shader
- OpMemoryModel Logical )" + mem_model + R"(
- OpEntryPoint Vertex %main "main"
- %void = OpTypeVoid
- %void_fn = OpTypeFunction %void
- %main = OpFunction %void None %void_fn
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- )";
- }
- TEST_P(ValidateCapabilityExtensionVersionTest, FailsInOlderSpirvVersion) {
- const auto spirv = MinimalShaderModuleWithCapability(GetParam().capability);
- CompileSuccessfully(spirv, GetParam().last_version_requiring_extension);
- EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION,
- ValidateInstructions(GetParam().last_version_requiring_extension));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr(std::string("1st operand of Capability: operand ") +
- GetParam().capability_new_name))
- << spirv << "\n";
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr(std::string("requires one of these extensions: ") +
- GetParam().extension));
- }
- TEST_P(ValidateCapabilityExtensionVersionTest,
- SucceedsInNewerSpirvVersionWithOldName) {
- const auto spirv = MinimalShaderModuleWithCapability(GetParam().capability);
- CompileSuccessfully(spirv, GetParam().first_version_in_core);
- EXPECT_EQ(SPV_SUCCESS,
- ValidateInstructions(GetParam().first_version_in_core));
- EXPECT_THAT(getDiagnosticString(), Eq("")) << spirv << "\n";
- }
- TEST_P(ValidateCapabilityExtensionVersionTest,
- SucceedsInNewerSpirvVersionWithNewName) {
- const auto spirv =
- MinimalShaderModuleWithCapability(GetParam().capability_new_name);
- CompileSuccessfully(spirv, GetParam().first_version_in_core);
- EXPECT_EQ(SPV_SUCCESS,
- ValidateInstructions(GetParam().first_version_in_core));
- EXPECT_THAT(getDiagnosticString(), Eq("")) << spirv << "\n";
- }
- std::vector<CapabilityExtensionVersionCase> CapVersionCases1_5() {
- #define IN15NOSUFFIX(C, E) \
- { C, C, E, SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_5 }
- #define IN15(C, C_WITHOUT_SUFFIX, E) \
- { C, C_WITHOUT_SUFFIX, E, SPV_ENV_UNIVERSAL_1_4, SPV_ENV_UNIVERSAL_1_5 }
- return std::vector<CapabilityExtensionVersionCase>{
- // SPV_KHR_8bit_storage
- IN15NOSUFFIX("StorageBuffer8BitAccess", "SPV_KHR_8bit_storage"),
- IN15NOSUFFIX("UniformAndStorageBuffer8BitAccess", "SPV_KHR_8bit_storage"),
- IN15NOSUFFIX("StoragePushConstant8", "SPV_KHR_8bit_storage"),
- // SPV_EXT_descriptor_indexing
- IN15("ShaderNonUniformEXT", "ShaderNonUniform",
- "SPV_EXT_descriptor_indexing"),
- IN15("RuntimeDescriptorArrayEXT", "RuntimeDescriptorArray",
- "SPV_EXT_descriptor_indexing"),
- IN15("InputAttachmentArrayDynamicIndexingEXT",
- "InputAttachmentArrayDynamicIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("UniformTexelBufferArrayDynamicIndexingEXT",
- "UniformTexelBufferArrayDynamicIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("StorageTexelBufferArrayDynamicIndexingEXT",
- "StorageTexelBufferArrayDynamicIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("UniformBufferArrayNonUniformIndexingEXT",
- "UniformBufferArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("SampledImageArrayNonUniformIndexingEXT",
- "SampledImageArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("StorageBufferArrayNonUniformIndexingEXT",
- "StorageBufferArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("StorageImageArrayNonUniformIndexingEXT",
- "StorageImageArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("InputAttachmentArrayNonUniformIndexingEXT",
- "InputAttachmentArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("UniformTexelBufferArrayNonUniformIndexingEXT",
- "UniformTexelBufferArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- IN15("StorageTexelBufferArrayNonUniformIndexingEXT",
- "StorageTexelBufferArrayNonUniformIndexing",
- "SPV_EXT_descriptor_indexing"),
- // SPV_EXT_physical_storage_buffer
- IN15("PhysicalStorageBufferAddresses", "PhysicalStorageBufferAddresses",
- "SPV_EXT_physical_storage_buffer"),
- // SPV_KHR_vulkan_memory_model
- IN15("VulkanMemoryModelKHR", "VulkanMemoryModel",
- "SPV_KHR_vulkan_memory_model"),
- IN15("VulkanMemoryModelDeviceScopeKHR", "VulkanMemoryModelDeviceScope",
- "SPV_KHR_vulkan_memory_model"),
- };
- #undef IN15
- }
- INSTANTIATE_TEST_SUITE_P(NewInSpirv1_5, ValidateCapabilityExtensionVersionTest,
- ValuesIn(CapVersionCases1_5()));
- TEST_P(ValidateCapability,
- CapShaderViewportIndexLayerFailsInOlderSpirvVersion) {
- const auto spirv =
- MinimalShaderModuleWithCapability("ShaderViewportIndexLayerEXT");
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_4);
- EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_4));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "1st operand of Capability: operand ShaderViewportIndexLayerEXT"));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("requires one of these extensions: "
- "SPV_EXT_shader_viewport_index_layer"));
- }
- TEST_P(ValidateCapability, CapShaderViewportIndexLayerFailsInNewSpirvVersion) {
- const auto spirv =
- MinimalShaderModuleWithCapability("ShaderViewportIndexLayerEXT");
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_5);
- EXPECT_EQ(SPV_ERROR_MISSING_EXTENSION,
- ValidateInstructions(SPV_ENV_UNIVERSAL_1_5));
- EXPECT_THAT(
- getDiagnosticString(),
- HasSubstr(
- "1st operand of Capability: operand ShaderViewportIndexLayerEXT"));
- EXPECT_THAT(getDiagnosticString(),
- HasSubstr("requires one of these extensions: "
- "SPV_EXT_shader_viewport_index_layer"));
- }
- TEST_F(ValidateCapability, CapShaderViewportIndexSucceedsInNewSpirvVersion) {
- const auto spirv = MinimalShaderModuleWithCapability("ShaderViewportIndex");
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_5);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5));
- EXPECT_THAT(getDiagnosticString(), Eq(""));
- }
- TEST_F(ValidateCapability, CapShaderLayerSucceedsInNewSpirvVersion) {
- const auto spirv = MinimalShaderModuleWithCapability("ShaderLayer");
- CompileSuccessfully(spirv, SPV_ENV_UNIVERSAL_1_5);
- EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_UNIVERSAL_1_5));
- EXPECT_THAT(getDiagnosticString(), Eq(""));
- }
- } // namespace
- } // namespace val
- } // namespace spvtools
|