yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
91430870a
master
1//TEST:SIMPLE(filecheck=METAL): -target metal -stage fragment -entry fragmentMain 2//TEST:SIMPLE(filecheck=WGSL): -target wgsl -stage fragment -entry fragmentMain 3//TEST:SIMPLE(filecheck=METALLIB): -target metallib -stage fragment -entry fragmentMain 4//TEST:SIMPLE(filecheck=WGSLSPIRV): -target wgsl-spirv-asm -stage fragment -entry fragmentMain 5 6// METAL: COARSEVERTEX_7 7// METAL: COARSEVERTEX_6 8 9// Ensure each attribute which may vary only appears once. 10// Ensure 1, 2, 3, 4 all appear 11 12// METAL-DAG: [[ATTR1:COARSEVERTEX_(1|2|3|4)]] 13 14// METAL-NOT: [[ATTR1]] 15// METAL-DAG: [[ATTR2:COARSEVERTEX_(1|2|3|4)]] 16 17// METAL: COARSEVERTEX{{(_0|())}} 18 19// METAL-NOT: [[ATTR2]] 20// METAL-DAG: [[ATTR3:COARSEVERTEX_(1|2|3|4)]] 21 22// METAL-NOT: [[ATTR3]] 23// METAL-DAG: [[ATTR4:COARSEVERTEX_(1|2|3|4)]] 24 25// WGSL:struct pixelInput 26// WGSL-DAG:@location(0) [[VAR0:[A-Za-z_0-9]+]] 27// WGSL-DAG:@location(1) [[VAR1:[A-Za-z_0-9]+]] 28// WGSL-DAG:@location(2) [[VAR2:[A-Za-z_0-9]+]] 29// WGSL-DAG:@location(3) [[VAR3:[A-Za-z_0-9]+]] 30// WGSL-DAG:@location(4) [[VAR4:[A-Za-z_0-9]+]] 31// WGSL-DAG:@location(6) [[VAR6:[A-Za-z_0-9]+]] 32// WGSL-DAG:@location(7) [[VAR7:[A-Za-z_0-9]+]] 33// WGSL-NOT:@location(8) 34// WGSL:} 35 36// METALLIB: @fragmentMain 37// WGSLSPIRV: %fragmentMain = OpFunction %void None 38 39RWStructuredBuffer<float> outputBuffer; 40 41struct BottomFragment1 42{ 43 float p1; 44}; 45struct BottomFragment2 46{ 47 float p1; 48}; 49 50struct MiddleFragment1 51{ 52 float p1; 53 BottomFragment1 p2; 54 BottomFragment2 p3; 55}; 56struct TopFragment 57{ 58 float p1 : CoarseVertex7; 59 MiddleFragment1 p2 : CoarseVertex6; 60 MiddleFragment1 p3 : CoarseVertex0; 61}; 62 63struct FragmentStageInput 64{ 65 TopFragment coarseVertex : CoarseVertex; 66}; 67 68// WGSL: fn fragmentMain{{[( ]*}}[[InputVar:[A-Za-z_0-9]+]] 69float4 fragmentMain(FragmentStageInput input) 70{ 71 // METAL-DAG: {{.*}}->p1{{.*}}= 72 73 // METAL-DAG: {{.*}}->p2{{.*}}->p1{{.*}}= 74 // METAL-DAG: {{.*}}->p2{{.*}}->p2{{.*}}->p1{{.*}}= 75 // METAL-DAG: {{.*}}->p2{{.*}}->p3{{.*}}->p1{{.*}}= 76 77 // METAL-DAG: {{.*}}->p3{{.*}}->p1{{.*}}= 78 // METAL-DAG: {{.*}}->p3{{.*}}->p2{{.*}}->p1{{.*}}= 79 // METAL-DAG: {{.*}}->p3{{.*}}->p3{{.*}}->p1{{.*}}= 80 81 // WGSL: var [[UnpackedInput:[A-Za-z_0-9]+]] : pixelInput 82 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR7]]; 83 84 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR6]]; 85 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR1]]; 86 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR2]]; 87 88 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR0]]; 89 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR3]]; 90 // WGSL-DAG: [[UnpackedInput]].{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}}.{{[A-Za-z_0-9]+}} = [[InputVar]].[[VAR4]]; 91 92 outputBuffer[0] = input.coarseVertex.p1 + input.coarseVertex.p2.p1 + +input.coarseVertex.p3.p1; 93 return float4(0, 0, 0, 0); 94}