yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
92ee2927d
master
1//TEST(compute):SIMPLE(filecheck=SM5):-target hlsl -profile cs_5_1 -entry computeMain 2//TEST(compute):SIMPLE(filecheck=HLSL2018):-target hlsl -profile cs_6_0 -capability hlsl_2018 -entry computeMain 3//TEST(compute):SIMPLE(filecheck=SM6):-target hlsl -profile cs_6_0 -entry computeMain 4//TEST(compute):SIMPLE(filecheck=WGS):-target wgsl -stage compute -entry computeMain 5//TEST(compute):SIMPLE(filecheck=MTL):-target metal -stage compute -entry computeMain 6//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK):-slang -compute -shaderobj -output-using-type -xslang -Wno-30056 7//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK):-vk -compute -shaderobj -output-using-type -xslang -Wno-30056 8//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK):-mtl -compute -shaderobj -output-using-type -xslang -Wno-30056 9//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-cuda -compute -shaderobj -output-using-type -xslang -Wno-30056 10//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-cpu -compute -shaderobj -output-using-type -xslang -Wno-30056 11 12// Testnig logical-AND, logical-OR and ternary operator with non-scalar operands 13 14//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 15RWStructuredBuffer<int> outputBuffer; 16 17static int result = 0; 18 19bool2 assignFunc(int index) 20{ 21 result += 10; 22 return bool2(true); 23} 24 25[numthreads(4, 1, 1)] 26void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 27{ 28 int index = dispatchThreadID.x; 29 30 // No short-circuiting for vector types 31 32 //SM5:(all({{.*}}&& 33 //HLSL2018:(all({{.*}}&& 34 //SM6:(all(and( 35 //WGS:(all((select(vec2<bool>(false), 36 //MTL:(all({{.*}}&& 37 if (all(bool2(index >= 1) && assignFunc(index))) 38 { 39 result++; 40 } 41 42 // Intentionally using non-boolean type for testing. 43 44 //SM5:(all({{.*}}|| 45 //HLSL2018:(all({{.*}}|| 46 //SM6:(or(vector<bool,2>( 47 //WGS:(select({{.*}}, vec2<bool>(true), vec2<bool>( 48 //MTL:(all(bool2({{.*}}|| 49 if (all(int2(index >= 2) || !assignFunc(index))) 50 { 51 result++; 52 } 53 54 //SM5:(all({{.*}}?{{.*}}: 55 //HLSL2018:(all({{.*}}?{{.*}}: 56 //SM6:(all(select( 57 //WGS:(all((select(vec2<bool>(false), 58 //MTL:(all(select(bool2(false) 59 if (all(bool2(index >= 3) ? assignFunc(index) : bool2(false))) 60 { 61 result++; 62 } 63 64 outputBuffer[index] = result; 65 66 //CHK:30 67 //CHK-NEXT:31 68 //CHK-NEXT:32 69 //CHK-NEXT:33 70}