yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
51ad07d1f
master
1//TEST:SIMPLE(filecheck=CHK):-target hlsl -stage compute -entry computeMain 2//TEST:SIMPLE(filecheck=HLSL):-target hlsl -stage compute -entry computeMain 3//TEST:SIMPLE(filecheck=GLSL):-target glsl -stage compute -entry computeMain 4//TEST:SIMPLE(filecheck=SPV):-target spirv -stage compute -entry computeMain 5 6// TODO: requires changes in parser 7//static_assert(true, "PASS_global"); 8//static_assert(false, "FAIL_global"); 9 10__generic<T:IArithmetic> 11void TEST_specialize() 12{ 13 static_assert(true, "TEST_specialize true"); 14 static_assert(T is float, "TEST_specialize T_is_float"); 15 static_assert(T is int, "TEST_specialize T_is_int"); 16} 17 18void TEST_target_switch() 19{ 20 static_assert(false, "TEST_target_switch all"); 21 __target_switch 22 { 23 case hlsl: 24 static_assert(false, "TEST_target_switch hlsl"); 25 return; 26 case glsl: 27 static_assert(false, "TEST_target_switch glsl"); 28 return; 29 default: 30 static_assert(false, "TEST_target_switch default"); 31 return; 32 } 33} 34 35__generic<T:IArithmetic> 36struct MyType 37{ 38 // TODO: requires changes in parser 39 //static_assert(true, "PASS_struct"); 40 //static_assert(false, "FAIL_struct"); 41 42 __init() 43 { 44 static_assert(true, "MyType init true"); 45 static_assert(false, "MyType init false"); 46 } 47}; 48 49__generic<T:IFloat> 50extension MyType<T> 51{ 52}; 53 54[numthreads(1,1,1)] 55void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) 56{ 57 // CHK-DAG: error {{.*}} TEST_specialize T_is_int 58 // CHK-DAG:{{.*}} TEST_specialize<float> 59 TEST_specialize<float>(); 60 61 // CHK-DAG: error {{.*}} TEST_specialize T_is_float 62 // CHK-DAG:{{.*}} TEST_specialize<int> 63 TEST_specialize<int>(); 64 65 //HLSL: error {{.*}} TEST_target_switch all 66 //HLSL: error {{.*}} TEST_target_switch hlsl 67 //HLSL-NOT: error {{.*}} TEST_target_switch glsl 68 //HLSL-NOT: error {{.*}} TEST_target_switch default 69 // 70 //GLSL: error {{.*}} TEST_target_switch all 71 //GLSL-NOT: error {{.*}} TEST_target_switch hlsl 72 //GLSL: error {{.*}} TEST_target_switch glsl 73 //GLSL-NOT: error {{.*}} TEST_target_switch default 74 // 75 //SPV: error {{.*}} TEST_target_switch all 76 //SPV-NOT: error {{.*}} TEST_target_switch hlsl 77 //SPV-NOT: error {{.*}} TEST_target_switch glsl 78 //SPV: error {{.*}} TEST_target_switch default 79 // 80 TEST_target_switch(); 81 82 //CHK-NOT: error {{.*}} MyType init true 83 //CHK: error {{.*}} MyType init false 84 MyType<float> obj; 85 86 //CHK: ([[#@LINE+1]]): error 87 static_assert(dispatchThreadID.x == 0, "not constant"); 88} 89