summaryrefslogtreecommitdiff
path: root/tools/slang-unit-test/unit-test-com-host-callable.slang
blob: e41eed8efc57388222436fa6e3a7fd71648d3d79 (plain)
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
// shader.slang

// Example of using 'NativeString'

export __extern_cpp NativeString getString(NativeString in)
{
    return in;
}

export __extern_cpp __global int intGlobal = 10;

export __extern_cpp void setGlobal(int v)
{
    intGlobal = v;
}

export __extern_cpp int getGlobal()
{
    return intGlobal;
}

[COM("9E0FCAF0-DE40-4CF1-A6A4-FF24814D32F2")]
interface IDoThings
{
    int doThing(int a, int b);
    int calcHash(NativeString in);
}

[COM("4CEA3168-819E-4E79-987B-8C4FDE6C697D")]
interface ICountGood
{
    int nextCount();
}

export __extern_cpp __global ICountGood globalCounter;

export __extern_cpp void setCounter(ICountGood counter)
{
    globalCounter = counter;
}

export __extern_cpp int nextCount()
{
    return globalCounter.nextCount();
}

export __extern_cpp int calcHash(NativeString text, IDoThings doThings)
{
    return doThings.calcHash(text);
}