diff --git a/tools/clang/lib/SPIRV/SpirvEmitter.cpp b/tools/clang/lib/SPIRV/SpirvEmitter.cpp index 3a67257da7..bfda6a878f 100644 --- a/tools/clang/lib/SPIRV/SpirvEmitter.cpp +++ b/tools/clang/lib/SPIRV/SpirvEmitter.cpp @@ -809,21 +809,17 @@ void SpirvEmitter::HandleTranslationUnit(ASTContext &context) { spvBuilder.setMemoryModel(spv::AddressingModel::Logical, spv::MemoryModel::GLSL450); - // Even though the 'workQueue' grows due to the above loop, the first - // 'numEntryPoints' entries in the 'workQueue' are the ones with the HLSL - // 'shader' attribute, and must therefore be entry functions. - assert(numEntryPoints <= workQueue.size()); - - for (uint32_t i = 0; i < numEntryPoints; ++i) { + for (uint32_t i = 0; i < workQueue.size(); ++i) { // TODO: assign specific StageVars w.r.t. to entry point const FunctionInfo *entryInfo = workQueue[i]; - assert(entryInfo->isEntryFunction); - spvBuilder.addEntryPoint( - getSpirvShaderStage( - entryInfo->shaderModelKind, - featureManager.isExtensionEnabled(Extension::EXT_mesh_shader)), - entryInfo->entryFunction, getEntryPointName(entryInfo), - getInterfacesForEntryPoint(entryInfo->entryFunction)); + if (entryInfo->isEntryFunction) { + spvBuilder.addEntryPoint( + getSpirvShaderStage( + entryInfo->shaderModelKind, + featureManager.isExtensionEnabled(Extension::EXT_mesh_shader)), + entryInfo->entryFunction, getEntryPointName(entryInfo), + getInterfacesForEntryPoint(entryInfo->entryFunction)); + } } // Add Location decorations to stage input/output variables. diff --git a/tools/clang/test/CodeGenSPIRV/lib.fn.export.with.entrypoint.hlsl b/tools/clang/test/CodeGenSPIRV/lib.fn.export.with.entrypoint.hlsl new file mode 100644 index 0000000000..0ab965aded --- /dev/null +++ b/tools/clang/test/CodeGenSPIRV/lib.fn.export.with.entrypoint.hlsl @@ -0,0 +1,19 @@ +// RUN: %dxc -T lib_6_6 -E main -fspv-target-env=universal1.5 -fcgl %s -spirv | FileCheck %s + +// CHECK: OpEntryPoint MissKHR %miss "miss" %payload +// CHECK: OpDecorate %func LinkageAttributes "func" Export + + +struct RayPayload +{ + uint a; +}; + +export void func() +{ +} + +[shader("miss")] +void miss(inout RayPayload payload) +{ +}