yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
dbf05f8dc
master
1// Test that multiple functions from different extensions are properly linked through their respective witness table. 2 3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -shaderobj 4interface IValuableImpl 5{ 6 int getValue(); 7} 8 9interface IValuable 10{ 11 associatedtype Impl : IValuableImpl; 12 Impl getImpl(); 13}; 14 15__generic <Int : __BuiltinIntegerType> 16extension Int : IValuableImpl 17{ 18 int getValue() 19 { 20 return 0; 21 } 22}; 23 24__generic <Float : __BuiltinFloatingPointType> 25extension Float : IValuableImpl 26{ 27 int getValue() 28 { 29 return 1; 30 } 31}; 32 33__generic <ValuableImpl : IValuableImpl> 34extension ValuableImpl : IValuable 35{ 36 typealias Impl = ValuableImpl; 37 ValuableImpl getImpl() 38 { 39 return this; 40 } 41}; 42 43//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 44RWStructuredBuffer<int> outputBuffer; 45 46[shader("compute")] 47[numthreads(1, 1, 1)] 48void computeMain() 49{ 50 uint i = 0; 51 float f = float(i) / float(10); 52 53 // CHECK: 0 54 outputBuffer[0] = i.getImpl().getValue(); 55 56 // CHECK: 1 57 outputBuffer[1] = f.getImpl().getValue(); 58}