Home | History | Annotate | Download | only in shaders
      1 case float_input
      2 	values
      3 	{
      4 		input float in0		= [ 1.123 | 0.75 | -512.0 | -72.13 | 199.91 ];
      5 		output float out0	= [ 1.123 | 0.75 | -512.0 | -72.13 | 199.91 ];
      6 	}
      7 	values
      8 	{
      9 		input float in0		= [ -1.123 | -0.75 | 512.0 | -72.13 | -199.91 ];
     10 		output float out0	= [ -1.123 | -0.75 | 512.0 | -72.13 | -199.91 ];
     11 	}
     12 
     13 	both ""
     14 		precision highp float;
     15 		${DECLARATIONS}
     16 		void main()
     17 		{
     18 			out0 = in0;
     19 			${OUTPUT}
     20 		}
     21 	""
     22 end
     23 
     24 case float_uniform
     25 	values
     26 	{
     27 		uniform float uni0	= [ 1.123 | 0.75 | -512.0 | -72.13 | 199.91 ];
     28 		output float out0	= [ 1.123 | 0.75 | -512.0 | -72.13 | 199.91 ];
     29 	}
     30 
     31 	both ""
     32 		precision highp float;
     33 		${DECLARATIONS}
     34 		uniform float uni0;
     35 		void main()
     36 		{
     37 			out0 = uni0;
     38 			${OUTPUT}
     39 		}
     40 	""
     41 end
     42 
     43 case float_0
     44 	values { output float out0 = 1.123; }
     45 	both ""
     46 		precision highp float;
     47 		${DECLARATIONS}
     48 		void main()
     49 		{
     50 			out0 = +1.123;
     51 			${OUTPUT}
     52 		}
     53 	""
     54 end
     55 
     56 case float_1
     57 	values { output float out0 = -1.123; }
     58 	both ""
     59 		precision highp float;
     60 		${DECLARATIONS}
     61 		void main()
     62 		{
     63 			out0 = -1.123;
     64 			${OUTPUT}
     65 		}
     66 	""
     67 end
     68 
     69 case float_2
     70 	values { output float out0 = 123.0; }
     71 	both ""
     72 		precision highp float;
     73 		${DECLARATIONS}
     74 		void main()
     75 		{
     76 			out0 = 123.;
     77 			${OUTPUT}
     78 		}
     79 	""
     80 end
     81 
     82 case float_3
     83 	values { output float out0 = 0.123; }
     84 	both ""
     85 		precision highp float;
     86 		${DECLARATIONS}
     87 		void main()
     88 		{
     89 			out0 = .123;
     90 			${OUTPUT}
     91 		}
     92 	""
     93 end
     94 
     95 case float_4
     96 	values { output float out0 = 123.0; }
     97 	both ""
     98 		precision highp float;
     99 		${DECLARATIONS}
    100 		void main()
    101 		{
    102 			out0 = 1.23e+2;
    103 			${OUTPUT}
    104 		}
    105 	""
    106 end
    107 
    108 case float_5
    109 	values { output float out0 = -123.0; }
    110 	both ""
    111 		precision highp float;
    112 		${DECLARATIONS}
    113 		void main()
    114 		{
    115 			out0 = -1.23E+2;
    116 			${OUTPUT}
    117 		}
    118 	""
    119 end
    120 
    121 case float_6
    122 	values { output float out0 = -123.0; }
    123 	both ""
    124 		precision highp float;
    125 		${DECLARATIONS}
    126 		void main()
    127 		{
    128 			out0 = -1.23e2;
    129 			${OUTPUT}
    130 		}
    131 	""
    132 end
    133 
    134 case float_7
    135 	values { output float out0 = 0.123; }
    136 	both ""
    137 		precision highp float;
    138 		${DECLARATIONS}
    139 		void main()
    140 		{
    141 			out0 = 1.23e-1;
    142 			${OUTPUT}
    143 		}
    144 	""
    145 end
    146 
    147 case float_8
    148 	values { output float out0 = 1000.0; }
    149 	both ""
    150 		precision highp float;
    151 		${DECLARATIONS}
    152 		void main()
    153 		{
    154 			out0 = 1e3;
    155 			${OUTPUT}
    156 		}
    157 	""
    158 end
    159 
    160 case int_0
    161 	values { output int out0 = 123; }
    162 	both ""
    163 		precision highp float;
    164 		${DECLARATIONS}
    165 		void main()
    166 		{
    167 			out0 = 123;
    168 			${OUTPUT}
    169 		}
    170 	""
    171 end
    172 
    173 case int_1
    174 	values { output int out0 = -321; }
    175 	both ""
    176 		precision highp float;
    177 		${DECLARATIONS}
    178 		void main()
    179 		{
    180 			out0 = -321;
    181 			${OUTPUT}
    182 		}
    183 	""
    184 end
    185 
    186 case int_2
    187 	values { output int out0 = 123; }
    188 	both ""
    189 		precision highp float;
    190 		${DECLARATIONS}
    191 		void main()
    192 		{
    193 			out0 = 0x7B;
    194 			${OUTPUT}
    195 		}
    196 	""
    197 end
    198 
    199 case int_3
    200 	values { output int out0 = 123; }
    201 	both ""
    202 		precision highp float;
    203 		${DECLARATIONS}
    204 		void main()
    205 		{
    206 			out0 = 0X7b;
    207 			${OUTPUT}
    208 		}
    209 	""
    210 end
    211 
    212 case int_4
    213 	values { output int out0 = 123; }
    214 	both ""
    215 		precision highp float;
    216 		${DECLARATIONS}
    217 		void main()
    218 		{
    219 			out0 = 0173;
    220 			${OUTPUT}
    221 		}
    222 	""
    223 end
    224 
    225 case bool_0
    226 	values { output bool out0 = true; }
    227 	both ""
    228 		precision highp float;
    229 		${DECLARATIONS}
    230 		void main()
    231 		{
    232 			out0 = true;
    233 			${OUTPUT}
    234 		}
    235 	""
    236 end
    237 
    238 case bool_1
    239 	values { output bool out0 = false; }
    240 	both ""
    241 		precision highp float;
    242 		${DECLARATIONS}
    243 		void main()
    244 		{
    245 			out0 = false;
    246 			${OUTPUT}
    247 		}
    248 	""
    249 end
    250 
    251 case const_float_global
    252 	 values { output float out0 = 1000.0; }
    253 	 
    254 	 both ""
    255 	 	  precision mediump float;
    256 	 	  ${DECLARATIONS}
    257 		  const float theConstant = 1000.0;
    258 		  void main()
    259 		  {
    260 				out0 = theConstant;
    261 				${OUTPUT}
    262 		  }
    263 	 ""
    264 end
    265 
    266 case const_float_main
    267 	 values { output float out0 = -1000.0; }
    268 	 
    269 	 both ""
    270 	 	  precision mediump float;
    271 	 	  ${DECLARATIONS}
    272 		  void main()
    273 		  {
    274 		  	    const float theConstant = -1000.0;
    275 				out0 = theConstant;
    276 				${OUTPUT}
    277 		  }
    278 	 ""
    279 end
    280 
    281 case const_float_function
    282 	 values { output float out0 = -0.012; }
    283 	 
    284 	 both ""
    285 	 	  precision mediump float;
    286 	 	  ${DECLARATIONS}
    287 		  float func()
    288 		  {
    289 		  	    const float theConstant = -0.012;
    290 				return theConstant;				
    291 		  }
    292 		  void main()
    293 		  {
    294 				out0 = func();
    295 				${OUTPUT}
    296 		  }
    297 	 ""
    298 end
    299 
    300 case const_float_scope
    301 	 values { output float out0 = 1.0; }
    302 	 
    303 	 both ""
    304 	 	  precision mediump float;
    305 	 	  ${DECLARATIONS}
    306 		  void main()
    307 		  {
    308 				{
    309 					 const float theConstant = 1.0;
    310 					 out0 = theConstant;
    311 			    }
    312 				${OUTPUT}
    313 		  }
    314 	 ""
    315 end
    316 
    317 case const_float_scope_shawdowing_1
    318 	 values { output float out0 = 1.0; }
    319 	 
    320 	 both ""
    321 	 	  precision mediump float;
    322 	 	  ${DECLARATIONS}
    323 		  void main()
    324 		  {
    325 			    const float theConstant = 100.0;
    326 				{
    327 					 const float theConstant = 1.0;
    328 					 out0 = theConstant;
    329 			    }
    330 				${OUTPUT}
    331 		  }
    332 	 ""
    333 end
    334 
    335 case const_float_scope_shawdowing_2
    336 	 values { output float out0 = 1.0; }
    337 	 
    338 	 both ""
    339 	 	  precision mediump float;
    340    	      ${DECLARATIONS}
    341 		  const float theConstant = 100.0;
    342 		  void main()
    343 		  {
    344 				{
    345 					 const float theConstant = 1.0;
    346 					 out0 = theConstant;
    347 			    }
    348 				${OUTPUT}
    349 		  }
    350 	 ""
    351 end
    352 
    353 case const_float_scope_shawdowing_3
    354 	 values { output float out0 = 1.0; }
    355 	 
    356 	 both ""
    357 	 	  precision mediump float;
    358    	      ${DECLARATIONS}
    359 		  const float theConstant = 100.0;
    360 		  void main()
    361 		  {
    362  			    const float theConstant = -100.0;
    363 				{
    364 					 const float theConstant = 1.0;
    365 					 out0 = theConstant;
    366 			    }
    367 				${OUTPUT}
    368 		  }
    369 	 ""
    370 end
    371 
    372 case const_float_scope_shawdowing_4
    373 	 values { output float out0 = 2.0; }
    374 	 
    375 	 both ""
    376 	 	  precision mediump float;
    377    	      ${DECLARATIONS}
    378 		  const float theConstant = 100.0;
    379 		  float func()
    380 		  {
    381 				const float theConstant = 2.0;
    382 				return theConstant;
    383 		  }
    384 		  void main()
    385 		  {
    386  			    const float theConstant = -100.0;
    387 				{
    388 					 const float theConstant = 1.0;
    389 					 out0 = func();
    390 			    }
    391 				${OUTPUT}
    392 		  }
    393 	 ""
    394 end
    395 
    396 case const_float_operations_with_const
    397 	 values { output float out0 = 21.0; }
    398 	 
    399 	 both ""
    400 	 	  precision mediump float;
    401    	      ${DECLARATIONS}
    402 		  const float theGlobalConstant = 10.0;
    403 		  float func()
    404 		  {
    405 				const float theConstant = 2.0;
    406 				return theConstant;
    407 		  }
    408 		  void main()
    409 		  {
    410  			    const float theConstant = -100.0;
    411 				{
    412 					 const float theConstant = 1.0;
    413 					 out0 = func() * theGlobalConstant + theConstant;
    414 			    }
    415 				${OUTPUT}
    416 		  }
    417 	 ""
    418 end
    419 
    420 case const_float_assignment_1
    421 	 values { output float out0 = 10.0; }
    422 	 
    423 	 both ""
    424 	 	  precision mediump float;
    425    	      ${DECLARATIONS}
    426 		  void main()
    427 		  {
    428  			    const float theConstant1 = 10.0;
    429 				const float theConstant2 = theConstant1;
    430 				out0 = theConstant2;
    431 				${OUTPUT}
    432 		  }
    433 	 ""
    434 end
    435 
    436 case const_float_assignment_2
    437 	 values { output float out0 = 10.0; }
    438 	 
    439 	 both ""
    440 	 	  precision mediump float;
    441    	      ${DECLARATIONS}
    442 		  void main()
    443 		  {
    444  			    const float theConstant1 = 10.0;
    445 				{
    446 					const float theConstant2 = theConstant1;
    447 					out0 = theConstant2;
    448 				}
    449 				${OUTPUT}
    450 		  }
    451 	 ""
    452 end
    453 
    454 case const_float_assignment_3
    455 	 values { output float out0 = 10.0; }
    456 	 
    457 	 both ""
    458 	 	  precision mediump float;
    459    	      ${DECLARATIONS}
    460 	      const float theConstant1 = 10.0;
    461 		  void main()
    462 		  {
    463 				const float theConstant2 = theConstant1;
    464 				out0 = theConstant2;
    465 				${OUTPUT}
    466 		  }
    467 	 ""
    468 end
    469 
    470 case const_float_assignment_4
    471 	 values { output float out0 = 10.0; }
    472 	 
    473 	 both ""
    474 	 	  precision mediump float;
    475    	      ${DECLARATIONS}
    476 	      const float theConstant1 = 10.0;
    477 		  float func()
    478 		  {
    479 				const float theConstant2 = theConstant1;
    480 				return theConstant2;				
    481 		  }
    482 		  void main()
    483 		  {
    484 				out0 = func();
    485 				${OUTPUT}
    486 		  }
    487 	 ""
    488 end
    489 
    490 case const_float_assign_uniform
    491 	 expect compile_fail	 
    492 	 values { output float out0 = 10.0; }
    493 	 both ""
    494 	 	  precision mediump float;
    495    	      ${DECLARATIONS}
    496 		  uniform float theUniform;
    497 		  void main()
    498 		  {
    499 				const float theConstant = theUniform;
    500 				out0 = theConstant;
    501 				${OUTPUT}
    502 		  }
    503 	 ""
    504 end
    505 
    506 case const_float_assign_varying
    507 	 expect compile_fail	 
    508 	 values { output float out0 = 10.0; }
    509 	 vertex ""
    510    	      ${VERTEX_DECLARATIONS}
    511 		  varying float theVarying;
    512 		  void main()
    513 		  {
    514 				theVarying = 1.0;
    515 				gl_Position = vec(1.0);
    516 		  }	 	
    517 	 ""
    518 	 fragment ""
    519 	 	  precision mediump float;
    520    	      ${FRAGMENT_DECLARATIONS}
    521 		  varying float theVarying;
    522 		  void main()
    523 		  {
    524 				const float theConstant = theVarying;
    525 				out0 = theConstant;
    526 				${FRAGMENT_OUTPUT}
    527 		  }
    528 	 ""
    529 end
    530 
    531 case const_float_function_gotcha
    532 	 desc "Function constant parameters are not really constants, so using them as constant expressions should fail."
    533  	 expect compile_fail	 
    534 	 values { output float out0 = 20.0; }
    535 	 both ""
    536 	 	  precision mediump float;
    537    	      ${DECLARATIONS}
    538 		  float func(const float gotcha)
    539 		  {
    540 				const float theConstant2 = gotcha;
    541 				return theConstant2*2.0;				
    542 		  }
    543 		  void main()
    544 		  {
    545 		  	    const float theConstant = 10.0;
    546 				out0 = func(theConstant);
    547 				${OUTPUT}
    548 		  }
    549 	 ""
    550 end
    551 
    552 case const_float_from_int
    553 	 values { output float out0 = 10.0; }
    554 	 
    555 	 both ""
    556 	 	  precision mediump float;
    557    	      ${DECLARATIONS}
    558 	      const float theConstant = float(10);
    559 		  void main()
    560 		  {
    561 				out0 = theConstant;
    562 				${OUTPUT}
    563 		  }
    564 	 ""
    565 end
    566 
    567 case const_float_from_vec2
    568 	 values { output float out0 = 10.0; }
    569 	 
    570 	 both ""
    571 	 	  precision mediump float;
    572    	      ${DECLARATIONS}
    573 	      const float theConstant = vec2(1.0, 10.0).y;
    574 		  void main()
    575 		  {
    576 				out0 = theConstant;
    577 				${OUTPUT}
    578 		  }
    579 	 ""
    580 end
    581 
    582 case const_float_from_vec3
    583 	 values { output float out0 = 10.0; }
    584 	 
    585 	 both ""
    586 	 	  precision mediump float;
    587    	      ${DECLARATIONS}
    588 	      const float theConstant = vec3(1.0, 10.0, 20.0).y;
    589 		  void main()
    590 		  {
    591 				out0 = theConstant;
    592 				${OUTPUT}
    593 		  }
    594 	 ""
    595 end
    596 
    597 case const_float_from_vec4
    598 	 values { output float out0 = 10.0; }
    599 	 
    600 	 both ""
    601 	 	  precision mediump float;
    602    	      ${DECLARATIONS}
    603 	      const float theConstant = vec4(1.0, 10.0, 20.0, -10.0).y;
    604 		  void main()
    605 		  {
    606 				out0 = theConstant;
    607 				${OUTPUT}
    608 		  }
    609 	 ""
    610 end
    611 
    612 case const_float_assign_variable_1
    613 	 expect compile_fail	 
    614 	 values { output float out0 = 20.0; }
    615 	 both ""
    616 	 	  precision mediump float;
    617    	      ${DECLARATIONS}
    618 		  void main()
    619 		  {
    620 				float theVariable = 20.0;
    621 				const float theConstant = theVariable;
    622 				out0 = theConstant;
    623 				${OUTPUT}
    624 		  }
    625 	 ""
    626 end
    627 
    628 case const_float_assign_variable_2
    629 	 expect compile_fail	 
    630 	 values { output float out0 = 50.0; }
    631 	 both ""
    632 	 	  precision mediump float;
    633    	      ${DECLARATIONS}
    634 		  void main()
    635 		  {
    636 				float theVariable = 20.0;
    637 				theVariable += 30.0;
    638 				const float theConstant = theVariable;
    639 				out0 = theConstant;
    640 				${OUTPUT}
    641 		  }
    642 	 ""
    643 end
    644 
    645 case const_float_assign_user_func
    646 	 expect compile_fail	 
    647 	 values { output float out0 = 50.0; }
    648 	 both ""
    649 	 	  precision mediump float;
    650    	      ${DECLARATIONS}
    651 		  float func()
    652 		  {
    653 				return 50.0;
    654   		  }
    655 		  void main()
    656 		  {
    657 				const float theConstant = func();
    658 				out0 = theConstant;
    659 				${OUTPUT}
    660 		  }
    661 	 ""
    662 end
    663