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 RWStructuredBuffer<T1> buffer0; 27 RWStructuredBuffer<T2> buffer1; 28 29 float getVal() 30 { 31 return buffer0[0].getElementVal() + buffer1[0].getElementVal(); 32 } 33} 34 35//TEST_INPUT:set gFoo = new Impl<Elem,Elem>{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( 41 uniform ParameterBlock<Impl<Elem, Elem>> gFoo, 42 uniform float v, 43 uniform RWStructuredBuffer<float> outputBuffer 44) 45{ 46 // CHECK: 4.0 47 outputBuffer[0] = gFoo.getVal() + v; 48}