Skip to content

Commit db90a46

Browse files
authored
[SPIRV] Simplify looking for input storage class (microsoft#6968)
The function `DeclResultIdMapper::isInputStorageClass` tries to determine the storage class for the stage variable by looking at its SigPoint. This does not always work. This change simply looks at the storage class that is already associated with the variable, which should have been set when the StageVar was created. Fixes microsoft#6959
1 parent c72be81 commit db90a46

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

tools/clang/lib/SPIRV/DeclResultIdMapper.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,8 +1156,7 @@ bool DeclResultIdMapper::decorateStageIOLocations() {
11561156
}
11571157

11581158
bool DeclResultIdMapper::isInputStorageClass(const StageVar &v) {
1159-
return getStorageClassForSigPoint(v.getSigPoint()) ==
1160-
spv::StorageClass::Input;
1159+
return v.getStorageClass() == spv::StorageClass::Input;
11611160
}
11621161

11631162
void DeclResultIdMapper::createFnParamCounterVar(const VarDecl *param) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %dxc -spirv -enable-16bit-types -T lib_6_7 -HV 202x %s | FileCheck %s
2+
3+
// CHECK: OpEntryPoint Fragment %psmain "psmain" %gl_HelperInvocation %out_var_SV_Target0
4+
// CHECK: OpDecorate %gl_HelperInvocation BuiltIn HelperInvocation
5+
// CHECK: %gl_HelperInvocation = OpVariable %_ptr_Input_bool Input
6+
7+
[[vk::ext_builtin_input(23 /* BuiltInHelperInvocation */)]]
8+
static const bool HelperInvocation;
9+
10+
[shader("pixel")]
11+
float4 psmain() : SV_Target0 {
12+
13+
if (HelperInvocation)
14+
return 0;
15+
return 1;
16+
}

0 commit comments

Comments
 (0)