yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

DevonFix User Attribute string reflection (#6799)387deedac

master
1.2 KiB71 linesraw
1// attribute.slang
2
3// Tests reflection of user defined attributes.
4
5//TEST:REFLECTION:-stage compute -entry main -target hlsl -no-codegen
6
7[__AttributeUsage(_AttributeTargets.Struct)]
8[__AttributeUsage(_AttributeTargets.Function)]
9struct MyStructAttribute
10{
11    int iParam;
12    float fParam;
13    string sParam;
14};
15
16[__AttributeUsage(_AttributeTargets.Var)]
17[__AttributeUsage(_AttributeTargets.Param)]
18struct DefaultValueAttribute
19{
20    int iParam;
21};
22
23[MyStruct(0, 1.0, "A")]
24struct A
25{
26    float x;
27    [DefaultValue(1)]
28    float y;
29};
30
31[MyStruct(0, 2.0, "\"")]
32struct B
33{
34    float x;
35    [DefaultValue(1+1)]
36    float z;
37};
38
39ParameterBlock<A> param;
40ParameterBlock<B> param2;
41
42[DefaultValue(2)] int globalInt;
43
44[__AttributeUsage(_AttributeTargets.Struct)]
45[__AttributeUsage(_AttributeTargets.Var)]
46[__AttributeUsage(_AttributeTargets.Param)]
47struct StructVarParamAttribute
48{
49    int iParam;
50};
51
52[StructVarParam(0)]
53struct D
54{
55    int a;
56};
57
58D param3;
59
60[StructVarParam(1)] int globalInt2;
61
62
63[MyStruct(2, 3.0, "main")]
64[MyStruct(-2, -3.0, "")]
65[numthreads(1, 1, 1)]
66void main(
67    uint3 dispatchThreadID : SV_DispatchThreadID,
68    [DefaultValue(3)] float a,
69    [StructVarParam(2)] float b)
70{
71}