Skip to content

Commit

Permalink
[SPIRV] Simplify looking for input storage class
Browse files Browse the repository at this point in the history
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 #6959
  • Loading branch information
s-perron committed Oct 15, 2024
1 parent 26d7dd9 commit e0eedbf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tools/clang/lib/SPIRV/DeclResultIdMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,7 @@ bool DeclResultIdMapper::decorateStageIOLocations() {
}

bool DeclResultIdMapper::isInputStorageClass(const StageVar &v) {
return getStorageClassForSigPoint(v.getSigPoint()) ==
spv::StorageClass::Input;
return v.getStorageClass() == spv::StorageClass::Input;
}

void DeclResultIdMapper::createFnParamCounterVar(const VarDecl *param) {
Expand Down
16 changes: 16 additions & 0 deletions tools/clang/test/CodeGenSPIRV/ext_builtin_input.lib.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %dxc -spirv -enable-16bit-types -T lib_6_7 -HV 202x %s | FileCheck %s

// CHECK: OpEntryPoint Fragment %psmain "psmain" %gl_HelperInvocation %out_var_SV_Target0
// CHECK: OpDecorate %gl_HelperInvocation BuiltIn HelperInvocation
// CHECK: %gl_HelperInvocation = OpVariable %_ptr_Input_bool Input

[[vk::ext_builtin_input(23 /* BuiltInHelperInvocation */)]]
static const bool HelperInvocation;

[shader("pixel")]
float4 psmain() : SV_Target0 {

if (HelperInvocation)
return 0;
return 1;
}

0 comments on commit e0eedbf

Please sign in to comment.