Home | History | Annotate | Download | only in shaders
      1 
      2 group varying "Varying linkage"
      3 	group rules "Rules"
      4 		case input_type_mismatch
      5 			version 310 es
      6 			desc "Geometry shader input type mismatch"
      7 			expect link_fail
      8 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
      9 			values { output float out0 = 1.0; }
     10 			vertex ""
     11 				#version 310 es
     12 				${VERTEX_DECLARATIONS}
     13 				out mediump float geo_in;
     14 				void main()
     15 				{
     16 					geo_in = 1.0;
     17 					${VERTEX_OUTPUT}
     18 				}
     19 			""
     20 			geometry ""
     21 				#version 310 es
     22 				${GEOMETRY_DECLARATIONS}
     23 				in mediump vec2 geo_in[];
     24 				out mediump float geo_out;
     25 				void main()
     26 				{
     27 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
     28 					{
     29 						geo_out = geo_in[ndx].x + geo_in[ndx].y;
     30 						gl_Position = gl_in[ndx].gl_Position;
     31 						EmitVertex();
     32 					}
     33 				}
     34 			""
     35 			fragment ""
     36 				#version 310 es
     37 				precision mediump float;
     38 				${FRAGMENT_DECLARATIONS}
     39 				in mediump float geo_out;
     40 				void main()
     41 				{
     42 					out0 = geo_out;
     43 					${FRAGMENT_OUTPUT}
     44 				}
     45 			""
     46 		end
     47 
     48 		case output_type_mismatch
     49 			version 310 es
     50 			desc "Geometry shader output type mismatch"
     51 			expect link_fail
     52 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
     53 			values { output float out0 = 1.0; }
     54 			vertex ""
     55 				#version 310 es
     56 				${VERTEX_DECLARATIONS}
     57 				void main()
     58 				{
     59 					${VERTEX_OUTPUT}
     60 				}
     61 			""
     62 			geometry ""
     63 				#version 310 es
     64 				${GEOMETRY_DECLARATIONS}
     65 				out mediump float geo_out;
     66 				void main()
     67 				{
     68 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
     69 					{
     70 						geo_out = 1.0;
     71 						gl_Position = gl_in[ndx].gl_Position;
     72 						EmitVertex();
     73 					}
     74 				}
     75 			""
     76 			fragment ""
     77 				#version 310 es
     78 				precision mediump float;
     79 				${FRAGMENT_DECLARATIONS}
     80 				in mediump vec2 geo_out;
     81 				void main()
     82 				{
     83 					out0 = geo_out.x + geo_out.y;
     84 					${FRAGMENT_OUTPUT}
     85 				}
     86 			""
     87 		end
     88 
     89 		case input_different_precision
     90 			version 310 es
     91 			desc "Geometry shader input precision mismatch"
     92 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
     93 			values { output float out0 = 1.0; }
     94 			vertex ""
     95 				#version 310 es
     96 				${VERTEX_DECLARATIONS}
     97 				out highp float geo_in;
     98 				void main()
     99 				{
    100 					geo_in = 1.0;
    101 					${VERTEX_OUTPUT}
    102 				}
    103 			""
    104 			geometry ""
    105 				#version 310 es
    106 				${GEOMETRY_DECLARATIONS}
    107 				in lowp float geo_in[];
    108 				out mediump float geo_out;
    109 				void main()
    110 				{
    111 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    112 					{
    113 						geo_out = geo_in[ndx];
    114 						gl_Position = gl_in[ndx].gl_Position;
    115 						EmitVertex();
    116 					}
    117 				}
    118 			""
    119 			fragment ""
    120 				#version 310 es
    121 				precision mediump float;
    122 				${FRAGMENT_DECLARATIONS}
    123 				in mediump float geo_out;
    124 				void main()
    125 				{
    126 					out0 = geo_out;
    127 					${FRAGMENT_OUTPUT}
    128 				}
    129 			""
    130 		end
    131 
    132 		case output_different_precision
    133 			version 310 es
    134 			desc "Geometry shader output precision mismatch"
    135 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    136 			values { output float out0 = 1.0; }
    137 			vertex ""
    138 				#version 310 es
    139 				${VERTEX_DECLARATIONS}
    140 				void main()
    141 				{
    142 					${VERTEX_OUTPUT}
    143 				}
    144 			""
    145 			geometry ""
    146 				#version 310 es
    147 				${GEOMETRY_DECLARATIONS}
    148 				out highp float geo_out;
    149 				void main()
    150 				{
    151 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    152 					{
    153 						geo_out = 1.0;
    154 						gl_Position = gl_in[ndx].gl_Position;
    155 						EmitVertex();
    156 					}
    157 				}
    158 			""
    159 			fragment ""
    160 				#version 310 es
    161 				precision mediump float;
    162 				${FRAGMENT_DECLARATIONS}
    163 				in lowp float geo_out;
    164 				void main()
    165 				{
    166 					out0 = geo_out;
    167 					${FRAGMENT_OUTPUT}
    168 				}
    169 			""
    170 		end
    171 
    172 		case input_no_declaration
    173 			version 310 es
    174 			desc "Geometry shader input has no matching output"
    175 			expect link_fail
    176 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    177 			values { output float out0 = 1.0; }
    178 			vertex ""
    179 				#version 310 es
    180 				${VERTEX_DECLARATIONS}
    181 				void main()
    182 				{
    183 					${VERTEX_OUTPUT}
    184 				}
    185 			""
    186 			geometry ""
    187 				#version 310 es
    188 				${GEOMETRY_DECLARATIONS}
    189 				in lowp float geo_in[];
    190 				out mediump float geo_out;
    191 				void main()
    192 				{
    193 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    194 					{
    195 						geo_out = geo_in[ndx];
    196 						gl_Position = gl_in[ndx].gl_Position;
    197 						EmitVertex();
    198 					}
    199 				}
    200 			""
    201 			fragment ""
    202 				#version 310 es
    203 				precision mediump float;
    204 				${FRAGMENT_DECLARATIONS}
    205 				in mediump float geo_out;
    206 				void main()
    207 				{
    208 					out0 = geo_out;
    209 					${FRAGMENT_OUTPUT}
    210 				}
    211 			""
    212 		end
    213 
    214 		case output_no_declaration
    215 			version 310 es
    216 			desc "Geometry shader has no output for an input"
    217 			expect link_fail
    218 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    219 			values { output float out0 = 1.0; }
    220 			vertex ""
    221 				#version 310 es
    222 				${VERTEX_DECLARATIONS}
    223 				void main()
    224 				{
    225 					${VERTEX_OUTPUT}
    226 				}
    227 			""
    228 			geometry ""
    229 				#version 310 es
    230 				${GEOMETRY_DECLARATIONS}
    231 				void main()
    232 				{
    233 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    234 					{
    235 						gl_Position = gl_in[ndx].gl_Position;
    236 						EmitVertex();
    237 					}
    238 				}
    239 			""
    240 			fragment ""
    241 				#version 310 es
    242 				precision mediump float;
    243 				${FRAGMENT_DECLARATIONS}
    244 				in mediump float geo_out;
    245 				void main()
    246 				{
    247 					out0 = geo_out;
    248 					${FRAGMENT_OUTPUT}
    249 				}
    250 			""
    251 		end
    252 
    253 		case input_superfluous_declaration
    254 			version 310 es
    255 			desc "Geometry shader has no input for an output"
    256 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    257 			values { output float out0 = 1.0; }
    258 			vertex ""
    259 				#version 310 es
    260 				${VERTEX_DECLARATIONS}
    261 				out mediump float geo_in;
    262 				void main()
    263 				{
    264 					geo_in = 1.0;
    265 					${VERTEX_OUTPUT}
    266 				}
    267 			""
    268 			geometry ""
    269 				#version 310 es
    270 				${GEOMETRY_DECLARATIONS}
    271 				out mediump float geo_out;
    272 				void main()
    273 				{
    274 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    275 					{
    276 						geo_out = 1.0;
    277 						gl_Position = gl_in[ndx].gl_Position;
    278 						EmitVertex();
    279 					}
    280 				}
    281 			""
    282 			fragment ""
    283 				#version 310 es
    284 				precision mediump float;
    285 				${FRAGMENT_DECLARATIONS}
    286 				in mediump float geo_out;
    287 				void main()
    288 				{
    289 					out0 = geo_out;
    290 					${FRAGMENT_OUTPUT}
    291 				}
    292 			""
    293 		end
    294 
    295 		case output_superfluous_declaration
    296 			version 310 es
    297 			desc "Geometry shader has output without an matching input"
    298 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    299 			values { output float out0 = 1.0; }
    300 			vertex ""
    301 				#version 310 es
    302 				${VERTEX_DECLARATIONS}
    303 				void main()
    304 				{
    305 					${VERTEX_OUTPUT}
    306 				}
    307 			""
    308 			geometry ""
    309 				#version 310 es
    310 				${GEOMETRY_DECLARATIONS}
    311 				out mediump float geo_out;
    312 				void main()
    313 				{
    314 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    315 					{
    316 						geo_out = 1.0;
    317 						gl_Position = gl_in[ndx].gl_Position;
    318 						EmitVertex();
    319 					}
    320 				}
    321 			""
    322 			fragment ""
    323 				#version 310 es
    324 				precision mediump float;
    325 				${FRAGMENT_DECLARATIONS}
    326 				void main()
    327 				{
    328 					out0 = 1.0;
    329 					${FRAGMENT_OUTPUT}
    330 				}
    331 			""
    332 		end
    333 
    334 		case input_array_explicit_size
    335 			version 310 es
    336 			desc "Geometry shader input is explicitly sized array"
    337 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    338 			values { output float out0 = 1.0; }
    339 			vertex ""
    340 				#version 310 es
    341 				${VERTEX_DECLARATIONS}
    342 				out mediump float geo_in;
    343 				void main()
    344 				{
    345 					geo_in = 1.0;
    346 					${VERTEX_OUTPUT}
    347 				}
    348 			""
    349 			geometry ""
    350 				#version 310 es
    351 				${GEOMETRY_DECLARATIONS}
    352 				in mediump float geo_in[3];
    353 				out mediump float geo_out;
    354 				void main()
    355 				{
    356 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    357 					{
    358 						geo_out = geo_in[ndx];
    359 						gl_Position = gl_in[ndx].gl_Position;
    360 						EmitVertex();
    361 					}
    362 				}
    363 			""
    364 			fragment ""
    365 				#version 310 es
    366 				precision mediump float;
    367 				${FRAGMENT_DECLARATIONS}
    368 				in mediump float geo_out;
    369 				void main()
    370 				{
    371 					out0 = geo_out;
    372 					${FRAGMENT_OUTPUT}
    373 				}
    374 			""
    375 		end
    376 
    377 		case input_non_array
    378 			version 310 es
    379 			desc "Geometry shader has no input for an output"
    380 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    381 			expect compile_or_link_fail
    382 			values { output float out0 = 1.0; }
    383 			vertex ""
    384 				#version 310 es
    385 				${VERTEX_DECLARATIONS}
    386 				out mediump float geo_in;
    387 				void main()
    388 				{
    389 					geo_in = 1.0;
    390 					${VERTEX_OUTPUT}
    391 				}
    392 			""
    393 			geometry ""
    394 				#version 310 es
    395 				${GEOMETRY_DECLARATIONS}
    396 				in mediump float geo_in;
    397 				out mediump float geo_out;
    398 				void main()
    399 				{
    400 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    401 					{
    402 						geo_out = geo_in;
    403 						gl_Position = gl_in[ndx].gl_Position;
    404 						EmitVertex();
    405 					}
    406 				}
    407 			""
    408 			fragment ""
    409 				#version 310 es
    410 				precision mediump float;
    411 				${FRAGMENT_DECLARATIONS}
    412 				in mediump float geo_out;
    413 				void main()
    414 				{
    415 					out0 = geo_out;
    416 					${FRAGMENT_OUTPUT}
    417 				}
    418 			""
    419 		end
    420 
    421 		case input_array_size_mismatch
    422 			version 310 es
    423 			desc "Geometry shader input is explicitly sized array, but size does not match input primitive"
    424 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    425 			expect compile_or_link_fail
    426 			values { output float out0 = 1.0; }
    427 			vertex ""
    428 				#version 310 es
    429 				${VERTEX_DECLARATIONS}
    430 				out mediump float geo_in;
    431 				void main()
    432 				{
    433 					geo_in = 1.0;
    434 					${VERTEX_OUTPUT}
    435 				}
    436 			""
    437 			geometry ""
    438 				#version 310 es
    439 				${GEOMETRY_DECLARATIONS}
    440 				in mediump float geo_in[4];
    441 				out mediump float geo_out;
    442 				void main()
    443 				{
    444 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    445 					{
    446 						geo_out = geo_in[ndx+1];
    447 						gl_Position = gl_in[ndx].gl_Position;
    448 						EmitVertex();
    449 					}
    450 				}
    451 			""
    452 			fragment ""
    453 				#version 310 es
    454 				precision mediump float;
    455 				${FRAGMENT_DECLARATIONS}
    456 				in mediump float geo_out;
    457 				void main()
    458 				{
    459 					out0 = geo_out;
    460 					${FRAGMENT_OUTPUT}
    461 				}
    462 			""
    463 		end
    464 
    465 		case input_block
    466 			version 310 es
    467 			desc "Geometry shader input block"
    468 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    469 			require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { vertex }
    470 			values { output float out0 = 1.0; }
    471 			vertex ""
    472 				#version 310 es
    473 				${VERTEX_DECLARATIONS}
    474 				out IOBlockName
    475 				{
    476 					mediump float var;
    477 				} outputInstanceName;
    478 				void main()
    479 				{
    480 					outputInstanceName.var = 1.0;
    481 					${VERTEX_OUTPUT}
    482 				}
    483 			""
    484 			geometry ""
    485 				#version 310 es
    486 				${GEOMETRY_DECLARATIONS}
    487 				in IOBlockName
    488 				{
    489 					mediump float var;
    490 				} inputInstanceName[];
    491 				out mediump float geo_out;
    492 				void main()
    493 				{
    494 					geo_out = inputInstanceName[0].var;
    495 					gl_Position = gl_in[0].gl_Position;
    496 					EmitVertex();
    497 					geo_out = inputInstanceName[1].var;
    498 					gl_Position = gl_in[1].gl_Position;
    499 					EmitVertex();
    500 					geo_out = inputInstanceName[2].var;
    501 					gl_Position = gl_in[2].gl_Position;
    502 					EmitVertex();
    503 				}
    504 			""
    505 			fragment ""
    506 				#version 310 es
    507 				precision mediump float;
    508 				${FRAGMENT_DECLARATIONS}
    509 				in mediump float geo_out;
    510 				void main()
    511 				{
    512 					out0 = geo_out;
    513 					${FRAGMENT_OUTPUT}
    514 				}
    515 			""
    516 		end
    517 
    518 		case input_block_explicit_size
    519 			version 310 es
    520 			desc "Geometry shader input block with explicit size"
    521 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    522 			require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { vertex }
    523 			values { output float out0 = 1.0; }
    524 			vertex ""
    525 				#version 310 es
    526 				${VERTEX_DECLARATIONS}
    527 				out IOBlockName
    528 				{
    529 					mediump float var;
    530 				} outputInstanceName;
    531 				void main()
    532 				{
    533 					outputInstanceName.var = 1.0;
    534 					${VERTEX_OUTPUT}
    535 				}
    536 			""
    537 			geometry ""
    538 				#version 310 es
    539 				${GEOMETRY_DECLARATIONS}
    540 				in IOBlockName
    541 				{
    542 					mediump float var;
    543 				} inputInstanceName[3];
    544 				out mediump float geo_out;
    545 				void main()
    546 				{
    547 					geo_out = inputInstanceName[0].var;
    548 					gl_Position = gl_in[0].gl_Position;
    549 					EmitVertex();
    550 					geo_out = inputInstanceName[1].var;
    551 					gl_Position = gl_in[1].gl_Position;
    552 					EmitVertex();
    553 					geo_out = inputInstanceName[2].var;
    554 					gl_Position = gl_in[2].gl_Position;
    555 					EmitVertex();
    556 				}
    557 			""
    558 			fragment ""
    559 				#version 310 es
    560 				precision mediump float;
    561 				${FRAGMENT_DECLARATIONS}
    562 				in mediump float geo_out;
    563 				void main()
    564 				{
    565 					out0 = geo_out;
    566 					${FRAGMENT_OUTPUT}
    567 				}
    568 			""
    569 		end
    570 
    571 		case input_block_non_array
    572 			version 310 es
    573 			desc "Geometry shader input block is non an array"
    574 			expect compile_or_link_fail
    575 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    576 			require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { vertex }
    577 			values { output float out0 = 1.0; }
    578 			vertex ""
    579 				#version 310 es
    580 				${VERTEX_DECLARATIONS}
    581 				out IOBlockName
    582 				{
    583 					mediump float var;
    584 				} outputInstanceName;
    585 				void main()
    586 				{
    587 					outputInstanceName.var = 1.0;
    588 					${VERTEX_OUTPUT}
    589 				}
    590 			""
    591 			geometry ""
    592 				#version 310 es
    593 				${GEOMETRY_DECLARATIONS}
    594 				in IOBlockName
    595 				{
    596 					mediump float var;
    597 				} inputInstanceName;
    598 				out mediump float geo_out;
    599 				void main()
    600 				{
    601 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    602 					{
    603 						geo_out = inputInstanceName.var;
    604 						gl_Position = gl_in[ndx].gl_Position;
    605 						EmitVertex();
    606 					}
    607 				}
    608 			""
    609 			fragment ""
    610 				#version 310 es
    611 				precision mediump float;
    612 				${FRAGMENT_DECLARATIONS}
    613 				in mediump float geo_out;
    614 				void main()
    615 				{
    616 					out0 = geo_out;
    617 					${FRAGMENT_OUTPUT}
    618 				}
    619 			""
    620 		end
    621 
    622 		case input_block_array_size_mismatch
    623 			version 310 es
    624 			desc "Geometry shader input block invalid array size"
    625 			expect compile_or_link_fail
    626 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    627 			require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { vertex }
    628 			values { output float out0 = 1.0; }
    629 			vertex ""
    630 				#version 310 es
    631 				${VERTEX_DECLARATIONS}
    632 				out IOBlockName
    633 				{
    634 					mediump float var;
    635 				} outputInstanceName;
    636 				void main()
    637 				{
    638 					outputInstanceName.var = 1.0;
    639 					${VERTEX_OUTPUT}
    640 				}
    641 			""
    642 			geometry ""
    643 				#version 310 es
    644 				${GEOMETRY_DECLARATIONS}
    645 				in IOBlockName
    646 				{
    647 					mediump float var;
    648 				} inputInstanceName[4];
    649 				out mediump float geo_out;
    650 				void main()
    651 				{
    652 					geo_out = inputInstanceName[0].var;
    653 					gl_Position = gl_in[0].gl_Position;
    654 					EmitVertex();
    655 					geo_out = inputInstanceName[1].var;
    656 					gl_Position = gl_in[1].gl_Position;
    657 					EmitVertex();
    658 					geo_out = inputInstanceName[2].var + inputInstanceName[3].var;
    659 					gl_Position = gl_in[2].gl_Position;
    660 					EmitVertex();
    661 				}
    662 			""
    663 			fragment ""
    664 				#version 310 es
    665 				precision mediump float;
    666 				${FRAGMENT_DECLARATIONS}
    667 				in mediump float geo_out;
    668 				void main()
    669 				{
    670 					out0 = geo_out;
    671 					${FRAGMENT_OUTPUT}
    672 				}
    673 			""
    674 		end
    675 
    676 		case output_block
    677 			version 310 es
    678 			desc "Geometry shader output block"
    679 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    680 			require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { fragment }
    681 			values { output float out0 = 1.0; }
    682 			vertex ""
    683 				#version 310 es
    684 				${VERTEX_DECLARATIONS}
    685 				void main()
    686 				{
    687 					${VERTEX_OUTPUT}
    688 				}
    689 			""
    690 			geometry ""
    691 				#version 310 es
    692 				${GEOMETRY_DECLARATIONS}
    693 				out IOBlockName
    694 				{
    695 					mediump float var;
    696 				} outputInstanceName;
    697 				void main()
    698 				{
    699 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    700 					{
    701 						outputInstanceName.var = 1.0;
    702 						gl_Position = gl_in[ndx].gl_Position;
    703 						EmitVertex();
    704 					}
    705 				}
    706 			""
    707 			fragment ""
    708 				#version 310 es
    709 				precision mediump float;
    710 				${FRAGMENT_DECLARATIONS}
    711 				in IOBlockName
    712 				{
    713 					mediump float var;
    714 				} inputInstanceName;
    715 				void main()
    716 				{
    717 					out0 = inputInstanceName.var;
    718 					${FRAGMENT_OUTPUT}
    719 				}
    720 			""
    721 		end
    722 
    723 		case output_block_array
    724 			version 310 es
    725 			desc "Geometry shader output block array"
    726 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    727 			require extension { "GL_OES_shader_io_blocks" | "GL_EXT_shader_io_blocks" } in { fragment }
    728 			values { output float out0 = 1.0; }
    729 			vertex ""
    730 				#version 310 es
    731 				${VERTEX_DECLARATIONS}
    732 				void main()
    733 				{
    734 					${VERTEX_OUTPUT}
    735 				}
    736 			""
    737 			geometry ""
    738 				#version 310 es
    739 				${GEOMETRY_DECLARATIONS}
    740 				out IOBlockName
    741 				{
    742 					mediump float var;
    743 				} outputInstanceName[2];
    744 				void main()
    745 				{
    746 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    747 					{
    748 						outputInstanceName[0].var = 2.0;
    749 						outputInstanceName[1].var = 1.0;
    750 						gl_Position = gl_in[ndx].gl_Position;
    751 						EmitVertex();
    752 					}
    753 				}
    754 			""
    755 			fragment ""
    756 				#version 310 es
    757 				precision mediump float;
    758 				${FRAGMENT_DECLARATIONS}
    759 				in IOBlockName
    760 				{
    761 					mediump float var;
    762 				} inputInstanceName[2];
    763 				void main()
    764 				{
    765 					out0 = inputInstanceName[0].var - inputInstanceName[1].var;
    766 					${FRAGMENT_OUTPUT}
    767 				}
    768 			""
    769 		end
    770 
    771 		case unspecified_input_primitive_type
    772 			version 310 es
    773 			desc "Geometry shader input type unspecified"
    774 			expect compile_or_link_fail
    775 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    776 			vertex ""
    777 				#version 310 es
    778 				${VERTEX_DECLARATIONS}
    779 				void main()
    780 				{
    781 					${VERTEX_OUTPUT}
    782 				}
    783 			""
    784 			geometry ""
    785 				#version 310 es
    786 				layout (triangle_strip, max_vertices=3) out;
    787 				void main()
    788 				{
    789 					gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
    790 					EmitVertex();
    791 					gl_Position = vec4(0.0, 1.0, 0.0, 1.0);
    792 					EmitVertex();
    793 					gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
    794 					EmitVertex();
    795 				}
    796 			""
    797 			fragment ""
    798 				#version 310 es
    799 				precision mediump float;
    800 				${FRAGMENT_DECLARATIONS}
    801 				void main()
    802 				{
    803 					${FRAGMENT_OUTPUT}
    804 				}
    805 			""
    806 		end
    807 
    808 		case unspecified_output_primitive_type
    809 			version 310 es
    810 			desc "Geometry shader output type unspecified"
    811 			expect compile_or_link_fail
    812 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    813 			vertex ""
    814 				#version 310 es
    815 				${VERTEX_DECLARATIONS}
    816 				void main()
    817 				{
    818 					${VERTEX_OUTPUT}
    819 				}
    820 			""
    821 			geometry ""
    822 				#version 310 es
    823 				layout (triangles) in;
    824 				layout (max_vertices=3) out;
    825 				void main()
    826 				{
    827 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    828 					{
    829 						gl_Position = gl_in[ndx].gl_Position;
    830 						EmitVertex();
    831 					}
    832 				}
    833 			""
    834 			fragment ""
    835 				#version 310 es
    836 				precision mediump float;
    837 				${FRAGMENT_DECLARATIONS}
    838 				void main()
    839 				{
    840 					${FRAGMENT_OUTPUT}
    841 				}
    842 			""
    843 		end
    844 
    845 		case unspecified_output_primitive_num_vertices
    846 			version 310 es
    847 			desc "Geometry shader output type unspecified"
    848 			expect compile_or_link_fail
    849 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    850 			vertex ""
    851 				#version 310 es
    852 				${VERTEX_DECLARATIONS}
    853 				void main()
    854 				{
    855 					${VERTEX_OUTPUT}
    856 				}
    857 			""
    858 			geometry ""
    859 				#version 310 es
    860 				layout (triangles) in;
    861 				layout (triangle_strip) out;
    862 				void main()
    863 				{
    864 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    865 					{
    866 						gl_Position = gl_in[ndx].gl_Position;
    867 						EmitVertex();
    868 					}
    869 				}
    870 			""
    871 			fragment ""
    872 				#version 310 es
    873 				precision mediump float;
    874 				${FRAGMENT_DECLARATIONS}
    875 				void main()
    876 				{
    877 					${FRAGMENT_OUTPUT}
    878 				}
    879 			""
    880 		end
    881 
    882 		# access_more_than_available_input_vertices
    883 		case access_more_than_available_input_vertices
    884 			version 310 es
    885 			desc "Geometry shader input block with explicit size"
    886 			expect compile_or_link_fail
    887 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    888 			vertex ""
    889 				#version 310 es
    890 				${VERTEX_DECLARATIONS}
    891 				void main()
    892 				{
    893 					${VERTEX_OUTPUT}
    894 				}
    895 			""
    896 			geometry ""
    897 				#version 310 es
    898 				${GEOMETRY_DECLARATIONS}
    899 				void main()
    900 				{
    901 					gl_Position = gl_in[0].gl_Position;
    902 					EmitVertex();
    903 					gl_Position = gl_in[1].gl_Position;
    904 					EmitVertex();
    905 					gl_Position = gl_in[4].gl_Position; // access more than available
    906 					EmitVertex();
    907 				}
    908 			""
    909 			fragment ""
    910 				#version 310 es
    911 				precision mediump float;
    912 				${FRAGMENT_DECLARATIONS}
    913 				void main()
    914 				{
    915 					${FRAGMENT_OUTPUT}
    916 				}
    917 			""
    918 		end
    919 	end
    920 
    921 	import "linkage_geometry_varying_types.test"
    922 
    923 	group qualifiers "Varying qualifiers"
    924 		case smooth
    925 			version 310 es
    926 			desc "varying with smooth interpolation"
    927 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    928 			values
    929 			{
    930 				input float in0		= 1.0;
    931 				output float out0	= 1.0;
    932 			}
    933 			vertex ""
    934 				#version 310 es
    935 				${VERTEX_DECLARATIONS}
    936 				smooth out mediump float vtx_var;
    937 				void main()
    938 				{
    939 					vtx_var = in0;
    940 					${VERTEX_OUTPUT}
    941 				}
    942 			""
    943 			geometry ""
    944 				#version 310 es
    945 				${GEOMETRY_DECLARATIONS}
    946 				smooth in mediump float vtx_var[];
    947 				smooth out mediump float geo_var;
    948 				void main()
    949 				{
    950 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    951 					{
    952 						geo_var = vtx_var[ndx];
    953 						gl_Position = gl_in[ndx].gl_Position;
    954 						EmitVertex();
    955 					}
    956 				}
    957 			""
    958 			fragment ""
    959 				#version 310 es
    960 				precision mediump float;
    961 				${FRAGMENT_DECLARATIONS}
    962 				smooth in float geo_var;
    963 				void main()
    964 				{
    965 					out0 = geo_var;
    966 					${FRAGMENT_OUTPUT}
    967 				}
    968 			""
    969 		end
    970 
    971 		case flat
    972 			version 310 es
    973 			desc "varying with flat interpolation"
    974 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
    975 			values
    976 			{
    977 				input float in0		= 1.0;
    978 				output float out0	= 1.0;
    979 			}
    980 			vertex ""
    981 				#version 310 es
    982 				${VERTEX_DECLARATIONS}
    983 				flat out mediump float vtx_var;
    984 				void main()
    985 				{
    986 					vtx_var = in0;
    987 					${VERTEX_OUTPUT}
    988 				}
    989 			""
    990 			geometry ""
    991 				#version 310 es
    992 				${GEOMETRY_DECLARATIONS}
    993 				flat in mediump float vtx_var[];
    994 				flat out mediump float geo_var;
    995 				void main()
    996 				{
    997 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    998 					{
    999 						geo_var = vtx_var[ndx];
   1000 						gl_Position = gl_in[ndx].gl_Position;
   1001 						EmitVertex();
   1002 					}
   1003 				}
   1004 			""
   1005 			fragment ""
   1006 				#version 310 es
   1007 				precision mediump float;
   1008 				${FRAGMENT_DECLARATIONS}
   1009 				flat in float geo_var;
   1010 				void main()
   1011 				{
   1012 					out0 = geo_var;
   1013 					${FRAGMENT_OUTPUT}
   1014 				}
   1015 			""
   1016 		end
   1017 
   1018 		case centroid
   1019 			version 310 es
   1020 			desc "varying declared with centroid qualifier"
   1021 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1022 			values
   1023 			{
   1024 				input float in0		= 1.0;
   1025 				output float out0	= 1.0;
   1026 			}
   1027 			vertex ""
   1028 				#version 310 es
   1029 				${VERTEX_DECLARATIONS}
   1030 				centroid out mediump float vtx_var;
   1031 				void main()
   1032 				{
   1033 					vtx_var = in0;
   1034 					${VERTEX_OUTPUT}
   1035 				}
   1036 			""
   1037 			geometry ""
   1038 				#version 310 es
   1039 				${GEOMETRY_DECLARATIONS}
   1040 				centroid in mediump float vtx_var[];
   1041 				centroid out mediump float geo_var;
   1042 				void main()
   1043 				{
   1044 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1045 					{
   1046 						geo_var = vtx_var[ndx];
   1047 						gl_Position = gl_in[ndx].gl_Position;
   1048 						EmitVertex();
   1049 					}
   1050 				}
   1051 			""
   1052 			fragment ""
   1053 				#version 310 es
   1054 				precision mediump float;
   1055 				${FRAGMENT_DECLARATIONS}
   1056 				centroid in float geo_var;
   1057 				void main()
   1058 				{
   1059 					out0 = geo_var;
   1060 					${FRAGMENT_OUTPUT}
   1061 				}
   1062 			""
   1063 		end
   1064 
   1065 		case sample
   1066 			version 310 es
   1067 			desc "varying declared with sample qualifier"
   1068 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1069 			require extension { "GL_OES_shader_multisample_interpolation" }
   1070 			values
   1071 			{
   1072 				input float in0		= 1.0;
   1073 				output float out0	= 1.0;
   1074 			}
   1075 			vertex ""
   1076 				#version 310 es
   1077 				${VERTEX_DECLARATIONS}
   1078 				sample out mediump float vtx_var;
   1079 				void main()
   1080 				{
   1081 					vtx_var = in0;
   1082 					${VERTEX_OUTPUT}
   1083 				}
   1084 			""
   1085 			geometry ""
   1086 				#version 310 es
   1087 				${GEOMETRY_DECLARATIONS}
   1088 				sample in mediump float vtx_var[];
   1089 				sample out mediump float geo_var;
   1090 				void main()
   1091 				{
   1092 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1093 					{
   1094 						geo_var = vtx_var[ndx];
   1095 						gl_Position = gl_in[ndx].gl_Position;
   1096 						EmitVertex();
   1097 					}
   1098 				}
   1099 			""
   1100 			fragment ""
   1101 				#version 310 es
   1102 				precision mediump float;
   1103 				${FRAGMENT_DECLARATIONS}
   1104 				sample in float geo_var;
   1105 				void main()
   1106 				{
   1107 					out0 = geo_var;
   1108 					${FRAGMENT_OUTPUT}
   1109 				}
   1110 			""
   1111 		end
   1112 	end
   1113 end
   1114 
   1115 group uniform "Uniform linkage"
   1116 	group rules "Rules"
   1117 
   1118 		case type_mismatch_1
   1119 			version 310 es
   1120 			desc "uniforms declared with different types"
   1121 			expect link_fail
   1122 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1123 			vertex ""
   1124 				#version 310 es
   1125 				${VERTEX_DECLARATIONS}
   1126 				uniform mediump float u_var;
   1127 				out mediump float vtx_var;
   1128 				void main()
   1129 				{
   1130 					vtx_var = u_var;
   1131 					${VERTEX_OUTPUT}
   1132 				}
   1133 			""
   1134 			geometry ""
   1135 				#version 310 es
   1136 				${GEOMETRY_DECLARATIONS}
   1137 				uniform mediump vec4 u_var;
   1138 				in mediump float vtx_var[];
   1139 				out mediump float geo_var;
   1140 				void main()
   1141 				{
   1142 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1143 					{
   1144 						geo_var = vtx_var[ndx];
   1145 						gl_Position = gl_in[ndx].gl_Position + u_var;
   1146 						EmitVertex();
   1147 					}
   1148 				}
   1149 			""
   1150 			fragment ""
   1151 				#version 310 es
   1152 				precision mediump float;
   1153 				${FRAGMENT_DECLARATIONS}
   1154 				in float geo_var;
   1155 				void main()
   1156 				{
   1157 					${FRAG_COLOR} = vec4(geo_var);
   1158 				}
   1159 			""
   1160 		end
   1161 
   1162 		case type_mismatch_2
   1163 			version 310 es
   1164 			desc "uniforms declared with different types"
   1165 			expect link_fail
   1166 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1167 			require limit "GL_MAX_VERTEX_ATOMIC_COUNTERS" > 0
   1168 			vertex ""
   1169 				#version 310 es
   1170 				${VERTEX_DECLARATIONS}
   1171 				layout(binding=0) uniform atomic_uint u_var;
   1172 				out mediump float vtx_var;
   1173 				void main()
   1174 				{
   1175 					uint result = atomicCounterIncrement(u_var);
   1176 					vtx_var = float(result);
   1177 					${VERTEX_OUTPUT}
   1178 				}
   1179 			""
   1180 			geometry ""
   1181 				#version 310 es
   1182 				${GEOMETRY_DECLARATIONS}
   1183 				uniform mediump vec4 u_var;
   1184 				in mediump float vtx_var[];
   1185 				out mediump float geo_var;
   1186 				void main()
   1187 				{
   1188 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1189 					{
   1190 						geo_var = vtx_var[ndx];
   1191 						gl_Position = gl_in[ndx].gl_Position + u_var;
   1192 						EmitVertex();
   1193 					}
   1194 				}
   1195 			""
   1196 			fragment ""
   1197 				#version 310 es
   1198 				precision mediump float;
   1199 				${FRAGMENT_DECLARATIONS}
   1200 				in float geo_var;
   1201 				void main()
   1202 				{
   1203 					${FRAG_COLOR} = vec4(geo_var);
   1204 				}
   1205 			""
   1206 		end
   1207 
   1208 		case type_mismatch_3
   1209 			version 310 es
   1210 			desc "uniforms declared with different types"
   1211 			expect link_fail
   1212 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1213 			require limit "GL_MAX_VERTEX_IMAGE_UNIFORMS" > 0
   1214 			vertex ""
   1215 				#version 310 es
   1216 				${VERTEX_DECLARATIONS}
   1217 				layout(binding=0) layout(rgba8i) uniform iimage2D u_var;
   1218 				out mediump float vtx_var;
   1219 				void main()
   1220 				{
   1221 					int result = imageSize(u_var).x;
   1222 					vtx_var = float(result);
   1223 					${VERTEX_OUTPUT}
   1224 				}
   1225 			""
   1226 			geometry ""
   1227 				#version 310 es
   1228 				${GEOMETRY_DECLARATIONS}
   1229 				uniform mediump vec4 u_var;
   1230 				in mediump float vtx_var[];
   1231 				out mediump float geo_var;
   1232 				void main()
   1233 				{
   1234 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1235 					{
   1236 						geo_var = vtx_var[ndx];
   1237 						gl_Position = gl_in[ndx].gl_Position + u_var;
   1238 						EmitVertex();
   1239 					}
   1240 				}
   1241 			""
   1242 			fragment ""
   1243 				#version 310 es
   1244 				precision mediump float;
   1245 				${FRAGMENT_DECLARATIONS}
   1246 				in float geo_var;
   1247 				void main()
   1248 				{
   1249 					${FRAG_COLOR} = vec4(geo_var);
   1250 				}
   1251 			""
   1252 		end
   1253 
   1254 		case precision_mismatch
   1255 			version 310 es
   1256 			desc "uniforms declared with different precisions"
   1257 			expect link_fail
   1258 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1259 			vertex ""
   1260 				#version 310 es
   1261 				${VERTEX_DECLARATIONS}
   1262 				uniform highp float u_var;
   1263 				out mediump float vtx_var;
   1264 				void main()
   1265 				{
   1266 					vtx_var = u_var;
   1267 					${VERTEX_OUTPUT}
   1268 				}
   1269 			""
   1270 			geometry ""
   1271 				#version 310 es
   1272 				${GEOMETRY_DECLARATIONS}
   1273 				uniform mediump float u_var;
   1274 				in mediump float vtx_var[];
   1275 				out mediump float geo_var;
   1276 				void main()
   1277 				{
   1278 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1279 					{
   1280 						geo_var = vtx_var[ndx];
   1281 						gl_Position = gl_in[ndx].gl_Position + vec4(u_var);
   1282 						EmitVertex();
   1283 					}
   1284 				}
   1285 			""
   1286 			fragment ""
   1287 				#version 310 es
   1288 				precision mediump float;
   1289 				${FRAGMENT_DECLARATIONS}
   1290 				in float geo_var;
   1291 				void main()
   1292 				{
   1293 					${FRAG_COLOR} = vec4(geo_var);
   1294 				}
   1295 			""
   1296 		end
   1297 
   1298 		case struct_partial_usage
   1299 			version 310 es
   1300 			desc "uniforms struct used partially in different stages"
   1301 			require extension { "GL_OES_geometry_shader" | "GL_EXT_geometry_shader" } in { geometry }
   1302 			values
   1303 			{
   1304 				uniform float val.vtxValue	= 1.0;
   1305 				uniform float val.geoValue	= 1.0;
   1306 				uniform float val.frgValue	= 1.0;
   1307 			}
   1308 			vertex ""
   1309 				#version 310 es
   1310 				${VERTEX_DECLARATIONS}
   1311 				struct S
   1312 				{
   1313 					mediump float vtxValue;
   1314 					mediump float geoValue;
   1315 					mediump float frgValue;
   1316 				};
   1317 				uniform S val;
   1318 				out mediump float vtx_var;
   1319 				void main()
   1320 				{
   1321 					vtx_var = val.vtxValue;
   1322 					${VERTEX_OUTPUT}
   1323 				}
   1324 			""
   1325 			geometry ""
   1326 				#version 310 es
   1327 				${GEOMETRY_DECLARATIONS}
   1328 				struct S
   1329 				{
   1330 					mediump float vtxValue;
   1331 					mediump float geoValue;
   1332 					mediump float frgValue;
   1333 				};
   1334 				uniform S val;
   1335 				in mediump float vtx_var[];
   1336 				out mediump float geo_var;
   1337 				void main()
   1338 				{
   1339 					for (int ndx = 0; ndx < gl_in.length(); ++ndx)
   1340 					{
   1341 						geo_var = vtx_var[ndx] + val.geoValue;
   1342 						gl_Position = gl_in[ndx].gl_Position;
   1343 						EmitVertex();
   1344 					}
   1345 				}
   1346 			""
   1347 			fragment ""
   1348 				#version 310 es
   1349 				precision mediump float;
   1350 				${FRAGMENT_DECLARATIONS}
   1351 				struct S
   1352 				{
   1353 					mediump float vtxValue;
   1354 					mediump float geoValue;
   1355 					mediump float frgValue;
   1356 				};
   1357 				uniform S val;
   1358 				in float geo_var;
   1359 				void main()
   1360 				{
   1361 					${FRAG_COLOR} = vec4(geo_var + val.frgValue);
   1362 				}
   1363 			""
   1364 		end
   1365 	end
   1366 
   1367 	import "linkage_geometry_uniform_types.test"
   1368 end
   1369