123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662 |
- ///////////////////////////////////////////////////////////////////////////////
- // //
- // ValidationTest.cpp //
- // Copyright (C) Microsoft Corporation. All rights reserved. //
- // Licensed under the MIT license. See COPYRIGHT in the project root for //
- // full license information. //
- // //
- // //
- ///////////////////////////////////////////////////////////////////////////////
- #include <memory>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include "llvm/ADT/StringRef.h"
- #include "llvm/Support/Regex.h"
- #include <atlbase.h>
- #include "WexTestClass.h"
- #include "DxcTestUtils.h"
- #include "HlslTestUtils.h"
- using namespace std;
- void CheckOperationSucceeded(IDxcOperationResult *pResult, IDxcBlob **ppBlob) {
- HRESULT status;
- VERIFY_SUCCEEDED(pResult->GetStatus(&status));
- VERIFY_SUCCEEDED(status);
- VERIFY_SUCCEEDED(pResult->GetResult(ppBlob));
- }
- std::string DisassembleProgram(dxc::DxcDllSupport &dllSupport,
- IDxcBlob *pProgram) {
- CComPtr<IDxcCompiler> pCompiler;
- CComPtr<IDxcBlobEncoding> pDisassembly;
- if (!dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(dllSupport.Initialize());
- }
- VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
- VERIFY_SUCCEEDED(pCompiler->Disassemble(pProgram, &pDisassembly));
- return BlobToUtf8(pDisassembly);
- }
- class ValidationTest
- {
- public:
- BEGIN_TEST_CLASS(ValidationTest)
- TEST_METHOD_PROPERTY(L"Priority", L"0")
- END_TEST_CLASS()
- TEST_METHOD(WhenCorrectThenOK);
- TEST_METHOD(WhenMisalignedThenFail);
- TEST_METHOD(WhenEmptyFileThenFail);
- TEST_METHOD(WhenIncorrectMagicThenFail);
- TEST_METHOD(WhenIncorrectTargetTripleThenFail);
- TEST_METHOD(WhenIncorrectModelThenFail);
- TEST_METHOD(WhenIncorrectPSThenFail);
- TEST_METHOD(WhenWaveAffectsGradientThenFail);
- TEST_METHOD(WhenMultipleModulesThenFail);
- TEST_METHOD(WhenUnexpectedEOFThenFail);
- TEST_METHOD(WhenUnknownBlocksThenFail);
- TEST_METHOD(LoadOutputControlPointNotInPatchConstantFunction);
- TEST_METHOD(StorePatchControlNotInPatchConstantFunction);
- TEST_METHOD(OutputControlPointIDInPatchConstantFunction);
- TEST_METHOD(GsVertexIDOutOfBound)
- TEST_METHOD(StreamIDOutOfBound)
- TEST_METHOD(SignatureStreamIDForNonGS)
- TEST_METHOD(TypedUAVStoreFullMask0)
- TEST_METHOD(TypedUAVStoreFullMask1)
- TEST_METHOD(Recursive)
- TEST_METHOD(Recursive2)
- TEST_METHOD(UserDefineFunction)
- TEST_METHOD(ResourceRangeOverlap0)
- TEST_METHOD(ResourceRangeOverlap1)
- TEST_METHOD(ResourceRangeOverlap2)
- TEST_METHOD(ResourceRangeOverlap3)
- TEST_METHOD(CBufferOverlap0)
- TEST_METHOD(CBufferOverlap1)
- TEST_METHOD(ControlFlowHint)
- TEST_METHOD(ControlFlowHint1)
- TEST_METHOD(ControlFlowHint2)
- TEST_METHOD(SemanticLength1)
- TEST_METHOD(SemanticLength64)
- TEST_METHOD(PullModelPosition)
- TEST_METHOD(StructBufStrideAlign)
- TEST_METHOD(StructBufStrideOutOfBound)
- TEST_METHOD(StructBufGlobalCoherentAndCounter)
- TEST_METHOD(StructBufLoadCoordinates)
- TEST_METHOD(StructBufStoreCoordinates)
- TEST_METHOD(TypedBufRetType)
- TEST_METHOD(VsInputSemantic)
- TEST_METHOD(VsOutputSemantic)
- TEST_METHOD(HsInputSemantic)
- TEST_METHOD(HsOutputSemantic)
- TEST_METHOD(PatchConstSemantic)
- TEST_METHOD(DsInputSemantic)
- TEST_METHOD(DsOutputSemantic)
- TEST_METHOD(GsInputSemantic)
- TEST_METHOD(GsOutputSemantic)
- TEST_METHOD(PsInputSemantic)
- TEST_METHOD(PsOutputSemantic)
- TEST_METHOD(ArrayOfSVTarget)
- TEST_METHOD(InfiniteLog)
- TEST_METHOD(InfiniteAsin)
- TEST_METHOD(InfiniteAcos)
- TEST_METHOD(InfiniteDdxDdy)
- TEST_METHOD(IDivByZero)
- TEST_METHOD(UDivByZero)
- TEST_METHOD(UnusedMetadata)
- TEST_METHOD(MemoryOutOfBound)
- TEST_METHOD(AddrSpaceCast)
- TEST_METHOD(PtrBitCast)
- TEST_METHOD(MinPrecisionBitCast)
- TEST_METHOD(StructBitCast)
- TEST_METHOD(MultiDimArray)
- TEST_METHOD(ClipCullMaxComponents)
- TEST_METHOD(ClipCullMaxRows)
- TEST_METHOD(DuplicateSysValue)
- TEST_METHOD(SemTargetMax)
- TEST_METHOD(SemTargetIndexMatchesRow)
- TEST_METHOD(SemTargetCol0)
- TEST_METHOD(SemIndexMax)
- TEST_METHOD(SemTessFactorIndexMax)
- TEST_METHOD(SemInsideTessFactorIndexMax)
- TEST_METHOD(SemShouldBeAllocated)
- TEST_METHOD(SemShouldNotBeAllocated)
- TEST_METHOD(SemComponentOrder)
- TEST_METHOD(SemComponentOrder2)
- TEST_METHOD(SemComponentOrder3)
- TEST_METHOD(SemIndexConflictArbSV)
- TEST_METHOD(SemIndexConflictTessfactors)
- TEST_METHOD(SemIndexConflictTessfactors2)
- TEST_METHOD(SemRowOutOfRange)
- TEST_METHOD(SemPackOverlap)
- TEST_METHOD(SemPackOverlap2)
- TEST_METHOD(SemMultiDepth)
- TEST_METHOD(WhenInstrDisallowedThenFail);
- TEST_METHOD(WhenDepthNotFloatThenFail);
- TEST_METHOD(BarrierFail);
- TEST_METHOD(CBufferLegacyOutOfBoundFail);
- TEST_METHOD(CBufferOutOfBoundFail);
- TEST_METHOD(CsThreadSizeFail);
- TEST_METHOD(DeadLoopFail);
- TEST_METHOD(EvalFail);
- TEST_METHOD(GetDimCalcLODFail);
- TEST_METHOD(HsAttributeFail);
- TEST_METHOD(InnerCoverageFail);
- TEST_METHOD(InterpChangeFail);
- TEST_METHOD(InterpOnIntFail);
- TEST_METHOD(InvalidSigCompTyFail);
- TEST_METHOD(MultiStream2Fail);
- TEST_METHOD(PhiTGSMFail);
- TEST_METHOD(ReducibleFail);
- TEST_METHOD(SampleBiasFail);
- TEST_METHOD(SamplerKindFail);
- TEST_METHOD(SemaOverlapFail);
- TEST_METHOD(SigOutOfRangeFail);
- TEST_METHOD(SigOverlapFail);
- TEST_METHOD(SimpleHs1Fail);
- TEST_METHOD(SimpleHs3Fail);
- TEST_METHOD(SimpleHs4Fail);
- TEST_METHOD(SimpleDs1Fail);
- TEST_METHOD(SimpleGs1Fail);
- TEST_METHOD(UavBarrierFail);
- TEST_METHOD(UndefValueFail);
- TEST_METHOD(UpdateCounterFail);
- TEST_METHOD(WhenSmUnknownThenFail);
- TEST_METHOD(WhenSmLegacyThenFail);
- TEST_METHOD(WhenMetaFlagsUsageDeclThenOK);
- TEST_METHOD(WhenMetaFlagsUsageThenFail);
- dxc::DxcDllSupport m_dllSupport;
- void TestCheck(LPCWSTR name) {
- std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
- FileRunTestResult t = FileRunTestResult::RunFromFileCommands(fullPath.c_str());
- if (t.RunResult != 0) {
- CA2W commentWide(t.ErrorMessage.c_str(), CP_UTF8);
- WEX::Logging::Log::Comment(commentWide);
- WEX::Logging::Log::Error(L"Run result is not zero");
- }
- }
- bool CheckOperationResultMsg(IDxcOperationResult *pResult,
- const char *pErrorMsg, bool maySucceedAnyway,
- bool bRegex) {
- HRESULT status;
- VERIFY_SUCCEEDED(pResult->GetStatus(&status));
- if (pErrorMsg == nullptr) {
- VERIFY_SUCCEEDED(status);
- }
- else {
- if (SUCCEEDED(status) && maySucceedAnyway) {
- return false;
- }
- //VERIFY_FAILED(status);
- CComPtr<IDxcBlobEncoding> text;
- VERIFY_SUCCEEDED(pResult->GetErrorBuffer(&text));
- if (bRegex) {
- llvm::Regex RE(pErrorMsg);
- std::string reErrors;
- VERIFY_IS_TRUE(RE.isValid(reErrors));
- VERIFY_IS_TRUE(RE.match(llvm::StringRef((const char *)text->GetBufferPointer(), text->GetBufferSize())));
- } else {
- const char *pStart = (const char *)text->GetBufferPointer();
- const char *pEnd = pStart + text->GetBufferSize();
- const char *pMatch = std::search(pStart, pEnd, pErrorMsg, pErrorMsg + strlen(pErrorMsg));
- VERIFY_ARE_NOT_EQUAL(pEnd, pMatch);
- }
- }
- return true;
- }
- void CheckValidationMsg(IDxcBlob *pBlob, const char *pErrorMsg, bool bRegex = false) {
- CComPtr<IDxcValidator> pValidator;
- CComPtr<IDxcOperationResult> pResult;
- if (!m_dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
- }
- VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcValidator, &pValidator));
- VERIFY_SUCCEEDED(pValidator->Validate(pBlob, DxcValidatorFlags_Default, &pResult));
- CheckOperationResultMsg(pResult, pErrorMsg, false, bRegex);
- }
- void CheckValidationMsg(const char *pBlob, size_t blobSize, const char *pErrorMsg, bool bRegex = false) {
- if (!m_dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
- }
- CComPtr<IDxcLibrary> pLibrary;
- CComPtr<IDxcBlobEncoding> pBlobEncoding; // Encoding doesn't actually matter, it's binary.
- VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
- VERIFY_SUCCEEDED(pLibrary->CreateBlobWithEncodingFromPinned((LPBYTE)pBlob, blobSize, CP_UTF8, &pBlobEncoding));
- CheckValidationMsg(pBlobEncoding, pErrorMsg, bRegex);
- }
- void CompileSource(IDxcBlobEncoding *pSource, LPCSTR pShaderModel,
- IDxcBlob **pResultBlob) {
- CComPtr<IDxcCompiler> pCompiler;
- CComPtr<IDxcOperationResult> pResult;
- CComPtr<IDxcBlob> pProgram;
- if (!m_dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
- }
- CA2W shWide(pShaderModel, CP_UTF8);
- VERIFY_SUCCEEDED(
- m_dllSupport.CreateInstance(CLSID_DxcCompiler, &pCompiler));
- VERIFY_SUCCEEDED(pCompiler->Compile(pSource, L"hlsl.hlsl", L"main",
- shWide, nullptr, 0, nullptr, 0, nullptr,
- &pResult));
- VERIFY_SUCCEEDED(pResult->GetResult(pResultBlob));
- }
- void CompileSource(LPCSTR pSource, LPCSTR pShaderModel,
- IDxcBlob **pResultBlob) {
- if (!m_dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
- }
- CComPtr<IDxcBlobEncoding> pSourceBlob;
- Utf8ToBlob(m_dllSupport, pSource, &pSourceBlob);
- CompileSource(pSourceBlob, pShaderModel, pResultBlob);
- }
- void DisassembleProgram(IDxcBlob *pProgram, std::string *text) {
- *text = ::DisassembleProgram(m_dllSupport, pProgram);
- }
- void RewriteAssemblyCheckMsg(LPCSTR pSource, LPCSTR pShaderModel,
- LPCSTR pLookFor, LPCSTR pReplacement,
- LPCSTR pErrorMsg, bool bRegex = false) {
- CComPtr<IDxcBlob> pText;
- CComPtr<IDxcBlobEncoding> pSourceBlob;
-
- if (!m_dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
- }
- Utf8ToBlob(m_dllSupport, pSource, &pSourceBlob);
- RewriteAssemblyToText(pSourceBlob, pShaderModel, pLookFor, pReplacement, &pText, bRegex);
- CComPtr<IDxcAssembler> pAssembler;
- CComPtr<IDxcOperationResult> pAssembleResult;
- VERIFY_SUCCEEDED(
- m_dllSupport.CreateInstance(CLSID_DxcAssembler, &pAssembler));
- VERIFY_SUCCEEDED(pAssembler->AssembleToContainer(pText, &pAssembleResult));
- if (!CheckOperationResultMsg(pAssembleResult, pErrorMsg, true, bRegex)) {
- // Assembly succeeded, try validation.
- CComPtr<IDxcBlob> pBlob;
- VERIFY_SUCCEEDED(pAssembleResult->GetResult(&pBlob));
- CheckValidationMsg(pBlob, pErrorMsg, bRegex);
- }
- }
- void RewriteAssemblyToText(IDxcBlobEncoding *pSource, LPCSTR pShaderModel,
- LPCSTR pLookFor, LPCSTR pReplacement,
- IDxcBlob **pBlob, bool bRegex = false) {
- CComPtr<IDxcBlob> pProgram;
- std::string disassembly;
- CompileSource(pSource, pShaderModel, &pProgram);
- DisassembleProgram(pProgram, &disassembly);
- if (pLookFor && *pLookFor) {
- if (bRegex) {
- llvm::Regex RE(pLookFor);
- std::string reErrors;
- VERIFY_IS_TRUE(RE.isValid(reErrors));
- std::string replaced = RE.sub(pReplacement, disassembly, &reErrors);
- VERIFY_ARE_NOT_EQUAL(disassembly, replaced);
- VERIFY_IS_TRUE(reErrors.empty());
- disassembly = std::move(replaced);
- } else {
- bool found = false;
- size_t pos = 0;
- size_t lookForLen = strlen(pLookFor);
- size_t replaceLen = strlen(pReplacement);
- for (;;) {
- pos = disassembly.find(pLookFor, pos);
- if (pos == std::string::npos)
- break;
- found = true; // at least once
- disassembly.replace(pos, lookForLen, pReplacement);
- pos += replaceLen;
- }
- VERIFY_IS_TRUE(found);
- }
- }
- Utf8ToBlob(m_dllSupport, disassembly.c_str(), pBlob);
- }
-
- void RewriteAssemblyCheckMsg(LPCWSTR name, LPCSTR pShaderModel,
- LPCSTR pLookFor, LPCSTR pReplacement,
- LPCSTR pErrorMsg, bool bRegex = false) {
- std::wstring fullPath = hlsl_test::GetPathToHlslDataFile(name);
- CComPtr<IDxcLibrary> pLibrary;
- CComPtr<IDxcBlobEncoding> pSource;
- if (!m_dllSupport.IsEnabled()) {
- VERIFY_SUCCEEDED(m_dllSupport.Initialize());
- }
- VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLibrary));
- VERIFY_SUCCEEDED(
- pLibrary->CreateBlobFromFile(fullPath.c_str(), nullptr, &pSource));
- CComPtr<IDxcBlob> pText;
- RewriteAssemblyToText(pSource, pShaderModel, pLookFor, pReplacement, &pText);
- CComPtr<IDxcAssembler> pAssembler;
- CComPtr<IDxcOperationResult> pAssembleResult;
- VERIFY_SUCCEEDED(
- m_dllSupport.CreateInstance(CLSID_DxcAssembler, &pAssembler));
- VERIFY_SUCCEEDED(pAssembler->AssembleToContainer(pText, &pAssembleResult));
- if (!CheckOperationResultMsg(pAssembleResult, pErrorMsg, true, bRegex)) {
- // Assembly succeeded, try validation.
- CComPtr<IDxcBlob> pBlob;
- VERIFY_SUCCEEDED(pAssembleResult->GetResult(&pBlob));
- CheckValidationMsg(pBlob, pErrorMsg, bRegex);
- }
- }
- };
- TEST_F(ValidationTest, WhenCorrectThenOK) {
- CComPtr<IDxcBlob> pProgram;
- CompileSource("float4 main() : SV_Target { return 1; }", "ps_6_0", &pProgram);
- CheckValidationMsg(pProgram, nullptr);
- }
- // Lots of these going on below for simplicity in setting up payloads.
- //
- // warning C4838: conversion from 'int' to 'const char' requires a narrowing conversion
- // warning C4309: 'initializing': truncation of constant value
- #pragma warning(disable: 4838)
- #pragma warning(disable: 4309)
- TEST_F(ValidationTest, WhenMisalignedThenFail) {
- // Bitcode size must 4-byte aligned
- const char blob[] = {
- 'B', 'C',
- };
- CheckValidationMsg(blob, _countof(blob), "Invalid bitcode size");
- }
- TEST_F(ValidationTest, WhenEmptyFileThenFail) {
- // No blocks after signature.
- const char blob[] = {
- 'B', 'C', 0xc0, 0xde
- };
- CheckValidationMsg(blob, _countof(blob), "Malformed IR file");
- }
- TEST_F(ValidationTest, WhenIncorrectMagicThenFail) {
- // Signature isn't 'B', 'C', 0xC0 0xDE
- const char blob[] = {
- 'B', 'C', 0xc0, 0xdd
- };
- CheckValidationMsg(blob, _countof(blob), "Invalid bitcode signature");
- }
- TEST_F(ValidationTest, WhenIncorrectTargetTripleThenFail) {
- const char blob[] = {
- 'B', 'C', 0xc0, 0xde
- };
- CheckValidationMsg(blob, _countof(blob), "Malformed IR file");
- }
- TEST_F(ValidationTest, WhenMultipleModulesThenFail) {
- const char blob[] = {
- 'B', 'C', 0xc0, 0xde,
- 0x21, 0x0c, 0x00, 0x00, // Enter sub-block, BlockID = 8, Code Size=3, padding x2
- 0x00, 0x00, 0x00, 0x00, // NumWords = 0
- 0x08, 0x00, 0x00, 0x00, // End-of-block, padding
- // At this point, this is valid bitcode (but missing required DXIL metadata)
- // Trigger the case we're looking for now
- 0x21, 0x0c, 0x00, 0x00, // Enter sub-block, BlockID = 8, Code Size=3, padding x2
- };
- CheckValidationMsg(blob, _countof(blob), "Unused bits in buffer");
- }
- TEST_F(ValidationTest, WhenUnexpectedEOFThenFail) {
- // Importantly, this is testing the usage of report_fatal_error during deserialization.
- const char blob[] = {
- 'B', 'C', 0xc0, 0xde,
- 0x21, 0x0c, 0x00, 0x00, // Enter sub-block, BlockID = 8, Code Size=3, padding x2
- 0x00, 0x00, 0x00, 0x00, // NumWords = 0
- };
- CheckValidationMsg(blob, _countof(blob), "Invalid record");
- }
- TEST_F(ValidationTest, WhenUnknownBlocksThenFail) {
- const char blob[] = {
- 'B', 'C', 0xc0, 0xde, // Signature
- 0x31, 0x00, 0x00, 0x00 // Enter sub-block, BlockID != 8
- };
- CheckValidationMsg(blob, _countof(blob), "Unrecognized block found");
- }
- TEST_F(ValidationTest, WhenInstrDisallowedThenFail) {
- TestCheck(L"val-inst-disallowed.ll");
- }
- TEST_F(ValidationTest, WhenDepthNotFloatThenFail) {
- TestCheck(L"dxil_validation\\IntegerDepth.ll");
- }
- TEST_F(ValidationTest, BarrierFail) {
- TestCheck(L"dxil_validation\\barrier.ll");
- }
- TEST_F(ValidationTest, CBufferLegacyOutOfBoundFail) {
- TestCheck(L"dxil_validation\\cbuffer1.50_legacy.ll");
- }
- TEST_F(ValidationTest, CBufferOutOfBoundFail) {
- TestCheck(L"dxil_validation\\cbuffer1.50.ll");
- }
- TEST_F(ValidationTest, CsThreadSizeFail) {
- TestCheck(L"dxil_validation\\csThreadSize.ll");
- }
- TEST_F(ValidationTest, DeadLoopFail) {
- TestCheck(L"dxil_validation\\deadloop.ll");
- }
- TEST_F(ValidationTest, EvalFail) {
- TestCheck(L"dxil_validation\\Eval.ll");
- }
- TEST_F(ValidationTest, GetDimCalcLODFail) {
- TestCheck(L"dxil_validation\\GetDimCalcLOD.ll");
- }
- TEST_F(ValidationTest, HsAttributeFail) {
- TestCheck(L"dxil_validation\\hsAttribute.ll");
- }
- TEST_F(ValidationTest, InnerCoverageFail) {
- TestCheck(L"dxil_validation\\InnerCoverage.ll");
- }
- TEST_F(ValidationTest, InterpChangeFail) {
- TestCheck(L"dxil_validation\\interpChange.ll");
- }
- TEST_F(ValidationTest, InterpOnIntFail) {
- TestCheck(L"dxil_validation\\interpOnInt.ll");
- }
- TEST_F(ValidationTest, InvalidSigCompTyFail) {
- TestCheck(L"dxil_validation\\invalidSigCompTy.ll");
- }
- TEST_F(ValidationTest, MultiStream2Fail) {
- TestCheck(L"dxil_validation\\multiStream2.ll");
- }
- TEST_F(ValidationTest, PhiTGSMFail) {
- TestCheck(L"dxil_validation\\phiTGSM.ll");
- }
- TEST_F(ValidationTest, ReducibleFail) {
- TestCheck(L"dxil_validation\\reducible.ll");
- }
- TEST_F(ValidationTest, SampleBiasFail) {
- TestCheck(L"dxil_validation\\sampleBias.ll");
- }
- TEST_F(ValidationTest, SamplerKindFail) {
- TestCheck(L"dxil_validation\\samplerKind.ll");
- }
- TEST_F(ValidationTest, SemaOverlapFail) {
- TestCheck(L"dxil_validation\\semaOverlap.ll");
- }
- TEST_F(ValidationTest, SigOutOfRangeFail) {
- TestCheck(L"dxil_validation\\sigOutOfRange.ll");
- }
- TEST_F(ValidationTest, SigOverlapFail) {
- TestCheck(L"dxil_validation\\sigOverlap.ll");
- }
- TEST_F(ValidationTest, SimpleHs1Fail) {
- TestCheck(L"dxil_validation\\SimpleHs1.ll");
- }
- TEST_F(ValidationTest, SimpleHs3Fail) {
- TestCheck(L"dxil_validation\\SimpleHs3.ll");
- }
- TEST_F(ValidationTest, SimpleHs4Fail) {
- TestCheck(L"dxil_validation\\SimpleHs4.ll");
- }
- TEST_F(ValidationTest, SimpleDs1Fail) {
- TestCheck(L"dxil_validation\\SimpleDs1.ll");
- }
- TEST_F(ValidationTest, SimpleGs1Fail) {
- TestCheck(L"dxil_validation\\SimpleGs1.ll");
- }
- TEST_F(ValidationTest, UavBarrierFail) {
- TestCheck(L"dxil_validation\\uavBarrier.ll");
- }
- TEST_F(ValidationTest, UndefValueFail) {
- TestCheck(L"dxil_validation\\UndefValue.ll");
- }
- TEST_F(ValidationTest, UpdateCounterFail) {
- TestCheck(L"dxil_validation\\UpdateCounter.ll");
- }
- TEST_F(ValidationTest, WhenIncorrectModelThenFail) {
- TestCheck(L"val-failures.hlsl");
- }
- TEST_F(ValidationTest, WhenIncorrectPSThenFail) {
- TestCheck(L"val-failures-ps.hlsl");
- }
- TEST_F(ValidationTest, WhenSmUnknownThenFail) {
- RewriteAssemblyCheckMsg("float4 main() : SV_Target { return 1; }", "ps_6_0",
- "{!\"ps\", i32 6, i32 0}", "{!\"ps\", i32 1, i32 2}",
- "Unknown shader model 'ps_1_2'");
- }
- TEST_F(ValidationTest, WhenSmLegacyThenFail) {
- RewriteAssemblyCheckMsg("float4 main() : SV_Target { return 1; }", "ps_6_0",
- "{!\"ps\", i32 6, i32 0}", "{!\"ps\", i32 5, i32 1}",
- "Unknown shader model 'ps_5_1'");
- }
- TEST_F(ValidationTest, WhenMetaFlagsUsageDeclThenOK) {
- RewriteAssemblyCheckMsg(
- "uint u; float4 main() : SV_Target { uint64_t n = u; n *= u; return (uint)(n >> 32); }", "ps_6_0",
- "1048576", "1048577", // inhibit optimization, which should work fine
- nullptr);
- }
- TEST_F(ValidationTest, GsVertexIDOutOfBound) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleGs1.hlsl", "gs_6_0",
- "dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 2, i32 0)",
- "dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 2, i32 1)",
- "expect VertexID between 0~1, got 1");
- }
- TEST_F(ValidationTest, StreamIDOutOfBound) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleGs1.hlsl", "gs_6_0",
- "dx.op.emitStream(i32 97, i8 0)",
- "dx.op.emitStream(i32 97, i8 1)",
- "expect StreamID between 0 , got 1");
- }
- TEST_F(ValidationTest, SignatureStreamIDForNonGS) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\abs1.hlsl", "ps_6_0",
- ", i8 0, i32 1, i8 4, i32 0, i8 0, null}",
- ", i8 0, i32 1, i8 4, i32 0, i8 0, !19}\n!19 = !{i32 0, i32 1}",
- "Stream index (1) must between 0 and 0");
- }
- TEST_F(ValidationTest, TypedUAVStoreFullMask0) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\uav_typed_store.hlsl", "ps_6_0",
- "float 2.000000e+00, i8 15)",
- "float 2.000000e+00, i8 undef)",
- "Mask of TextureStore must be an immediate constant");
- }
- TEST_F(ValidationTest, TypedUAVStoreFullMask1) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\uav_typed_store.hlsl", "ps_6_0",
- "float 3.000000e+00, i8 15)",
- "float 3.000000e+00, i8 undef)",
- "Mask of BufferStore must be an immediate constant");
- }
- TEST_F(ValidationTest, Recursive) {
- TestCheck(L"..\\CodeGenHLSL\\recursive.hlsl");
- }
- TEST_F(ValidationTest, Recursive2) {
- TestCheck(L"..\\CodeGenHLSL\\recursive2.hlsl");
- }
- TEST_F(ValidationTest, UserDefineFunction) {
- TestCheck(L"..\\CodeGenHLSL\\recursive2.hlsl");
- }
- TEST_F(ValidationTest, ResourceRangeOverlap0) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\resource_overlap.hlsl", "ps_6_0",
- "!\"B\", i32 0, i32 1",
- "!\"B\", i32 0, i32 0",
- "Resource B with base 0 size 1 overlap");
- }
- TEST_F(ValidationTest, ResourceRangeOverlap1) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\resource_overlap.hlsl", "ps_6_0",
- "!\"s1\", i32 0, i32 1",
- "!\"s1\", i32 0, i32 0",
- "Resource s1 with base 0 size 1 overlap");
- }
- TEST_F(ValidationTest, ResourceRangeOverlap2) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\resource_overlap.hlsl", "ps_6_0",
- "!\"uav2\", i32 0, i32 0",
- "!\"uav2\", i32 0, i32 3",
- "Resource uav2 with base 3 size 1 overlap");
- }
- TEST_F(ValidationTest, ResourceRangeOverlap3) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\resource_overlap.hlsl", "ps_6_0",
- "!\"srv2\", i32 0, i32 1",
- "!\"srv2\", i32 0, i32 0",
- "Resource srv2 with base 0 size 1 overlap");
- }
- TEST_F(ValidationTest, CBufferOverlap0) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\cbufferOffset.hlsl", "ps_6_0",
- "i32 6, !\"g2\", i32 3, i32 0",
- "i32 6, !\"g2\", i32 3, i32 8",
- "CBuffer Foo1 has offset overlaps at 16");
- }
- TEST_F(ValidationTest, CBufferOverlap1) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\cbufferOffset.hlsl", "ps_6_0",
- " = !{i32 32, !",
- " = !{i32 16, !",
- "CBuffer Foo1 size insufficient for element at offset 16");
- }
- TEST_F(ValidationTest, ControlFlowHint) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\if1.hlsl", "ps_6_0",
- "!\"dx.controlflow.hints\", i32 1",
- "!\"dx.controlflow.hints\", i32 5",
- "Attribute forcecase only works for switch");
- }
- TEST_F(ValidationTest, ControlFlowHint1) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\if1.hlsl", "ps_6_0",
- "!\"dx.controlflow.hints\", i32 1",
- "!\"dx.controlflow.hints\", i32 1, i32 2",
- "Can't use branch and flatten attributes together");
- }
- TEST_F(ValidationTest, ControlFlowHint2) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\if1.hlsl", "ps_6_0",
- "!\"dx.controlflow.hints\", i32 1",
- "!\"dx.controlflow.hints\", i32 3",
- "Invalid control flow hint");
- }
- TEST_F(ValidationTest, SemanticLength1) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\binary1.hlsl", "ps_6_0",
- "!\"C\"",
- "!\"\"",
- "Semantic length must be at least 1 and at most 64");
- }
- TEST_F(ValidationTest, SemanticLength64) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\binary1.hlsl", "ps_6_0",
- "!\"C\"",
- "!\"CSESESESESESESESESESESESESESESESESESESESESESESESESESESESESESESESE\"",
- "Semantic length must be at least 1 and at most 64");
- }
- TEST_F(ValidationTest, PullModelPosition) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\eval.hlsl", "ps_6_0",
- "!\"A\", i8 9, i8 0",
- "!\"SV_Position\", i8 9, i8 3",
- "does not support pull-model evaluation of position");
- }
- TEST_F(ValidationTest, StructBufGlobalCoherentAndCounter) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\struct_buf1.hlsl", "ps_6_0",
- "!\"buf2\", i32 0, i32 0, i32 1, i32 12, i1 false, i1 false",
- "!\"buf2\", i32 0, i32 0, i32 1, i32 12, i1 true, i1 true",
- "globallycoherent cannot be used with append/consume buffers'buf2'");
- }
- TEST_F(ValidationTest, StructBufStrideAlign) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\struct_buf1.hlsl", "ps_6_0",
- "!7 = !{i32 1, i32 52}",
- "!7 = !{i32 1, i32 50}",
- "structured buffer element size must be a multiple of 4 bytes (actual size 50 bytes)");
- }
- TEST_F(ValidationTest, StructBufStrideOutOfBound) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\struct_buf1.hlsl", "ps_6_0",
- "!7 = !{i32 1, i32 52}",
- "!7 = !{i32 1, i32 2052}",
- "structured buffer elements cannot be larger than 2048 bytes (actual size 2052 bytes)");
- }
- TEST_F(ValidationTest, StructBufLoadCoordinates) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\struct_buf1.hlsl", "ps_6_0",
- "bufferLoad.f32(i32 69, %dx.types.Handle %buf1_texture_structbuf, i32 1, i32 8)",
- "bufferLoad.f32(i32 69, %dx.types.Handle %buf1_texture_structbuf, i32 1, i32 undef)",
- "structured buffer require 2 coordinates");
- }
- TEST_F(ValidationTest, StructBufStoreCoordinates) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\struct_buf1.hlsl", "ps_6_0",
- "bufferStore.f32(i32 70, %dx.types.Handle %buf2_UAV_structbuf, i32 0, i32 0",
- "bufferStore.f32(i32 70, %dx.types.Handle %buf2_UAV_structbuf, i32 0, i32 undef",
- "structured buffer require 2 coordinates");
- }
- TEST_F(ValidationTest, TypedBufRetType) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\sample5.hlsl", "ps_6_0",
- "%class.Texture2D = type { <4 x float>",
- "%class.Texture2D = type { <4 x double>",
- "elements of typed buffers and textures must fit in four 32-bit quantities");
- }
- TEST_F(ValidationTest, VsInputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\clip_planes.hlsl", "vs_6_0",
- "!\"POSITION\", i8 9, i8 0",
- "!\"SV_Target\", i8 9, i8 16",
- "Semantic 'SV_Target' is invalid as vs Input");
- }
- TEST_F(ValidationTest, VsOutputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\clip_planes.hlsl", "vs_6_0",
- "!\"NORMAL\", i8 9, i8 0",
- "!\"SV_Target\", i8 9, i8 16",
- "Semantic 'SV_Target' is invalid as vs Output");
- }
- TEST_F(ValidationTest, HsInputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleHs1.hlsl", "hs_6_0",
- "!\"TEXCOORD\", i8 9, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as hs Input");
- }
- TEST_F(ValidationTest, HsOutputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleHs1.hlsl", "hs_6_0",
- "!\"TEXCOORD\", i8 9, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as hs Output");
- }
- TEST_F(ValidationTest, PatchConstSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleHs1.hlsl", "hs_6_0",
- "!\"SV_TessFactor\", i8 9, i8 25",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as hs PatchConstant");
- }
- TEST_F(ValidationTest, DsInputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleDs1.hlsl", "ds_6_0",
- "!\"TEXCOORD\", i8 9, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as ds Input");
- }
- TEST_F(ValidationTest, DsOutputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleDs1.hlsl", "ds_6_0",
- "!\"TEXCOORD\", i8 9, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as ds Output");
- }
- TEST_F(ValidationTest, GsInputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleGs1.hlsl", "gs_6_0",
- "!\"POSSIZE\", i8 9, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as gs Input");
- }
- TEST_F(ValidationTest, GsOutputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\SimpleGs1.hlsl", "gs_6_0",
- "!\"TEXCOORD\", i8 9, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as gs Output");
- }
- TEST_F(ValidationTest, PsInputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\abs2.hlsl", "ps_6_0",
- "!\"A\", i8 4, i8 0",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as ps Input");
- }
- TEST_F(ValidationTest, PsOutputSemantic) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\abs2.hlsl", "ps_6_0",
- "!\"SV_Target\", i8 9, i8 16",
- "!\"VertexID\", i8 4, i8 1",
- "Semantic 'VertexID' is invalid as ps Output");
- }
- TEST_F(ValidationTest, ArrayOfSVTarget) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\targetArray.hlsl", "ps_6_0",
- "i32 6, !\"SV_Target\", i8 9, i8 16, !36, i8 0, i32 1",
- "i32 6, !\"SV_Target\", i8 9, i8 16, !36, i8 0, i32 2",
- "Pixel shader output registers are not indexable.");
- }
- TEST_F(ValidationTest, InfiniteLog) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\intrinsic_val_imm.hlsl", "ps_6_0",
- "op.unary.f32(i32 22, float %3)",
- "op.unary.f32(i32 22, float 0x7FF0000000000000)",
- "No indefinite logarithm");
- }
- TEST_F(ValidationTest, InfiniteAsin) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\intrinsic_val_imm.hlsl", "ps_6_0",
- "op.unary.f32(i32 16, float %3)",
- "op.unary.f32(i32 16, float 0x7FF0000000000000)",
- "No indefinite arcsine");
- }
- TEST_F(ValidationTest, InfiniteAcos) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\intrinsic_val_imm.hlsl", "ps_6_0",
- "op.unary.f32(i32 15, float %3)",
- "op.unary.f32(i32 15, float 0x7FF0000000000000)",
- "No indefinite arccosine");
- }
- TEST_F(ValidationTest, InfiniteDdxDdy) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\intrinsic_val_imm.hlsl", "ps_6_0",
- "op.unary.f32(i32 86, float %3)",
- "op.unary.f32(i32 86, float 0x7FF0000000000000)",
- "No indefinite derivative calculation");
- }
- TEST_F(ValidationTest, IDivByZero) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\intrinsic_val_imm.hlsl", "ps_6_0",
- "sdiv i32 %8, %9",
- "sdiv i32 %8, 0",
- "No signed integer division by zero");
- }
- TEST_F(ValidationTest, UDivByZero) {
- RewriteAssemblyCheckMsg(
- L"..\\CodeGenHLSL\\intrinsic_val_imm.hlsl", "ps_6_0",
- "udiv i32 %5, %6",
- "udiv i32 %5, 0",
- "No unsigned integer division by zero");
- }
- TEST_F(ValidationTest, UnusedMetadata) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\loop2.hlsl", "ps_6_0",
- ", !llvm.loop ",
- ", !llvm.loop2 ",
- "All metadata must be used by dxil");
- }
- TEST_F(ValidationTest, MemoryOutOfBound) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\targetArray.hlsl", "ps_6_0",
- "getelementptr [4 x float], [4 x float]* %12, i32 0, i32 3",
- "getelementptr [4 x float], [4 x float]* %12, i32 0, i32 10",
- "Access to out-of-bounds memory is disallowed");
- }
- TEST_F(ValidationTest, AddrSpaceCast) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\staticGlobals.hlsl", "ps_6_0",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " store float %11, float* %12, align 4",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " %X = addrspacecast float* %12 to float addrspace(1)* \n"
- " store float %11, float addrspace(1)* %X, align 4",
- "generic address space");
- }
- TEST_F(ValidationTest, PtrBitCast) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\staticGlobals.hlsl", "ps_6_0",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " store float %11, float* %12, align 4",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " %X = bitcast float* %12 to double* \n"
- " store float %11, float* %12, align 4",
- "Pointer type bitcast must be have same size");
- }
- TEST_F(ValidationTest, MinPrecisionBitCast) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\staticGlobals.hlsl", "ps_6_0",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " store float %11, float* %12, align 4",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " %X = bitcast float* %12 to [2 x half]* \n"
- " store float %11, float* %12, align 4",
- "Bitcast on minprecison types is not allowed");
- }
- TEST_F(ValidationTest, StructBitCast) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\staticGlobals.hlsl", "ps_6_0",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " store float %11, float* %12, align 4",
- "%12 = getelementptr [4 x float], [4 x float]* %1, i32 0, i32 0\n"
- " %X = bitcast float* %12 to %dx.types.Handle* \n"
- " store float %11, float* %12, align 4",
- "Bitcast on struct types is not allowed");
- }
- TEST_F(ValidationTest, MultiDimArray) {
- RewriteAssemblyCheckMsg(L"..\\CodeGenHLSL\\staticGlobals.hlsl", "ps_5_0",
- "%1 = alloca [4 x float]",
- "%1 = alloca [4 x float]\n"
- " %md = alloca [2 x [4 x float]]",
- "Only one dimension allowed for array type");
- }
- TEST_F(ValidationTest, WhenWaveAffectsGradientThenFail) {
- TestCheck(L"val-wave-failures-ps.hlsl");
- }
- TEST_F(ValidationTest, WhenMetaFlagsUsageThenFail) {
- RewriteAssemblyCheckMsg(
- "uint u; float4 main() : SV_Target { uint64_t n = u; n *= u; return (uint)(n >> 32); }", "ps_6_0",
- "1048576", "0", // remove the int64 flag
- "Flags must match usage");
- }
- TEST_F(ValidationTest, StorePatchControlNotInPatchConstantFunction) {
- RewriteAssemblyCheckMsg(
- "struct PSSceneIn \
- { \
- float4 pos : SV_Position; \
- float2 tex : TEXCOORD0; \
- float3 norm : NORMAL; \
- }; \
- \
- struct HSPerVertexData \
- { \
- PSSceneIn v; \
- }; \
- struct HSPerPatchData \
- { \
- float edges[ 3 ] : SV_TessFactor; \
- float inside : SV_InsideTessFactor; \
- }; \
- HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points, \
- OutputPatch<HSPerVertexData, 3> outpoints) \
- { \
- HSPerPatchData d; \
- \
- d.edges[ 0 ] = points[0].tex.x + outpoints[0].v.tex.x; \
- d.edges[ 1 ] = 1; \
- d.edges[ 2 ] = 1; \
- d.inside = 1; \
- \
- return d; \
- }\
- [domain(\"tri\")]\
- [partitioning(\"fractional_odd\")]\
- [outputtopology(\"triangle_cw\")]\
- [patchconstantfunc(\"HSPerPatchFunc\")]\
- [outputcontrolpoints(3)]\
- HSPerVertexData main( const uint id : SV_OutputControlPointID,\
- const InputPatch< PSSceneIn, 3 > points )\
- {\
- HSPerVertexData v;\
- \
- v.v = points[ id ];\
- \
- return v;\
- }\
- ",
- "hs_6_0",
- "dx.op.storeOutput.f32(i32 5",
- "dx.op.storePatchConstant.f32(i32 109",
- "opcode 'StorePatchConstant' should only used in 'PatchConstant function'");
- }
- TEST_F(ValidationTest, LoadOutputControlPointNotInPatchConstantFunction) {
- RewriteAssemblyCheckMsg(
- "struct PSSceneIn \
- { \
- float4 pos : SV_Position; \
- float2 tex : TEXCOORD0; \
- float3 norm : NORMAL; \
- }; \
- \
- struct HSPerVertexData \
- { \
- PSSceneIn v; \
- }; \
- struct HSPerPatchData \
- { \
- float edges[ 3 ] : SV_TessFactor; \
- float inside : SV_InsideTessFactor; \
- }; \
- HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points, \
- OutputPatch<HSPerVertexData, 3> outpoints) \
- { \
- HSPerPatchData d; \
- \
- d.edges[ 0 ] = points[0].tex.x + outpoints[0].v.tex.x; \
- d.edges[ 1 ] = 1; \
- d.edges[ 2 ] = 1; \
- d.inside = 1; \
- \
- return d; \
- }\
- [domain(\"tri\")]\
- [partitioning(\"fractional_odd\")]\
- [outputtopology(\"triangle_cw\")]\
- [patchconstantfunc(\"HSPerPatchFunc\")]\
- [outputcontrolpoints(3)]\
- HSPerVertexData main( const uint id : SV_OutputControlPointID,\
- const InputPatch< PSSceneIn, 3 > points )\
- {\
- HSPerVertexData v;\
- \
- v.v = points[ id ];\
- \
- return v;\
- }\
- ",
- "hs_6_0",
- "dx.op.loadInput.f32(i32 4",
- "dx.op.loadOutputControlPoint.f32(i32 106",
- "opcode 'LoadOutputControlPoint' should only used in 'PatchConstant function'");
- }
- TEST_F(ValidationTest, OutputControlPointIDInPatchConstantFunction) {
- RewriteAssemblyCheckMsg(
- "struct PSSceneIn \
- { \
- float4 pos : SV_Position; \
- float2 tex : TEXCOORD0; \
- float3 norm : NORMAL; \
- }; \
- \
- struct HSPerVertexData \
- { \
- PSSceneIn v; \
- }; \
- struct HSPerPatchData \
- { \
- float edges[ 3 ] : SV_TessFactor; \
- float inside : SV_InsideTessFactor; \
- }; \
- HSPerPatchData HSPerPatchFunc( const InputPatch< PSSceneIn, 3 > points, \
- OutputPatch<HSPerVertexData, 3> outpoints) \
- { \
- HSPerPatchData d; \
- \
- d.edges[ 0 ] = points[0].tex.x + outpoints[0].v.tex.x; \
- d.edges[ 1 ] = 1; \
- d.edges[ 2 ] = 1; \
- d.inside = 1; \
- \
- return d; \
- }\
- [domain(\"tri\")]\
- [partitioning(\"fractional_odd\")]\
- [outputtopology(\"triangle_cw\")]\
- [patchconstantfunc(\"HSPerPatchFunc\")]\
- [outputcontrolpoints(3)]\
- HSPerVertexData main( const uint id : SV_OutputControlPointID,\
- const InputPatch< PSSceneIn, 3 > points )\
- {\
- HSPerVertexData v;\
- \
- v.v = points[ id ];\
- \
- return v;\
- }\
- ",
- "hs_6_0",
- "ret void",
- "call i32 @dx.op.outputControlPointID.i32(i32 110)\n ret void",
- "opcode 'OutputControlPointID' should only used in 'hull function'");
- }
- TEST_F(ValidationTest, ClipCullMaxComponents) {
- RewriteAssemblyCheckMsg(" \
- struct VSOut { \
- float3 clip0 : SV_ClipDistance; \
- float3 clip1 : SV_ClipDistance1; \
- float cull0 : SV_CullDistance; \
- float cull1 : SV_CullDistance1; \
- float cull2 : CullDistance2; \
- }; \
- VSOut main() { \
- VSOut Out; \
- Out.clip0 = 0.1; \
- Out.clip1 = 0.2; \
- Out.cull0 = 0.3; \
- Out.cull1 = 0.4; \
- Out.cull2 = 0.5; \
- return Out; \
- } \
- ",
- "vs_6_0",
- "!{i32 4, !\"CullDistance\", i8 9, i8 0,",
- "!{i32 4, !\"SV_CullDistance\", i8 9, i8 7,",
- "ClipDistance and CullDistance use more than the maximum of 8 components combined.");
- }
- TEST_F(ValidationTest, ClipCullMaxRows) {
- RewriteAssemblyCheckMsg(" \
- struct VSOut { \
- float3 clip0 : SV_ClipDistance; \
- float3 clip1 : SV_ClipDistance1; \
- float2 cull0 : CullDistance; \
- }; \
- VSOut main() { \
- VSOut Out; \
- Out.clip0 = 0.1; \
- Out.clip1 = 0.2; \
- Out.cull0 = 0.3; \
- return Out; \
- } \
- ",
- "vs_6_0",
- "!{i32 2, !\"CullDistance\", i8 9, i8 0,",
- "!{i32 2, !\"SV_CullDistance\", i8 9, i8 7,",
- "ClipDistance and CullDistance occupy more than the maximum of 2 rows combined.");
- }
- TEST_F(ValidationTest, DuplicateSysValue) {
- RewriteAssemblyCheckMsg(" \
- float4 main(uint vid : SV_VertexID, uint iid : SV_InstanceID) : SV_Position { \
- return (float4)0 + vid + iid; \
- } \
- ",
- "vs_6_0",
- "!{i32 1, !\"SV_InstanceID\", i8 5, i8 2,",
- "!{i32 1, !\"\", i8 5, i8 1,",
- //"System value SV_VertexID appears more than once in the same signature.");
- "Semantic 'SV_VertexID' overlap at 0");
- }
- TEST_F(ValidationTest, SemTargetMax) {
- RewriteAssemblyCheckMsg(" \
- float4 main(float4 col : COLOR) : SV_Target7 { return col; } \
- ",
- "ps_6_0",
- "!{i32 0, !\"SV_Target\", i8 9, i8 16, ![0-9]+, i8 0, i32 1, i8 4, i32 7, i8 0, null}",
- "!{i32 0, !\"SV_Target\", i8 9, i8 16, !101, i8 0, i32 1, i8 4, i32 8, i8 0, null}\n!101 = !{i32 8}",
- "SV_Target semantic index exceeds maximum \\(7\\)",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemTargetIndexMatchesRow) {
- RewriteAssemblyCheckMsg(" \
- float4 main(float4 col : COLOR) : SV_Target7 { return col; } \
- ",
- "ps_6_0",
- "!{i32 0, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 4, i32 7, i8 0, null}",
- "!{i32 0, !\"SV_Target\", i8 9, i8 16, !\\1, i8 0, i32 1, i8 4, i32 6, i8 0, null}",
- "SV_Target semantic index must match packed row location",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemTargetCol0) {
- RewriteAssemblyCheckMsg(" \
- float3 main(float4 col : COLOR) : SV_Target7 { return col.xyz; } \
- ",
- "ps_6_0",
- "!{i32 0, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 3, i32 7, i8 0, null}",
- "!{i32 0, !\"SV_Target\", i8 9, i8 16, !\\1, i8 0, i32 1, i8 3, i32 7, i8 1, null}",
- "SV_Target packed location must start at column 0",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemIndexMax) {
- RewriteAssemblyCheckMsg(" \
- float4 main(uint vid : SV_VertexID, uint iid : SV_InstanceID) : SV_Position { \
- return (float4)0 + vid + iid; \
- } \
- ",
- "vs_6_0",
- "!{i32 0, !\"SV_VertexID\", i8 5, i8 1, ![0-9]+, i8 0, i32 1, i8 1, i32 0, i8 0, null}",
- "!{i32 0, !\"SV_VertexID\", i8 5, i8 1, !101, i8 0, i32 1, i8 1, i32 0, i8 0, null}\n!101 = !{i32 1}",
- "SV_VertexID semantic index exceeds maximum \\(0\\)",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemTessFactorIndexMax) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 3 ] : SV_TessFactor; \
- float inside : SV_InsideTessFactor; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 3> patch) { \
- PatchConstant PC; \
- PC.edges = (float[3])patch[1].pos.xyz; \
- PC.inside = patch[1].pos.w; \
- return PC; \
- } \
- [domain(\"tri\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(3)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 3 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- "!{i32 0, !\"SV_TessFactor\", i8 9, i8 25, ![0-9]+, i8 0, i32 3, i8 1, i32 0, i8 3, null}",
- "!{i32 0, !\"SV_TessFactor\", i8 9, i8 25, !101, i8 0, i32 2, i8 1, i32 0, i8 3, null}\n!101 = !{i32 0, i32 1}",
- "TessFactor rows, columns \\(2, 1\\) invalid for domain Tri. Expected 3 rows and 1 column.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemInsideTessFactorIndexMax) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 3 ] : SV_TessFactor; \
- float inside : SV_InsideTessFactor; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 3> patch) { \
- PatchConstant PC; \
- PC.edges = (float[3])patch[1].pos.xyz; \
- PC.inside = patch[1].pos.w; \
- return PC; \
- } \
- [domain(\"tri\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(3)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 3 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- "!{i32 1, !\"SV_InsideTessFactor\", i8 9, i8 26, !([0-9]+), i8 0, i32 1, i8 1, i32 3, i8 0, null}",
- "!{i32 1, !\"SV_InsideTessFactor\", i8 9, i8 26, !\\1, i8 0, i32 2, i8 1, i32 3, i8 0, null}",
- "InsideTessFactor rows, columns \\(2, 1\\) invalid for domain Tri. Expected 1 rows and 1 column.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemShouldBeAllocated) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 3 ] : SV_TessFactor; \
- float inside : SV_InsideTessFactor; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 3> patch) { \
- PatchConstant PC; \
- PC.edges = (float[3])patch[1].pos.xyz; \
- PC.inside = patch[1].pos.w; \
- return PC; \
- } \
- [domain(\"tri\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(3)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 3 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- "!{i32 0, !\"SV_TessFactor\", i8 9, i8 25, !([0-9]+), i8 0, i32 3, i8 1, i32 0, i8 3, null}",
- "!{i32 0, !\"SV_TessFactor\", i8 9, i8 25, !\\1, i8 0, i32 3, i8 1, i32 -1, i8 -1, null}",
- "PatchConstant Semantic 'SV_TessFactor' should have a valid packing location",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemShouldNotBeAllocated) {
- RewriteAssemblyCheckMsg(" \
- float4 main(float4 col : COLOR, out uint coverage : SV_Coverage) : SV_Target7 { coverage = 7; return col; } \
- ",
- "ps_6_0",
- "!\"SV_Coverage\", i8 5, i8 14, !([0-9]+), i8 0, i32 1, i8 1, i32 -1, i8 -1, null}",
- "!\"SV_Coverage\", i8 5, i8 14, !\\1, i8 0, i32 1, i8 1, i32 2, i8 0, null}",
- "Output Semantic 'SV_Coverage' should have a packing location of -1",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemComponentOrder) {
- RewriteAssemblyCheckMsg(" \
- void main( \
- float2 f2in : f2in, \
- float3 f3in : f3in, \
- uint vid : SV_VertexID, \
- uint iid : SV_InstanceID, \
- out float4 pos : SV_Position, \
- out float2 f2out : f2out, \
- out float3 f3out : f3out, \
- out float2 ClipDistance : SV_ClipDistance, \
- out float CullDistance : SV_CullDistance) \
- { \
- pos = float4(f3in, f2in.x); \
- ClipDistance = f2in.x; \
- CullDistance = f2in.y; \
- } \
- ",
- "vs_6_0",
- "= !{i32 1, !\"f2out\", i8 9, i8 0, !([0-9]+), i8 2, i32 1, i8 2, i32 2, i8 0, null}\n"
- "!([0-9]+) = !{i32 2, !\"f3out\", i8 9, i8 0, !([0-9]+), i8 2, i32 1, i8 3, i32 1, i8 0, null}\n"
- "!([0-9]+) = !{i32 3, !\"SV_ClipDistance\", i8 9, i8 6, !([0-9]+), i8 2, i32 1, i8 2, i32 3, i8 0, null}\n"
- "!([0-9]+) = !{i32 4, !\"SV_CullDistance\", i8 9, i8 7, !([0-9]+), i8 2, i32 1, i8 1, i32 3, i8 2, null}\n",
- "= !{i32 1, !\"f2out\", i8 9, i8 0, !\\1, i8 2, i32 1, i8 2, i32 2, i8 2, null}\n"
- "!\\2 = !{i32 2, !\"f3out\", i8 9, i8 0, !\\3, i8 2, i32 1, i8 3, i32 1, i8 1, null}\n"
- "!\\4 = !{i32 3, !\"SV_ClipDistance\", i8 9, i8 6, !\\5, i8 2, i32 1, i8 2, i32 2, i8 0, null}\n"
- "!\\6 = !{i32 4, !\"SV_CullDistance\", i8 9, i8 7, !\\7, i8 2, i32 1, i8 1, i32 1, i8 0, null}\n",
- "signature element SV_ClipDistance at location \\(2,0\\) size \\(1,2\\) violates component ordering rule \\(arb < sv < sgv\\).\n"
- "signature element SV_CullDistance at location \\(1,0\\) size \\(1,1\\) violates component ordering rule \\(arb < sv < sgv\\).",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemComponentOrder2) {
- RewriteAssemblyCheckMsg(" \
- float4 main( \
- float4 col : Color, \
- uint2 val : Value, \
- uint pid : SV_PrimitiveID, \
- bool ff : SV_IsFrontFace) : SV_Target \
- { \
- return col; \
- } \
- ",
- "ps_6_0",
- "= !{i32 1, !\"Value\", i8 5, i8 0, !([0-9]+), i8 1, i32 1, i8 2, i32 1, i8 0, null}\n"
- "!([0-9]+) = !{i32 2, !\"SV_PrimitiveID\", i8 5, i8 10, !([0-9]+), i8 1, i32 1, i8 1, i32 1, i8 2, null}\n"
- "!([0-9]+) = !{i32 3, !\"SV_IsFrontFace\", i8 1, i8 13, !([0-9]+), i8 1, i32 1, i8 1, i32 1, i8 3, null}\n",
- "= !{i32 1, !\"Value\", i8 5, i8 0, !\\1, i8 1, i32 1, i8 2, i32 1, i8 2, null}\n"
- "!\\2 = !{i32 2, !\"SV_PrimitiveID\", i8 5, i8 10, !\\3, i8 1, i32 1, i8 1, i32 1, i8 0, null}\n"
- "!\\4 = !{i32 3, !\"SV_IsFrontFace\", i8 1, i8 13, !\\5, i8 1, i32 1, i8 1, i32 1, i8 1, null}\n",
- "signature element SV_PrimitiveID at location \\(1,0\\) size \\(1,1\\) violates component ordering rule \\(arb < sv < sgv\\).\n"
- "signature element SV_IsFrontFace at location \\(1,1\\) size \\(1,1\\) violates component ordering rule \\(arb < sv < sgv\\).",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemComponentOrder3) {
- RewriteAssemblyCheckMsg(" \
- float4 main( \
- float4 col : Color, \
- uint val : Value, \
- uint pid : SV_PrimitiveID, \
- bool ff : SV_IsFrontFace, \
- uint vpid : ViewPortArrayIndex) : SV_Target \
- { \
- return col; \
- } \
- ",
- "ps_6_0",
- "= !{i32 1, !\"Value\", i8 5, i8 0, !([0-9]+), i8 1, i32 1, i8 1, i32 1, i8 0, null}\n"
- "!([0-9]+) = !{i32 2, !\"SV_PrimitiveID\", i8 5, i8 10, !([0-9]+), i8 1, i32 1, i8 1, i32 1, i8 2, null}\n"
- "!([0-9]+) = !{i32 3, !\"SV_IsFrontFace\", i8 1, i8 13, !([0-9]+), i8 1, i32 1, i8 1, i32 1, i8 3, null}\n"
- "!([0-9]+) = !{i32 4, !\"ViewPortArrayIndex\", i8 5, i8 0, !([0-9]+), i8 1, i32 1, i8 1, i32 1, i8 1, null}\n",
- "= !{i32 1, !\"Value\", i8 5, i8 0, !\\1, i8 1, i32 1, i8 1, i32 1, i8 1, null}\n"
- "!\\2 = !{i32 2, !\"SV_PrimitiveID\", i8 5, i8 10, !\\3, i8 1, i32 1, i8 1, i32 1, i8 0, null}\n"
- "!\\4 = !{i32 3, !\"SV_IsFrontFace\", i8 1, i8 13, !\\5, i8 1, i32 1, i8 1, i32 1, i8 2, null}\n"
- "!\\6 = !{i32 4, !\"ViewPortArrayIndex\", i8 5, i8 0, !\\7, i8 1, i32 1, i8 1, i32 1, i8 3, null}\n",
- "signature element SV_PrimitiveID at location \\(1,0\\) size \\(1,1\\) violates component ordering rule \\(arb < sv < sgv\\).\n"
- "signature element ViewPortArrayIndex at location \\(1,3\\) size \\(1,1\\) violates component ordering rule \\(arb < sv < sgv\\).",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemIndexConflictArbSV) {
- RewriteAssemblyCheckMsg(" \
- void main( \
- float4 inpos : Position, \
- uint iid : SV_InstanceID, \
- out float4 pos : SV_Position, \
- out uint id[2] : Array, \
- out uint vpid : SV_ViewPortArrayIndex, \
- out float2 ClipDistance : SV_ClipDistance, \
- out float CullDistance : SV_CullDistance) \
- { \
- pos = inpos; \
- ClipDistance = inpos.x; \
- CullDistance = inpos.y; \
- vpid = iid; \
- id[0] = iid; \
- id[1] = iid + 1; \
- } \
- ",
- "vs_6_0",
- "!{i32 2, !\"SV_ViewportArrayIndex\", i8 5, i8 5, !([0-9]+), i8 1, i32 1, i8 1, i32 3, i8 0, null}",
- "!{i32 2, !\"SV_ViewportArrayIndex\", i8 5, i8 5, !\\1, i8 1, i32 1, i8 1, i32 1, i8 3, null}",
- "signature element SV_ViewportArrayIndex at location \\(1,3\\) size \\(1,1\\) has an indexing conflict with another signature element packed into the same row.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemIndexConflictTessfactors) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 4 ] : SV_TessFactor; \
- float inside[ 2 ] : SV_InsideTessFactor; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 4> patch) { \
- PatchConstant PC; \
- PC.edges = (float[4])patch[1].pos; \
- PC.inside = (float[2])patch[1].pos.xy; \
- return PC; \
- } \
- [domain(\"quad\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(4)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 4 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- //!{i32 0, !"SV_TessFactor", i8 9, i8 25, !23, i8 0, i32 4, i8 1, i32 0, i8 3, null}
- "!{i32 1, !\"SV_InsideTessFactor\", i8 9, i8 26, !([0-9]+), i8 0, i32 2, i8 1, i32 4, i8 3, null}",
- "!{i32 1, !\"SV_InsideTessFactor\", i8 9, i8 26, !\\1, i8 0, i32 2, i8 1, i32 0, i8 2, null}",
- "signature element SV_InsideTessFactor at location \\(0,2\\) size \\(2,1\\) has an indexing conflict with another signature element packed into the same row.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemIndexConflictTessfactors2) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 4 ] : SV_TessFactor; \
- float inside[ 2 ] : SV_InsideTessFactor; \
- float arb [ 3 ] : Arb; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 4> patch) { \
- PatchConstant PC; \
- PC.edges = (float[4])patch[1].pos; \
- PC.inside = (float[2])patch[1].pos.xy; \
- PC.arb[0] = 1; PC.arb[1] = 2; PC.arb[2] = 3; \
- return PC; \
- } \
- [domain(\"quad\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(4)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 4 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- "!{i32 2, !\"Arb\", i8 9, i8 0, !([0-9]+), i8 0, i32 3, i8 1, i32 0, i8 0, null}",
- "!{i32 2, !\"Arb\", i8 9, i8 0, !\\1, i8 0, i32 3, i8 1, i32 2, i8 0, null}",
- "signature element Arb at location \\(2,0\\) size \\(3,1\\) has an indexing conflict with another signature element packed into the same row.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemRowOutOfRange) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 4 ] : SV_TessFactor; \
- float inside[ 2 ] : SV_InsideTessFactor; \
- float arb [ 3 ] : Arb; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 4> patch) { \
- PatchConstant PC; \
- PC.edges = (float[4])patch[1].pos; \
- PC.inside = (float[2])patch[1].pos.xy; \
- PC.arb[0] = 1; PC.arb[1] = 2; PC.arb[2] = 3; \
- return PC; \
- } \
- [domain(\"quad\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(4)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 4 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- "!{i32 2, !\"Arb\", i8 9, i8 0, !([0-9]+), i8 0, i32 3, i8 1, i32 0, i8 0, null}",
- "!{i32 2, !\"Arb\", i8 9, i8 0, !\\1, i8 0, i32 3, i8 1, i32 31, i8 0, null}",
- "signature element Arb at location \\(31,0\\) size \\(3,1\\) is out of range.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemPackOverlap) {
- RewriteAssemblyCheckMsg(" \
- struct Vertex { \
- float4 pos : SV_Position; \
- }; \
- struct PatchConstant { \
- float edges[ 4 ] : SV_TessFactor; \
- float inside[ 2 ] : SV_InsideTessFactor; \
- float arb [ 3 ] : Arb; \
- }; \
- PatchConstant PCMain( InputPatch<Vertex, 4> patch) { \
- PatchConstant PC; \
- PC.edges = (float[4])patch[1].pos; \
- PC.inside = (float[2])patch[1].pos.xy; \
- PC.arb[0] = 1; PC.arb[1] = 2; PC.arb[2] = 3; \
- return PC; \
- } \
- [domain(\"quad\")] \
- [partitioning(\"fractional_odd\")] \
- [outputtopology(\"triangle_cw\")] \
- [patchconstantfunc(\"PCMain\")] \
- [outputcontrolpoints(4)] \
- Vertex main(uint id : SV_OutputControlPointID, InputPatch< Vertex, 4 > patch) { \
- Vertex Out = patch[id]; \
- Out.pos.w += 0.25; \
- return Out; \
- } \
- ",
- "hs_6_0",
- "!{i32 2, !\"Arb\", i8 9, i8 0, !([0-9]+), i8 0, i32 3, i8 1, i32 0, i8 0, null}",
- "!{i32 2, !\"Arb\", i8 9, i8 0, !\\1, i8 0, i32 3, i8 1, i32 1, i8 3, null}",
- "signature element Arb at location \\(1,3\\) size \\(3,1\\) overlaps another signature element.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemPackOverlap2) {
- RewriteAssemblyCheckMsg(" \
- void main( \
- float4 inpos : Position, \
- uint iid : SV_InstanceID, \
- out float4 pos : SV_Position, \
- out uint id[2] : Array, \
- out uint3 value : Value, \
- out float2 ClipDistance : SV_ClipDistance, \
- out float CullDistance : SV_CullDistance) \
- { \
- pos = inpos; \
- ClipDistance = inpos.x; \
- CullDistance = inpos.y; \
- value = iid; \
- id[0] = iid; \
- id[1] = iid + 1; \
- } \
- ",
- "vs_6_0",
- "!{i32 1, !\"Array\", i8 5, i8 0, !([0-9]+), i8 1, i32 2, i8 1, i32 1, i8 0, null}\n"
- "!([0-9]+) = !{i32 2, !\"Value\", i8 5, i8 0, !([0-9]+), i8 1, i32 1, i8 3, i32 1, i8 1, null}",
- "!{i32 1, !\"Array\", i8 5, i8 0, !\\1, i8 1, i32 2, i8 1, i32 1, i8 1, null}\n"
- "!\\2 = !{i32 2, !\"Value\", i8 5, i8 0, !\\3, i8 1, i32 1, i8 3, i32 2, i8 0, null}",
- "signature element Value at location \\(2,0\\) size \\(1,3\\) overlaps another signature element.",
- /*bRegex*/true);
- }
- TEST_F(ValidationTest, SemMultiDepth) {
- RewriteAssemblyCheckMsg(" \
- float4 main(float4 f4 : Input, out float d0 : SV_Depth, out float d1 : SV_Target1) : SV_Target \
- { d0 = f4.z; d1 = f4.w; return f4; } \
- ",
- "ps_6_0",
- "!{i32 1, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 1, i32 1, i8 0, null}\n"
- "!([0-9]+) = !{i32 2, !\"SV_Target\", i8 9, i8 16, !([0-9]+), i8 0, i32 1, i8 4, i32 0, i8 0, null}",
- "!{i32 1, !\"SV_DepthGreaterEqual\", i8 9, i8 19, !\\3, i8 0, i32 1, i8 1, i32 -1, i8 -1, null}\n"
- "!\\2 = !{i32 2, !\"SV_Target\", i8 9, i8 16, !\\3, i8 0, i32 1, i8 4, i32 0, i8 0, null}",
- "Pixel Shader only allows one type of depth semantic to be declared",
- /*bRegex*/true);
- }
- // TODO: reject non-zero padding
|