summaryrefslogtreecommitdiffstats
path: root/examples/cpu-hello-world/shader.slang
blob: f650c3481c01ca5ccd463beaa3d78699a682e7cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// shader.slang

//TEST_INPUT:ubuffer(random(float, 4096, -1.0, 1.0), stride=4):name=ioBuffer
RWStructuredBuffer<float> ioBuffer;

[shader("compute")]
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
    uint tid = dispatchThreadID.x;

    float i = ioBuffer[tid];
    float o = i < 0.5 ? (i + i) : sqrt(i);

    ioBuffer[tid] = o;
}