From e5d49cf21db7a398afe6cfdb76f6b4a028e9eecb Mon Sep 17 00:00:00 2001 From: kaizhangNV <149626564+kaizhangNV@users.noreply.github.com> Date: Thu, 2 May 2024 13:05:18 -0700 Subject: Allow multiple _AttributeTargets for attribute declaration (#4087) The syntax like: [__AttributeUsage(_AttributeTargets.Var)] [__AttributeUsage(_AttributeTargets.Param)] struct DefaultValueAttribute { int iParam; }; is allowed. For user-defined attribute, we can specify more attribute targets on the attribute declaration. So one attribute can be used in more than one situations. --- tests/reflection/attribute.slang | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'tests/reflection/attribute.slang') diff --git a/tests/reflection/attribute.slang b/tests/reflection/attribute.slang index 864aa5896..e0739643c 100644 --- a/tests/reflection/attribute.slang +++ b/tests/reflection/attribute.slang @@ -10,14 +10,10 @@ struct MyStructAttribute int iParam; float fParam; }; -[__AttributeUsage(_AttributeTargets.Var)] -struct DefaultValueAttribute -{ - int iParam; -}; +[__AttributeUsage(_AttributeTargets.Var)] [__AttributeUsage(_AttributeTargets.Param)] -struct DefaultFuncParamAttribute +struct DefaultValueAttribute { int iParam; }; @@ -43,9 +39,29 @@ ParameterBlock param2; [DefaultValue(2)] int globalInt; +[__AttributeUsage(_AttributeTargets.Struct)] +[__AttributeUsage(_AttributeTargets.Var)] +[__AttributeUsage(_AttributeTargets.Param)] +struct StructVarParamAttribute +{ + int iParam; +}; + +[StructVarParam(0)] +struct D +{ + int a; +}; + +D param3; + +[StructVarParam(1)] int globalInt2; + + [numthreads(1, 1, 1)] void main( uint3 dispatchThreadID : SV_DispatchThreadID, - [DefaultFuncParam(3)] float a) + [DefaultValue(3)] float a, + [StructVarParam(2)] float b) { } -- cgit v1.2.3