yum-mirror/slang

Making it easier to work with shaders

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

Tim FoleyConvert more tests to use shader objects (#1659)2a5d5b323

master
909 B52 linesraw
1//TEST(compute):COMPARE_COMPUTE: -shaderobj
2//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
3
4//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
5RWStructuredBuffer<float> outputBuffer;
6
7interface IAdd
8{
9    float addf(float u, float v);
10}
11
12interface ISub
13{
14    float subf(float u, float v);
15}
16
17interface IAddAndSub
18{
19    float addf(float u, float v);
20    float subf(float u, float v);    
21}
22
23struct Simple : IAdd
24{
25    float base;
26    float addf(float u, float v)
27    {
28        return u+v;
29    }
30};
31
32__extension Simple : ISub, IAddAndSub
33{
34    float subf(float u, float v)
35    {
36        return base+u-v;
37    }
38};
39
40float testAddSub<T:IAddAndSub>(T t)
41{
42    return t.subf(t.addf(1.0, 1.0), 1.0);
43}
44
45[numthreads(4, 1, 1)]
46void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
47{
48    Simple s;
49    s.base = 0.0;
50	float outVal = testAddSub(s);
51	outputBuffer[dispatchThreadID.x] = outVal;
52}