yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
134f8ccc9
master
1// Test that we allow type conformances whose base interface is generic. 2 3//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-dx11 -compute -output-using-type 4//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -output-using-type 5 6public interface ITestInterface<Real : IFloat> { 7 Real sample(); 8} 9 10struct TestInterfaceImpl<Real : IFloat> : ITestInterface<Real> { 11 Real sample() { 12 return x; 13 } 14 Real x; 15} 16 17//TEST_INPUT: set data = new StructuredBuffer<ITestInterface<float> >[new TestInterfaceImpl<float>{1.0}]; 18StructuredBuffer<ITestInterface<float>> data; 19 20//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0 0 0], stride=4); 21RWStructuredBuffer<int> outputBuffer; 22 23//TEST_INPUT: type_conformance TestInterfaceImpl<float>:ITestInterface<float> = 3 24 25[numthreads(1, 1, 1)] 26void computeMain() 27{ 28 let obj = data[0]; 29 // CHECK: 1 30 outputBuffer[0] = int(obj.sample()); 31}