yum-mirror/slang

Making it easier to work with shaders

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

jsmall-nvidiaLanguage experiments (#2068)447b7e0e2

master
1.1 KiB51 linesraw
1//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
2
3/* A test using interfaces with mutation.
4
5Doesn't work because
6
7.slang(18): error 30050: mutating method 'lock' cannot be called on an immutable value
8    lockable.lock();
9    
10If that section is removed we get on `doThing(count)`
11
12.slang(31): error 30047: argument passed to parameter '0' must be l-value.
13
14Which perhaps means an inteface cannot be used as a lvalue?
15*/
16
17//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
18RWStructuredBuffer<int> outputBuffer;
19
20interface ILockable
21{
22    [mutating] void lock();
23    [mutating] void unlock();
24};
25
26struct IntCount : ILockable
27{
28    [mutating] void lock() { count ++; }
29    [mutating] void unlock() { --count; }
30    int count = 0;
31};
32
33int doThing(inout ILockable lockable)
34{
35    lockable.lock();
36    // do something...
37    
38    lockable.unlock();
39    return 0;
40}
41
42[numthreads(4, 1, 1)]
43void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
44{    
45    int index = dispatchThreadID.x;
46    
47    IntCount count;
48    doThing(count);
49    
50    outputBuffer[dispatchThreadID.x] = count.count;
51}