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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
//TEST:DOC:-entry computeMain -target hlsl -stage compute -doc -no-codegen
void outFunc(out int v)
{
v = 10;
}
/// Testing out nested generics
struct ParentStruct<T> ///< Some type
{
/// Testing out a child
struct ChildStruct<S> ///< Some other type
{
/// A useless method hey ho
T getValue(S v) { T t; S s; return t; }
};
};
struct GenericStruct<T>
{
/// Let's try a typedef too
typedef T Element;
T getValue() { return value; }
T value;
};
/// A rather silly generic function to test out doc extraction
T addInts<T : __BuiltinIntegerType, ///< The type we are operating on
/// Just testing out a
/// non type based generic
let U : int,
let V : int> ///< And another one
(
/// CHECKING!!
T z, ///< The Z parameter
T b) ///< The B parameter
{
return z + b;
}
namespace Hey
{
void doAnotherThing(int a);
}
/// Let's test indent
///
/// ```
/// {
/// imIndented();
/// }
/// ```
///
RWStructuredBuffer<int> inputBuffer;
/// An interface to do things
interface IDoThing
{
/// An associated type
associatedtype V;
/// Add two integers
V add(V a, ///< First parameter
V b ///< Second parameter
);
/// Subtract
/// Multi-line
int sub(int a, ///< First
int b ///< Second
);
}
interface IThing
{
float getValue();
};
/// Implement IThing on float
extension float : IThing
{
/// Just return the float itself!
float getValue() { return this; }
}
struct Thing : IThing, IDoThing
{
typedef int V;
int add(int a, int b) { return a + b; }
int sub(int a, int b ) { return a - b; }
float getValue() { return 1.0f; }
};
/// A struct with some fields
struct SomeStruct
{
/// A field
int aField;
/// Multi-line
/// is a thing
int anotherField;
int yetAnother; ///< A field with stuff
/// Get a value
int getMethod() { return yetAnother; }
};
/// An enum
enum AnEnum
{
Value, ///< A value
/// Another value
/// With a multi-line comment
AnotherValue,
};
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
RWStructuredBuffer<int> outputBuffer; ///< An output buffer
/// doThing!
int doThing(int a, ///< a parameter
int b) ///< b parameter
{
while (b >= 0)
{
a
+=
a;
}
return a;
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
int a = dispatchThreadID.x;
int b = dispatchThreadID.y;
int c = dispatchThreadID.z;
int d = a + b * c;
int e = d + c / 2;
for (int i = 0; i < b; ++i)
{
if (e > 10 && i & 2)
{
a += b; b -= c; c += c; d = d + e + a; e = a;
}
else
{
a = e; b = c + c; d += d + __SyntaxError(); e = doThing(e, dispatchThreadID.x);
}
}
outputBuffer[dispatchThreadID.x] = a + b + c + d + e;
}
|