yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyRemove old code paths from render-test (#1760)6e5d85efb

master
1.6 KiB53 linesraw
1//TEST(compute):PERFORMANCE_PROFILE:-cpu -compute -compile-arg -O3 -compute-dispatch 256,1,1  -shaderobj
2//TEST_DISABLED(compute):PERFORMANCE_PROFILE:-cpu -compute -source-language cpp -compile-arg -O3 -compute-dispatch 256,1,1
3//TEST(compute):PERFORMANCE_PROFILE:-slang -compute -compute-dispatch 256,1,1 -shaderobj
4//TEST(compute):PERFORMANCE_PROFILE:-slang -compute -dx12 -compute-dispatch 256,1,1 -shaderobj
5//TEST(compute, vulkan):PERFORMANCE_PROFILE:-vk -compute -compute-dispatch 256,1,1 -shaderobj
6
7//TEST_INPUT:ubuffer(random(float, 4096, -1, 1), stride=4):out,name outputBuffer
8
9#ifndef __cplusplus
10
11RWStructuredBuffer<float> outputBuffer;
12
13[numthreads(16, 1, 1)]
14void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
15{
16    uint i = dispatchThreadID.x;
17    float v = outputBuffer[i];
18    v = v < 0.0f ? (v * v) : (v + v + v);
19	outputBuffer[i] = v;
20}
21
22
23#else
24
25namespace { // anonymous
26
27struct LocalUniformState
28{
29    RWStructuredBuffer<float> outputBuffer_0;
30};
31
32} // anonymous
33
34static void _calc(const RWStructuredBuffer<float>& buf, int start, int end)
35{
36    assert(start >= 0 && end <= buf.count);
37    float* data = buf.data;
38    
39    for (int i = start; i < end; ++i)
40    {
41        float v = data[i];
42        data[i] = v < 0.0f ? (v * v) : (v + v + v);
43    }
44}
45
46SLANG_PRELUDE_EXPORT
47void computeMain(ComputeVaryingInput* varyingInput, void* inParams, void* inUniformState)
48{
49    LocalUniformState* uniformState = (LocalUniformState*)inUniformState;
50    _calc(uniformState->outputBuffer_0, varyingInput->startGroupID.x * 16, varyingInput->endGroupID.x * 16);
51}
52 
53#endif