yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
160111a0e
master
1//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 2 3/* A test for equality around interface types 4 5This is an attempt to get the *outside* impl of equality to work. The simple case does, but just to throw a spanner in the works, lets mix in some inheritance. 6 7An issue here (perhaps) is that this will compile - the isEqual implementation will just slice and probably not do what the implementer expected. 8 */ 9 10//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer 11RWStructuredBuffer<float> outputBuffer; 12 13struct MyStruct 14{ 15 int a = 10; 16}; 17 18struct MyStruct2 : MyStruct 19{ 20 int b; 21}; 22 23bool isEqual(MyStruct a, MyStruct b) 24{ 25 return a.a == b.a; 26} 27 28[numthreads(4, 1, 1)] 29void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 30{ 31 int index = dispatchThreadID.x; 32 33 // I *suppose* it could be argued that this is problematic - that the b field is uninitialized 34 // but there is no warning or an error. 35 36 MyStruct2 a = { 1 }; 37 MyStruct2 b = { 2 }; 38 39 bool res = isEqual(a, b); 40 41 outputBuffer[index] = 1 + int(res); 42}