@@ -73,6 +73,7 @@ class RewriterTest {
7373 TEST_METHOD (RunVectorSyntaxMix);
7474 TEST_METHOD (RunVectorSyntax);
7575 TEST_METHOD (RunIncludes);
76+ TEST_METHOD (RunSpirv);
7677 TEST_METHOD (RunStructMethods);
7778 TEST_METHOD (RunPredefines);
7879 TEST_METHOD (RunWideOneByte);
@@ -398,6 +399,31 @@ TEST_F(RewriterTest, RunNoFunctionBodyInclude) {
398399 RewriterOptionMask::SkipFunctionBody));
399400}
400401
402+ TEST_F (RewriterTest, RunSpirv) {
403+ CComPtr<IDxcRewriter> pRewriter;
404+ CComPtr<IDxcRewriter2> pRewriter2;
405+ VERIFY_SUCCEEDED (CreateRewriter (&pRewriter));
406+ VERIFY_SUCCEEDED (pRewriter->QueryInterface (&pRewriter2));
407+ CComPtr<IDxcOperationResult> pRewriteResult;
408+
409+ // Get the source text from a file
410+ FileWithBlob source (m_dllSupport,
411+ GetPathToHlslDataFile (L" rewriter\\ spirv.hlsl" ).c_str ());
412+
413+ LPCWSTR compileOptions[] = {L" -E" , L" main" , L" -HV" , L" 2021" , L" -spirv" };
414+
415+ // Run rewriter with HLSL 2021 specification and SPIR-V support
416+ VERIFY_SUCCEEDED (pRewriter2->RewriteWithOptions (
417+ source.BlobEncoding , L" spirv.hlsl" , compileOptions,
418+ _countof (compileOptions), nullptr , 0 , nullptr , &pRewriteResult));
419+
420+ CComPtr<IDxcBlob> result;
421+ VERIFY_SUCCEEDED (pRewriteResult->GetResult (&result));
422+ std::string strResult = BlobToUtf8 (result);
423+ // No built-in namespace "vk"
424+ VERIFY_IS_TRUE (strResult.find (" namespace vk" ) == std::string::npos);
425+ }
426+
401427TEST_F (RewriterTest, RunStructMethods) {
402428 CheckVerifiesHLSL (L" rewriter\\ struct-methods.hlsl" , L" rewriter\\ correct_rewrites\\ struct-methods_gold.hlsl" );
403429}
0 commit comments