yum-mirror/slang

Making it easier to work with shaders

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

Yong HeImplement explciit binding for metal and wgsl. (#5778)7dabfa76c

master
664 B34 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
3
4// Access fields of a `struct` type from within a "method" by
5// using an implicit `this` expression.
6
7struct A
8{
9	float x;
10
11	float addWith(float y)
12	{
13		return x + y;
14	}
15};
16
17//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
18RWStructuredBuffer<float> outputBuffer;
19
20float test(float inVal)
21{
22	A a;
23	a.x = inVal;
24	return a.addWith(inVal*inVal);
25}
26
27[numthreads(4, 1, 1)]
28void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
29{
30	uint tid = dispatchThreadID.x;
31	float inVal = float(tid);
32	float outVal = test(inVal);
33	outputBuffer[tid] = outVal;
34}