1## encoding=utf-8 2## Copyright © 2016 Intel Corporation 3## 4## Permission is hereby granted, free of charge, to any person obtaining a copy 5## of this software and associated documentation files (the "Software"), to deal 6## in the Software without restriction, including without limitation the rights 7## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8## copies of the Software, and to permit persons to whom the Software is 9## furnished to do so, subject to the following conditions: 10## 11## The above copyright notice and this permission notice shall be included in 12## all copies or substantial portions of the Software. 13## 14## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20## SOFTWARE. 21 22<%! 23 def _version(ver): 24 if ver == 'GL_ARB_vertex_attrib_64bit': 25 glsl_version_int = '150' 26 else: 27 glsl_version_int = ver 28 29 glsl_version = '{}.{}'.format(glsl_version_int[0], glsl_version_int[1:3]) 30 31 return (glsl_version, glsl_version_int) 32%> 33<% glsl, glsl_int = _version(ver) %> 34 35[require] 36GLSL >= ${glsl} 37% if ver == 'GL_ARB_vertex_attrib_64bit': 38 GL_ARB_gpu_shader_fp64 39 ${ver} 40% endif 41GL_MAX_VERTEX_ATTRIBS >= ${num_vs_in} 42 43[vertex shader] 44#version ${glsl_int} 45% if ver == 'GL_ARB_vertex_attrib_64bit': 46 #extension GL_ARB_gpu_shader_fp64 : require 47 #extension GL_ARB_vertex_attrib_64bit : require 48% endif 49 50% for idx, in_type in enumerate(in_types): 51 % for vidx in range(4): 52 uniform ${in_type.name} expected${idx}${vidx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''}; 53 % endfor 54% endfor 55% for idx, in_type in enumerate(in_types): 56 in ${in_type.name} value${idx}${'[{}]'.format(arrays[idx]) if arrays[idx] - 1 else ''}; 57% endfor 58in vec3 piglit_vertex; 59out vec4 fs_color; 60 61#define RED vec4(1.0, 0.0, 0.0, 1.0) 62#define GREEN vec4(0.0, 1.0, 0.0, 1.0) 63 64void main() 65{ 66 gl_Position = vec4(piglit_vertex.x, piglit_vertex.y, 0.0, 1.0); 67 % for vidx, vertex in enumerate(['-1.0', '0.0', '1.0', '2.0']): 68 if (piglit_vertex.z == ${vertex}) { 69 % for idx, in_type in enumerate(in_types): 70 if (value${idx} != expected${idx}${vidx}) { 71 fs_color = RED; 72 return; 73 } 74 % endfor 75 } 76 % endfor 77 fs_color = GREEN; 78} 79 80[fragment shader] 81#version 150 82 83in vec4 fs_color; 84out vec4 color; 85 86void main() 87{ 88 color = fs_color; 89} 90 91[vertex data] 92% for idx, in_type in enumerate(in_types): 93 % if idx == position_order - 1: 94 piglit_vertex/float/vec3 \ 95 % endif 96 % for i in range(arrays[idx]): 97 % for j in range(in_type.columns): 98 value${idx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}/${gl_types[idx]}/${in_type.name}${'/{}'.format(j) if in_type.columns > 1 else ''} \ 99 % endfor 100 % endfor 101% endfor 102% if position_order > len(in_types): 103 piglit_vertex/float/vec3\ 104% endif 105 106% for d in range(len(gl_types_values['double'])): 107 % for vidx, vertex in enumerate(['-1.0 -1.0 -1.0', ' 1.0 -1.0 0.0', ' 1.0 1.0 1.0', '-1.0 1.0 2.0']): 108 % for idx, in_type in enumerate(in_types): 109 % if idx == position_order - 1: 110 ${vertex} \ 111 % endif 112 % for i in range(arrays[idx]): 113 % for j in range(in_type.columns): 114 % for k in range(in_type.rows): 115 ${gl_types_values[gl_types[idx]][(d + (i * in_type.columns + j) * in_type.rows + k + vidx) % len(gl_types_values[gl_types[idx]])]} \ 116 % endfor 117 \ 118 % endfor 119 % endfor 120 % endfor 121 % if position_order > len(in_types): 122 ${vertex}\ 123 % endif 124 125 % endfor 126% endfor 127 128[test] 129% for d in range(len(gl_types_values['double'])): 130 131 % for vidx in range(4): 132 % for idx, in_type in enumerate(in_types): 133 % for i in range(arrays[idx]): 134 uniform ${in_type.name} expected${idx}${vidx}${'[{}]'.format(i) if arrays[idx] > 1 else ''}\ 135 % for j in range(in_type.columns): 136 % for k in range(in_type.rows): 137 ## Careful: these are the values for the VBO type, not the uniform type. If we use the hex format they should match or the run will fail. 138 ${gl_types_values[gl_types[idx]][(d + (i * in_type.columns + j) * in_type.rows + k + vidx) % len(gl_types_values[gl_types[idx]])]}\ 139 % endfor 140 % endfor 141 142 % endfor 143 % endfor 144 % endfor 145 clear color 0.0 0.0 1.0 0.0 146 clear 147 draw arrays GL_TRIANGLE_FAN ${d * 4} 4 148 probe all rgba 0.0 1.0 0.0 1.0 149% endfor 150