yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9ec6b9168
master
1//TEST(smoke,compute):COMPARE_COMPUTE: -shaderobj 2//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj 3 4// This is a basic test for Slang compute shader. 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 7RWStructuredBuffer<uint> outputBuffer; 8 9interface IInterface 10{ 11 associatedtype T; 12 T getT(); 13 [mutating] 14 void setT(T val); 15} 16interface IEmptyS 17{ 18 float emptyFunc(); 19}; 20struct EmptyS : IEmptyS 21{ 22 float emptyFunc() {return 0.0;} 23}; 24 25struct Empty<TT : IEmptyS> : IInterface 26{ 27 typedef TT T; 28 TT value = TT(); 29 float a = 0; 30 TT getT() 31 { 32 return value; 33 } 34 [mutating] 35 void setT(TT val) 36 { 37 value = val; 38 a = value.emptyFunc(); 39 } 40} 41 42void test<Obj : IInterface>(Obj obj) 43{ 44 Obj.T v = obj.getT(); 45 obj.setT(v); 46} 47 48[numthreads(4, 1, 1)] 49void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 50{ 51 Empty<EmptyS> obj = {}; 52 test(obj); 53 outputBuffer[dispatchThreadID.x] = dispatchThreadID.x; 54}