From 16f617f944655edf3631dc78bb13c504b53d2771 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 19 Dec 2024 07:07:31 -0800 Subject: Report error when generated spirv is empty. (#5899) * Report error when generated spirv is empty. * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska --- source/slang/slang-emit-spirv.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/slang/slang-emit-spirv.cpp') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 92fa507e0..63ebfcf6e 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -7964,6 +7964,8 @@ SlangResult emitSPIRVFromIR( { spirvOut.clear(); + bool symbolsEmitted = false; + auto sink = codeGenContext->getSink(); #if 0 @@ -8008,6 +8010,7 @@ SlangResult emitSPIRVFromIR( if (shouldPreserveParams && as(inst)) { context.ensureInst(inst); + symbolsEmitted = true; } if (generateWholeProgram) { @@ -8016,6 +8019,7 @@ SlangResult emitSPIRVFromIR( if (func->findDecoration()) { context.ensureInst(inst); + symbolsEmitted = true; } } } @@ -8046,8 +8050,14 @@ SlangResult emitSPIRVFromIR( for (auto irEntryPoint : irEntryPoints) { context.ensureInst(irEntryPoint); + symbolsEmitted = true; } + if (!symbolsEmitted) + { + sink->diagnose(irModule->getModuleInst(), Diagnostics::outputSpvIsEmpty); + return SLANG_FAIL; + } // Move forward delcared pointers to the end. do -- cgit v1.2.3