Skip to content

[SPIRV] Allow decoration attributes on fields. #7453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
Merged
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
6 changes: 4 additions & 2 deletions tools/clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1418,15 +1418,17 @@ def VKDecorateExt : InheritableAttr {

def VKDecorateIdExt : InheritableAttr {
let Spellings = [CXX11<"vk", "ext_decorate_id">];
let Subjects = SubjectList<[Function, Var, ParmVar, TypedefName], ErrorDiag>;
let Subjects =
SubjectList<[Function, Var, ParmVar, Field, TypedefName], ErrorDiag>;
let Args = [UnsignedArgument<"decorate">, VariadicExprArgument<"arguments">];
let LangOpts = [SPIRV];
let Documentation = [Undocumented];
}

def VKDecorateStringExt : InheritableAttr {
let Spellings = [CXX11<"vk", "ext_decorate_string">];
let Subjects = SubjectList<[Function, Var, ParmVar, TypedefName], ErrorDiag>;
let Subjects =
SubjectList<[Function, Var, ParmVar, Field, TypedefName], ErrorDiag>;
let Args = [UnsignedArgument<"decorate">, VariadicStringArgument<"arguments">];
let LangOpts = [SPIRV];
let Documentation = [Undocumented];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ template<class T, class U>
[[vk::ext_instruction(/*spv::OpBitcast*/124)]]
T Bitcast(U);

// CHECK: OpMemberDecorate %S 0 Offset 0
// CHECK: OpMemberDecorate %S 1 Offset 16
// CHECK: %S = OpTypeStruct %v4float %v4float
// CHECK-DAG: OpMemberDecorate %S 0 Offset 0
// CHECK-DAG: OpMemberDecorate %S 1 Offset 16
// CHECK-DAG: %S = OpTypeStruct %v4float %v4float

struct S
{
[[vk::ext_decorate(/*offset*/ 35, 0)]] float4 f1;
[[vk::ext_decorate(/*offset*/ 35, 16)]] float4 f2;
};

// CHECK-DAG: OpDecorateString %out_var_SV_TARGET UserSemantic "raster_order_group_0"
struct PixelOutput
{
[[vk::location(0), vk::ext_decorate_string(5635, "raster_order_group_0")]] float4 rt0 : SV_TARGET;
};

using PointerType = vk::SpirvOpaqueType<
/* OpTypePointer */ 32,
/* PhysicalStorageBuffer */ vk::Literal<vk::integral_constant<uint,5349> >,
Expand All @@ -27,14 +33,16 @@ S Load(PointerType pointer,

uint64_t address;

float4 main() : SV_TARGET
PixelOutput main()
{

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

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

This file was deleted.