Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tools/clang/lib/SPIRV/DeclResultIdMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ bool shouldSkipInStructLayout(const Decl *decl) {
// Ignore embeded function decls
if (isa<FunctionDecl>(decl))
return true;
// Ignore static variables. They are not part of struct-like explicit
// layouts and should not consume a member index.
if (const auto *varDecl = dyn_cast<VarDecl>(decl))
if (varDecl->getStorageClass() == StorageClass::SC_Static)
return true;
// Ignore empty decls
if (isa<EmptyDecl>(decl))
return true;
Expand Down
21 changes: 21 additions & 0 deletions tools/clang/test/CodeGenSPIRV/var.static-const.cbuffer.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %dxc -T ps_6_0 -E main %s -spirv 2>&1 | FileCheck %s

cbuffer MetadataCB {
uint m0; static const int c0 = 0;
uint m1; static const int c1 = 0;
uint m2; static const int c2 = 0;
};

float4 main() : SV_Target {
return float4(asfloat(m2), 0, 0, 0);
}

// CHECK: warning: cbuffer member initializer ignored since no Vulkan equivalent
// CHECK: warning: cbuffer member initializer ignored since no Vulkan equivalent
// CHECK: warning: cbuffer member initializer ignored since no Vulkan equivalent
// CHECK: OpName %type_MetadataCB "type.MetadataCB"
// CHECK-NEXT: OpMemberName %type_MetadataCB 0 "m0"
// CHECK-NEXT: OpMemberName %type_MetadataCB 1 "m1"
// CHECK-NEXT: OpMemberName %type_MetadataCB 2 "m2"
// CHECK: %type_MetadataCB = OpTypeStruct %uint %uint %uint
// CHECK: OpAccessChain %_ptr_Uniform_uint %MetadataCB %int_2
Loading