Skip to content

Commit 0958e06

Browse files
authored
[SPIRV] Don't assume entry points are at the start of the worklist. (#7225)
Fixes #7161
1 parent 6701eed commit 0958e06

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

tools/clang/lib/SPIRV/SpirvEmitter.cpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -809,21 +809,17 @@ void SpirvEmitter::HandleTranslationUnit(ASTContext &context) {
809809
spvBuilder.setMemoryModel(spv::AddressingModel::Logical,
810810
spv::MemoryModel::GLSL450);
811811

812-
// Even though the 'workQueue' grows due to the above loop, the first
813-
// 'numEntryPoints' entries in the 'workQueue' are the ones with the HLSL
814-
// 'shader' attribute, and must therefore be entry functions.
815-
assert(numEntryPoints <= workQueue.size());
816-
817-
for (uint32_t i = 0; i < numEntryPoints; ++i) {
812+
for (uint32_t i = 0; i < workQueue.size(); ++i) {
818813
// TODO: assign specific StageVars w.r.t. to entry point
819814
const FunctionInfo *entryInfo = workQueue[i];
820-
assert(entryInfo->isEntryFunction);
821-
spvBuilder.addEntryPoint(
822-
getSpirvShaderStage(
823-
entryInfo->shaderModelKind,
824-
featureManager.isExtensionEnabled(Extension::EXT_mesh_shader)),
825-
entryInfo->entryFunction, getEntryPointName(entryInfo),
826-
getInterfacesForEntryPoint(entryInfo->entryFunction));
815+
if (entryInfo->isEntryFunction) {
816+
spvBuilder.addEntryPoint(
817+
getSpirvShaderStage(
818+
entryInfo->shaderModelKind,
819+
featureManager.isExtensionEnabled(Extension::EXT_mesh_shader)),
820+
entryInfo->entryFunction, getEntryPointName(entryInfo),
821+
getInterfacesForEntryPoint(entryInfo->entryFunction));
822+
}
827823
}
828824

829825
// Add Location decorations to stage input/output variables.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %dxc -T lib_6_6 -E main -fspv-target-env=universal1.5 -fcgl %s -spirv | FileCheck %s
2+
3+
// CHECK: OpEntryPoint MissKHR %miss "miss" %payload
4+
// CHECK: OpDecorate %func LinkageAttributes "func" Export
5+
6+
7+
struct RayPayload
8+
{
9+
uint a;
10+
};
11+
12+
export void func()
13+
{
14+
}
15+
16+
[shader("miss")]
17+
void miss(inout RayPayload payload)
18+
{
19+
}

0 commit comments

Comments
 (0)