Home | History | Annotate | Download | only in es32
      1 # -------------------------------------------------
      2 # drawElements Quality Program OpenGL ES 3.2 Module
      3 # -------------------------------------------------
      4 #
      5 # Copyright 2016 The Android Open Source Project
      6 #
      7 # Licensed under the Apache License, Version 2.0 (the "License");
      8 # you may not use this file except in compliance with the License.
      9 # You may obtain a copy of the License at
     10 #
     11 #      http://www.apache.org/licenses/LICENSE-2.0
     12 #
     13 # Unless required by applicable law or agreed to in writing, software
     14 # distributed under the License is distributed on an "AS IS" BASIS,
     15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 # See the License for the specific language governing permissions and
     17 # limitations under the License.
     18 
     19 
     20 group extension_macros "Extension macro definitions"
     21 
     22 	case android_extension_pack_es31a
     23 		version 320 es
     24 		desc "Test GL_ANDROID_extension_pack_es31a macro"
     25 		values
     26 		{
     27 			output float out0 = 1.0;
     28 		}
     29 
     30 		vertex ""
     31 			#version 320 es
     32 			${VERTEX_DECLARATIONS}
     33 
     34 			void main()
     35 			{
     36 				${VERTEX_OUTPUT}
     37 			}
     38 		""
     39 		fragment ""
     40 			#version 320 es
     41 			precision mediump float;
     42 			${FRAGMENT_DECLARATIONS}
     43 
     44 			void main()
     45 			{
     46 				out0 = float(GL_ANDROID_extension_pack_es31a);
     47 				${FRAGMENT_OUTPUT}
     48 			}
     49 		""
     50 	end
     51 end
     52 
     53 group extension_directive "Extension directive"
     54 
     55 	case oes_sample_variables
     56 		version 320 es
     57 		desc "Test oes_sample_variables extension"
     58 		values
     59 		{
     60 			output float out0 = 1.0;
     61 		}
     62 
     63 		vertex ""
     64 			#version 320 es
     65 			${VERTEX_DECLARATIONS}
     66 
     67 			void main()
     68 			{
     69 				${VERTEX_OUTPUT}
     70 			}
     71 		""
     72 		fragment ""
     73 			#version 320 es
     74 			precision mediump float;
     75 			${FRAGMENT_DECLARATIONS}
     76 
     77 			void main()
     78 			{
     79 				out0 = (gl_SampleID < 0) ? (0.0) : (1.0);
     80 				${FRAGMENT_OUTPUT}
     81 			}
     82 		""
     83 	end
     84 
     85 	case oes_shader_image_atomic
     86 		version 320 es
     87 		desc "Test oes_shader_image_atomic extension"
     88 		expect build_successful
     89 
     90 		vertex ""
     91 			#version 320 es
     92 			${VERTEX_DECLARATIONS}
     93 
     94 			void main()
     95 			{
     96 				${VERTEX_OUTPUT}
     97 			}
     98 		""
     99 		fragment ""
    100 			#version 320 es
    101 			precision mediump float;
    102 			${FRAGMENT_DECLARATIONS}
    103 			layout(binding=0, r32i) coherent uniform highp iimage2D u_image;
    104 
    105 			void main()
    106 			{
    107 				if (imageAtomicXor(u_image, ivec2(0, 0), 1) == 0)
    108 					discard;
    109 				${FRAGMENT_OUTPUT}
    110 			}
    111 		""
    112 	end
    113 
    114 	case oes_shader_multisample_interpolation
    115 		version 320 es
    116 		desc "Test oes_shader_multisample_interpolation extension"
    117 		values
    118 		{
    119 			input float in0 = 1.0;
    120 			output float out0 = 1.0;
    121 		}
    122 
    123 		vertex ""
    124 			#version 320 es
    125 			${VERTEX_DECLARATIONS}
    126 			sample out highp float v_var;
    127 
    128 			void main()
    129 			{
    130 				v_var = in0;
    131 				${VERTEX_OUTPUT}
    132 			}
    133 		""
    134 		fragment ""
    135 			#version 320 es
    136 			precision mediump float;
    137 			${FRAGMENT_DECLARATIONS}
    138 			sample in mediump float v_var;
    139 
    140 			void main()
    141 			{
    142 				out0 = v_var;
    143 				${FRAGMENT_OUTPUT}
    144 			}
    145 		""
    146 	end
    147 
    148 	case oes_texture_storage_multisample_2d_array
    149 		version 320 es
    150 		desc "Test oes_texture_storage_multisample_2d_array extension"
    151 		expect build_successful
    152 
    153 		vertex ""
    154 			#version 320 es
    155 			${VERTEX_DECLARATIONS}
    156 
    157 			void main()
    158 			{
    159 				${VERTEX_OUTPUT}
    160 			}
    161 		""
    162 		fragment ""
    163 			#version 320 es
    164 			precision mediump float;
    165 			${FRAGMENT_DECLARATIONS}
    166 			uniform mediump sampler2DMSArray u_sampler;
    167 
    168 			void main()
    169 			{
    170 				if (texelFetch(u_sampler, ivec3(0, 0, 0), 0).r > 0.5)
    171 					discard;
    172 				${FRAGMENT_OUTPUT}
    173 			}
    174 		""
    175 	end
    176 
    177 	case ext_geometry_shader
    178 		version 320 es
    179 		desc "Test ext_geometry_shader extension"
    180 		values
    181 		{
    182 			input float in0 = 1.0;
    183 			output float out0 = 1.0;
    184 		}
    185 
    186 		vertex ""
    187 			#version 320 es
    188 			${VERTEX_DECLARATIONS}
    189 			out highp float geo_in;
    190 			void main()
    191 			{
    192 				geo_in = in0;
    193 				${VERTEX_OUTPUT}
    194 			}
    195 		""
    196 		geometry ""
    197 			#version 320 es
    198 			${GEOMETRY_DECLARATIONS}
    199 			in lowp float geo_in[];
    200 			out mediump float geo_out;
    201 			void main()
    202 			{
    203 				for (int ndx = 0; ndx < gl_in.length(); ++ndx)
    204 				{
    205 					geo_out = geo_in[ndx];
    206 					gl_Position = gl_in[ndx].gl_Position;
    207 					EmitVertex();
    208 				}
    209 			}
    210 		""
    211 		fragment ""
    212 			#version 320 es
    213 			precision mediump float;
    214 			${FRAGMENT_DECLARATIONS}
    215 			in mediump float geo_out;
    216 			void main()
    217 			{
    218 				out0 = geo_out;
    219 				${FRAGMENT_OUTPUT}
    220 			}
    221 		""
    222 	end
    223 
    224 	case ext_gpu_shader5
    225 		version 320 es
    226 		desc "Test ext_gpu_shader5 extension"
    227 		values
    228 		{
    229 			input float in0 = 1.0;
    230 			output float out0 = 2.0;
    231 		}
    232 
    233 		vertex ""
    234 			#version 320 es
    235 			${VERTEX_DECLARATIONS}
    236 			out highp float v_var;
    237 			void main()
    238 			{
    239 				v_var = in0;
    240 				${VERTEX_OUTPUT}
    241 			}
    242 		""
    243 		fragment ""
    244 			#version 320 es
    245 			precision mediump float;
    246 			${FRAGMENT_DECLARATIONS}
    247 			in mediump float v_var;
    248 			void main()
    249 			{
    250 				precise float fmaResult = fma(v_var, v_var, v_var);
    251 				out0 = fmaResult;
    252 				${FRAGMENT_OUTPUT}
    253 			}
    254 		""
    255 	end
    256 
    257 	case ext_primitive_bounding_box
    258 		version 320 es
    259 		desc "Test ext_primitive_bounding_box extension"
    260 		values
    261 		{
    262 			input float in0 = 1.0;
    263 			output float out0 = 1.0;
    264 		}
    265 
    266 		vertex ""
    267 			#version 320 es
    268 			${VERTEX_DECLARATIONS}
    269 			out highp float tc_in;
    270 			void main()
    271 			{
    272 				tc_in = in0;
    273 				${VERTEX_OUTPUT}
    274 			}
    275 		""
    276 		tessellation_control ""
    277 			#version 320 es
    278 			${TESSELLATION_CONTROL_DECLARATIONS}
    279 			in highp float tc_in[];
    280 			out highp float tc_out[];
    281 			void main()
    282 			{
    283 				tc_out[gl_InvocationID] = tc_in[gl_InvocationID];
    284 				// set bounding box to (-1,-1,-1, 1) .. (1,1,1,1)
    285 				gl_BoundingBox[0] = vec4(tc_in[0]-2.0, tc_in[1]-2.0, tc_in[2]-2.0, 1.0);
    286 				gl_BoundingBox[1] = vec4(tc_in[0], tc_in[1], tc_in[2], 1.0);
    287 				${TESSELLATION_CONTROL_OUTPUT}
    288 			}
    289 		""
    290 		tessellation_evaluation ""
    291 			#version 320 es
    292 			${TESSELLATION_EVALUATION_DECLARATIONS}
    293 			in highp float tc_out[];
    294 			out highp float te_out;
    295 			void main()
    296 			{
    297 				te_out = tc_out[2];
    298 				${TESSELLATION_EVALUATION_OUTPUT}
    299 			}
    300 		""
    301 		fragment ""
    302 			#version 320 es
    303 			precision mediump float;
    304 			${FRAGMENT_DECLARATIONS}
    305 			in mediump float te_out;
    306 			void main()
    307 			{
    308 				out0 = te_out;
    309 				${FRAGMENT_OUTPUT}
    310 			}
    311 		""
    312 	end
    313 
    314 	case ext_shader_io_blocks
    315 		version 320 es
    316 		desc "Test ext_shader_io_blocks extension"
    317 		values
    318 		{
    319 			input float in0 = 1.0;
    320 			output float out0 = 1.0;
    321 		}
    322 
    323 		vertex ""
    324 			#version 320 es
    325 			${VERTEX_DECLARATIONS}
    326 			out VaryingIOBlockName { highp float v_var; } instanceName;
    327 			void main()
    328 			{
    329 				instanceName.v_var = in0;
    330 				${VERTEX_OUTPUT}
    331 			}
    332 		""
    333 		fragment ""
    334 			#version 320 es
    335 			precision mediump float;
    336 			${FRAGMENT_DECLARATIONS}
    337 			in VaryingIOBlockName { highp float v_var; } instanceName;
    338 			void main()
    339 			{
    340 				out0 = instanceName.v_var;
    341 				${FRAGMENT_OUTPUT}
    342 			}
    343 		""
    344 	end
    345 
    346 	case ext_tessellation_shader
    347 		version 320 es
    348 		desc "Test ext_tessellation_shader extension"
    349 		values
    350 		{
    351 			input float in0 = 1.0;
    352 			output float out0 = 1.0;
    353 		}
    354 
    355 		vertex ""
    356 			#version 320 es
    357 			${VERTEX_DECLARATIONS}
    358 			out highp float tc_in;
    359 			void main()
    360 			{
    361 				tc_in = in0;
    362 				${VERTEX_OUTPUT}
    363 			}
    364 		""
    365 		tessellation_control ""
    366 			#version 320 es
    367 			${TESSELLATION_CONTROL_DECLARATIONS}
    368 			in highp float tc_in[];
    369 			out highp float tc_out[];
    370 			void main()
    371 			{
    372 				tc_out[gl_InvocationID] = tc_in[gl_InvocationID];
    373 				${TESSELLATION_CONTROL_OUTPUT}
    374 			}
    375 		""
    376 		tessellation_evaluation ""
    377 			#version 320 es
    378 			${TESSELLATION_EVALUATION_DECLARATIONS}
    379 			in highp float tc_out[];
    380 			out highp float te_out;
    381 			void main()
    382 			{
    383 				te_out = tc_out[2];
    384 				${TESSELLATION_EVALUATION_OUTPUT}
    385 			}
    386 		""
    387 		fragment ""
    388 			#version 320 es
    389 			precision mediump float;
    390 			${FRAGMENT_DECLARATIONS}
    391 			in mediump float te_out;
    392 			void main()
    393 			{
    394 				out0 = te_out;
    395 				${FRAGMENT_OUTPUT}
    396 			}
    397 		""
    398 	end
    399 
    400 	case ext_texture_buffer
    401 		version 320 es
    402 		desc "Test ext_texture_buffer extension"
    403 		expect build_successful
    404 
    405 		vertex ""
    406 			#version 320 es
    407 			${VERTEX_DECLARATIONS}
    408 
    409 			void main()
    410 			{
    411 				${VERTEX_OUTPUT}
    412 			}
    413 		""
    414 		fragment ""
    415 			#version 320 es
    416 			precision mediump float;
    417 			${FRAGMENT_DECLARATIONS}
    418 			uniform mediump samplerBuffer u_sampler;
    419 
    420 			void main()
    421 			{
    422 				if (textureSize(u_sampler) > 10)
    423 					discard;
    424 				${FRAGMENT_OUTPUT}
    425 			}
    426 		""
    427 	end
    428 
    429 	case ext_texture_cube_map_array
    430 		version 320 es
    431 		desc "Test ext_texture_cube_map_array extension"
    432 		expect build_successful
    433 
    434 		vertex ""
    435 			#version 320 es
    436 			${VERTEX_DECLARATIONS}
    437 
    438 			void main()
    439 			{
    440 				${VERTEX_OUTPUT}
    441 			}
    442 		""
    443 		fragment ""
    444 			#version 320 es
    445 			precision mediump float;
    446 			${FRAGMENT_DECLARATIONS}
    447 			uniform mediump samplerCubeArray u_sampler;
    448 
    449 			void main()
    450 			{
    451 				if (textureSize(u_sampler, 3).y > 10)
    452 					discard;
    453 				${FRAGMENT_OUTPUT}
    454 			}
    455 		""
    456 	end
    457 end
    458 
    459 group implementation_limits "Extended implementation limits"
    460 
    461 	case max_fragment_atomic_counter_buffers
    462 		version 320 es
    463 		desc "Test MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS limit"
    464 		expect build_successful
    465 
    466 		vertex ""
    467 			#version 320 es
    468 			${VERTEX_DECLARATIONS}
    469 
    470 			void main()
    471 			{
    472 				${VERTEX_OUTPUT}
    473 			}
    474 		""
    475 		fragment ""
    476 			#version 320 es
    477 			precision mediump float;
    478 			${FRAGMENT_DECLARATIONS}
    479 			layout(binding=0) uniform atomic_uint u_counter;
    480 
    481 			void main()
    482 			{
    483 				if (atomicCounterIncrement(u_counter) == 0u)
    484 					discard;
    485 				${FRAGMENT_OUTPUT}
    486 			}
    487 		""
    488 	end
    489 
    490 	case max_fragment_atomic_counters
    491 		version 320 es
    492 		desc "Test MAX_FRAGMENT_ATOMIC_COUNTERS limit"
    493 		expect build_successful
    494 
    495 		vertex ""
    496 			#version 320 es
    497 			${VERTEX_DECLARATIONS}
    498 
    499 			void main()
    500 			{
    501 				${VERTEX_OUTPUT}
    502 			}
    503 		""
    504 		fragment ""
    505 			#version 320 es
    506 			precision mediump float;
    507 			${FRAGMENT_DECLARATIONS}
    508 			layout(binding=0) uniform atomic_uint u_counter[8];
    509 
    510 			void main()
    511 			{
    512 				if (atomicCounterIncrement(u_counter[0]) == 0u)
    513 					discard;
    514 				if (atomicCounterIncrement(u_counter[1]) == 0u)
    515 					discard;
    516 				if (atomicCounterIncrement(u_counter[2]) == 0u)
    517 					discard;
    518 				if (atomicCounterIncrement(u_counter[3]) == 0u)
    519 					discard;
    520 				if (atomicCounterIncrement(u_counter[4]) == 0u)
    521 					discard;
    522 				if (atomicCounterIncrement(u_counter[5]) == 0u)
    523 					discard;
    524 				if (atomicCounterIncrement(u_counter[6]) == 0u)
    525 					discard;
    526 				if (atomicCounterIncrement(u_counter[7]) == 0u)
    527 					discard;
    528 				${FRAGMENT_OUTPUT}
    529 			}
    530 		""
    531 	end
    532 
    533 	case max_fragment_image_uniforms
    534 		version 320 es
    535 		desc "Test MAX_FRAGMENT_IMAGE_UNIFORMS limit"
    536 		expect build_successful
    537 
    538 		vertex ""
    539 			#version 320 es
    540 			${VERTEX_DECLARATIONS}
    541 
    542 			void main()
    543 			{
    544 				${VERTEX_OUTPUT}
    545 			}
    546 		""
    547 		fragment ""
    548 			#version 320 es
    549 			precision mediump float;
    550 			${FRAGMENT_DECLARATIONS}
    551 			layout(binding=0, r32i) uniform readonly highp iimage2D u_image0;
    552 			layout(binding=1, rgba16i) uniform readonly highp iimage3D u_image1;
    553 			layout(binding=2, rgba8ui) uniform readonly highp uimageCube u_image2;
    554 			layout(binding=3, rgba16f) uniform readonly highp image2DArray u_image3;
    555 
    556 			void main()
    557 			{
    558 				if (imageLoad(u_image0, ivec2(0, 0)).r == 0)
    559 					discard;
    560 				if (imageLoad(u_image1, ivec3(0, 0, 0)).r == 0)
    561 					discard;
    562 				if (imageLoad(u_image2, ivec3(0, 0, 0)).r == 0u)
    563 					discard;
    564 				if (imageLoad(u_image3, ivec3(0, 0, 0)).r == 0.0)
    565 					discard;
    566 				${FRAGMENT_OUTPUT}
    567 			}
    568 		""
    569 	end
    570 
    571 	case max_fragment_shader_storage_blocks
    572 		version 320 es
    573 		desc "Test MAX_FRAGMENT_SHADER_STORAGE_BLOCKS limit"
    574 		expect build_successful
    575 
    576 		vertex ""
    577 			#version 320 es
    578 			${VERTEX_DECLARATIONS}
    579 
    580 			void main()
    581 			{
    582 				${VERTEX_OUTPUT}
    583 			}
    584 		""
    585 		fragment ""
    586 			#version 320 es
    587 			precision mediump float;
    588 			${FRAGMENT_DECLARATIONS}
    589 			layout(binding=0, std430) coherent readonly buffer Buffer0
    590 			{
    591 				highp int val;
    592 				highp float vals[32];
    593 			} buffer0;
    594 			layout(binding=1, std140) volatile buffer Buffer1
    595 			{
    596 				highp float vals[];
    597 			} buffer1;
    598 			layout(binding=2, packed) restrict buffer Buffer2
    599 			{
    600 				highp int vals[15];
    601 			} buffer2;
    602 			layout(binding=3, std140) writeonly buffer Buffer3
    603 			{
    604 				highp vec3 vals[8];
    605 			} buffer3;
    606 
    607 			void main()
    608 			{
    609 				highp int readNdx = abs(int(gl_FragCoord.x));
    610 				highp int writeNdx = abs(int(gl_FragCoord.y));
    611 
    612 				if (buffer0.vals[readNdx % 32] == 0.0)
    613 					discard;
    614 
    615 				if (buffer1.vals[readNdx % 1024] == 0.0)
    616 					discard;
    617 				buffer1.vals[writeNdx % 1024] = float(readNdx);
    618 
    619 				if (buffer2.vals[readNdx % 15] == 0)
    620 					discard;
    621 				buffer2.vals[writeNdx % 15] = readNdx;
    622 
    623 				buffer3.vals[writeNdx % 8] = vec3(float(writeNdx), 0.0, float(readNdx));
    624 				${FRAGMENT_OUTPUT}
    625 			}
    626 		""
    627 	end
    628 end
    629