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.expected | 58 ++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'tests/reflection/attribute.slang.expected') diff --git a/tests/reflection/attribute.slang.expected b/tests/reflection/attribute.slang.expected index 94018c19c..9b51aae32 100644 --- a/tests/reflection/attribute.slang.expected +++ b/tests/reflection/attribute.slang.expected @@ -220,6 +220,46 @@ standard output = { "kind": "scalar", "scalarType": "int32" } + }, + { + "name": "param3", + "binding": {"kind": "uniform", "offset": 16, "size": 4}, + "type": { + "kind": "struct", + "name": "D", + "fields": [ + { + "name": "a", + "type": { + "kind": "scalar", + "scalarType": "int32" + }, + "binding": {"kind": "uniform", "offset": 0, "size": 4} + } + ], + "userAttribs": [{ + "name": "StructVarParam", + "arguments": [ + 0 + ] + } + ] + } + }, + { + "name": "globalInt2", + "userAttribs": [{ + "name": "StructVarParam", + "arguments": [ + 1 + ] + } + ], + "binding": {"kind": "uniform", "offset": 20, "size": 4}, + "type": { + "kind": "scalar", + "scalarType": "int32" + } } ], "entryPoints": [ @@ -242,7 +282,7 @@ standard output = { { "name": "a", "userAttribs": [{ - "name": "DefaultFuncParam", + "name": "DefaultValue", "arguments": [ 3 ] @@ -254,6 +294,22 @@ standard output = { "kind": "scalar", "scalarType": "float32" } + }, + { + "name": "b", + "userAttribs": [{ + "name": "StructVarParam", + "arguments": [ + 2 + ] + } + ], + "stage": "compute", + "binding": {"kind": "varyingInput", "index": 1}, + "type": { + "kind": "scalar", + "scalarType": "float32" + } } ], "threadGroupSize": [1, 1, 1] -- cgit v1.2.3