summaryrefslogtreecommitdiffstats
path: root/tests/reflection/attribute.slang
blob: 8d755648af748fcbc3f5938198311bd7c43c503e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// attribute.slang

// Tests reflection of user defined attributes.

//TEST:REFLECTION:-stage compute -entry main -target hlsl -no-codegen

[__AttributeUsage(_AttributeTargets.Struct)]
[__AttributeUsage(_AttributeTargets.Function)]
struct MyStructAttribute
{
    int iParam;
    float fParam;
    string sParam;
};

[__AttributeUsage(_AttributeTargets.Var)]
[__AttributeUsage(_AttributeTargets.Param)]
struct DefaultValueAttribute
{
    int iParam;
};

[MyStruct(0, 1.0, "A")]
struct A
{
    float x;
    [DefaultValue(1)]
    float y;
};

[MyStruct(0, 2.0, "\"")]
struct B
{
    float x;
    [DefaultValue(1+1)]
    float z;
};

ParameterBlock<A> param;
ParameterBlock<B> 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;


[MyStruct(2, 3.0, "main")]
[MyStruct(-2, -3.0, "")]
[numthreads(1, 1, 1)]
void main(
    uint3 dispatchThreadID : SV_DispatchThreadID,
    [DefaultValue(3)] float a,
    [StructVarParam(2)] float b)
{
}