Skip to content

Commit 14e1f83

Browse files
authored
[SPIRV] Allow decoration attributes on fields. (#7453)
Fixes #7270
1 parent 9b04d69 commit 14e1f83

File tree

3 files changed

+17
-20
lines changed

3 files changed

+17
-20
lines changed

tools/clang/include/clang/Basic/Attr.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,15 +1418,17 @@ def VKDecorateExt : InheritableAttr {
14181418

14191419
def VKDecorateIdExt : InheritableAttr {
14201420
let Spellings = [CXX11<"vk", "ext_decorate_id">];
1421-
let Subjects = SubjectList<[Function, Var, ParmVar, TypedefName], ErrorDiag>;
1421+
let Subjects =
1422+
SubjectList<[Function, Var, ParmVar, Field, TypedefName], ErrorDiag>;
14221423
let Args = [UnsignedArgument<"decorate">, VariadicExprArgument<"arguments">];
14231424
let LangOpts = [SPIRV];
14241425
let Documentation = [Undocumented];
14251426
}
14261427

14271428
def VKDecorateStringExt : InheritableAttr {
14281429
let Spellings = [CXX11<"vk", "ext_decorate_string">];
1429-
let Subjects = SubjectList<[Function, Var, ParmVar, TypedefName], ErrorDiag>;
1430+
let Subjects =
1431+
SubjectList<[Function, Var, ParmVar, Field, TypedefName], ErrorDiag>;
14301432
let Args = [UnsignedArgument<"decorate">, VariadicStringArgument<"arguments">];
14311433
let LangOpts = [SPIRV];
14321434
let Documentation = [Undocumented];

tools/clang/test/CodeGenSPIRV/inline-spirv/spv.inline.decorate.member.hlsl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ template<class T, class U>
44
[[vk::ext_instruction(/*spv::OpBitcast*/124)]]
55
T Bitcast(U);
66

7-
// CHECK: OpMemberDecorate %S 0 Offset 0
8-
// CHECK: OpMemberDecorate %S 1 Offset 16
9-
// CHECK: %S = OpTypeStruct %v4float %v4float
7+
// CHECK-DAG: OpMemberDecorate %S 0 Offset 0
8+
// CHECK-DAG: OpMemberDecorate %S 1 Offset 16
9+
// CHECK-DAG: %S = OpTypeStruct %v4float %v4float
1010

1111
struct S
1212
{
1313
[[vk::ext_decorate(/*offset*/ 35, 0)]] float4 f1;
1414
[[vk::ext_decorate(/*offset*/ 35, 16)]] float4 f2;
1515
};
1616

17+
// CHECK-DAG: OpDecorateString %out_var_SV_TARGET UserSemantic "raster_order_group_0"
18+
struct PixelOutput
19+
{
20+
[[vk::location(0), vk::ext_decorate_string(5635, "raster_order_group_0")]] float4 rt0 : SV_TARGET;
21+
};
22+
1723
using PointerType = vk::SpirvOpaqueType<
1824
/* OpTypePointer */ 32,
1925
/* PhysicalStorageBuffer */ vk::Literal<vk::integral_constant<uint,5349> >,
@@ -27,14 +33,16 @@ S Load(PointerType pointer,
2733

2834
uint64_t address;
2935

30-
float4 main() : SV_TARGET
36+
PixelOutput main()
3137
{
3238

3339
// CHECK: [[BC:%[0-9]+]] = OpBitcast %_ptr_PhysicalStorageBuffer_S {{%[0-9]+}}
3440
PointerType ptr = Bitcast<PointerType>(address);
3541

42+
PixelOutput output;
3643
// CHECK: [[LD:%[0-9]+]] = OpLoad %S [[BC]] Aligned 32
3744
// CHECK: [[RET:%[0-9]+]] = OpCompositeExtract %v4float [[LD]] 0
3845
// CHECK: OpStore %out_var_SV_TARGET [[RET]]
39-
return Load(ptr).f1;
46+
output.rt0 = Load(ptr).f1;
47+
return output;
4048
}

tools/clang/test/SemaHLSL/attributes/spv.inline.decorate.member.hlsl

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)