yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
712ce653d
master
1//TEST(compute):COMPARE_COMPUTE: -shaderobj -output-using-type 2//TEST(compute):COMPARE_COMPUTE: -vk -shaderobj -output-using-type 3 4// This test confirms that we can provide a subset of the required generic 5// arguments to a generic function, and have the rest be inferred from the 6// types of the value arguments. 7 8interface IConvertible 9{ 10 __init( int value ); 11 12 property value : int { get; } 13} 14 15ToType convert< ToType : IConvertible, FromType : IConvertible >( FromType fromVal ) 16{ 17 return ToType( fromVal.value*0x10 ); 18} 19 20struct A : IConvertible 21{ 22 int value; 23 __init(int v) { this.value = v; } 24} 25 26struct B : IConvertible 27{ 28 int value; 29 __init(int v) { this.value = v; } 30} 31 32 33int test( int value ) 34{ 35 A a = A(value); 36 B b = convert<B>(a); 37 38 return a.value + b.value; 39} 40 41//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 42RWStructuredBuffer<int> outputBuffer; 43 44[numthreads(4, 1, 1)] 45void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 46{ 47 int tid = dispatchThreadID.x; 48 outputBuffer[tid] = test(tid); 49}