yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d11 -shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -d3d12 -shaderobj -output-using-type 3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -vk -shaderobj -output-using-type 4//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu -shaderobj -output-using-type 5 6interface IFoo 7{ 8 float getVal(); 9} 10interface IElement 11{ 12 float getElementVal(); 13} 14 15struct Elem : IElement 16{ 17 float x; 18 float getElementVal() 19 { 20 return x; 21 } 22} 23 24struct Impl<T1:IElement, T2:IElement> : IFoo 25{ 26 float v1; 27 RWStructuredBuffer<T1> buffer0; 28 RWStructuredBuffer<T2> buffer1; 29 30 float getVal() 31 { 32 return buffer0[0].getElementVal() + buffer1[0].getElementVal() + v1; 33 } 34} 35//TEST_INPUT:set gFoo = new Impl<Elem,Elem>{2.0, ubuffer(data=[1.0], stride = 4), ubuffer(data=[2.0], stride = 4)} 36//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 37//TEST_INPUT:set v = 1.0; 38 39[numthreads(1, 1, 1)] 40void computeMain(uniform ParameterBlock<Impl<Elem, Elem>> gFoo, 41 uniform float v, 42 uniform RWStructuredBuffer<float> outputBuffer) 43{ 44 // CHECK: 6.0 45 outputBuffer[0] = gFoo.getVal() + v; 46}