16d0784059995b8fa554d74013c06e937889ff449Jamie Madill# -*- coding: utf-8 -*-
26d0784059995b8fa554d74013c06e937889ff449Jamie Madill
36d0784059995b8fa554d74013c06e937889ff449Jamie Madill#-------------------------------------------------------------------------
46d0784059995b8fa554d74013c06e937889ff449Jamie Madill# drawElements Quality Program utilities
56d0784059995b8fa554d74013c06e937889ff449Jamie Madill# --------------------------------------
66d0784059995b8fa554d74013c06e937889ff449Jamie Madill#
76d0784059995b8fa554d74013c06e937889ff449Jamie Madill# Copyright 2015 The Android Open Source Project
86d0784059995b8fa554d74013c06e937889ff449Jamie Madill#
96d0784059995b8fa554d74013c06e937889ff449Jamie Madill# Licensed under the Apache License, Version 2.0 (the "License");
106d0784059995b8fa554d74013c06e937889ff449Jamie Madill# you may not use this file except in compliance with the License.
116d0784059995b8fa554d74013c06e937889ff449Jamie Madill# You may obtain a copy of the License at
126d0784059995b8fa554d74013c06e937889ff449Jamie Madill#
136d0784059995b8fa554d74013c06e937889ff449Jamie Madill#      http://www.apache.org/licenses/LICENSE-2.0
146d0784059995b8fa554d74013c06e937889ff449Jamie Madill#
156d0784059995b8fa554d74013c06e937889ff449Jamie Madill# Unless required by applicable law or agreed to in writing, software
166d0784059995b8fa554d74013c06e937889ff449Jamie Madill# distributed under the License is distributed on an "AS IS" BASIS,
176d0784059995b8fa554d74013c06e937889ff449Jamie Madill# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186d0784059995b8fa554d74013c06e937889ff449Jamie Madill# See the License for the specific language governing permissions and
196d0784059995b8fa554d74013c06e937889ff449Jamie Madill# limitations under the License.
206d0784059995b8fa554d74013c06e937889ff449Jamie Madill#
216d0784059995b8fa554d74013c06e937889ff449Jamie Madill#-------------------------------------------------------------------------
226d0784059995b8fa554d74013c06e937889ff449Jamie Madill
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport sys
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport itertools
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport operator
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryimport genutil
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryfrom genutil import Scalar, Vec2, Vec3, Vec4, Uint, UVec2, UVec3, UVec4, CaseGroup
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# Templates
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryARTIHMETIC_CASE_TEMPLATE = """
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${{VALUES}}
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out0 = ${{EXPR}};
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFUNCTIONS_CASE_TEMPLATE = """
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${{VALUES}}
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${{OUTTYPE}} func (${{OUTTYPE}} a)
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return a * ${{OUTTYPE}}(2);
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out0 = func(in0);
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryARRAY_CASE_TEMPLATE = """
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${{VALUES}}
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${{ARRAYTYPE}}[] x = ${{ARRAYTYPE}}[] (${{ARRAYVALUES}});
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out0 = ${{EXPR}};
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySTRUCT_CASE_TEMPLATE = """
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${{VALUES}}
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			struct {
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				${{OUTTYPE}} val;
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			} x;
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			x.val = ${{STRUCTVALUE}};
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out0 = ${{EXPR}};
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryINVALID_CASE_TEMPLATE = """
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	expect compile_fail
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${{VALUES}}
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out0 = in0 + ${{OPERAND}};
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1673c827367444ee418f129b2c238299f49d3264554Jarkko PoyryINVALID_ARRAY_CASE_TEMPLATE = """
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	expect compile_fail
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values {}
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${{EXPR}}
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1893c827367444ee418f129b2c238299f49d3264554Jarkko PoyryINVALID_STRUCT_CASE_TEMPLATE = """
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrycase ${{NAME}}
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	expect compile_fail
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	version 310 es
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	require extension { "GL_EXT_shader_implicit_conversions" } in { vertex, fragment }
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	values {}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	both ""
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#version 310 es
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		precision highp float;
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		${DECLARATIONS}
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		void main()
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${SETUP}
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			struct { ${{INTYPE}} value; } a;
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			struct { ${{OUTTYPE}} value; } b;
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = ${{INVALUE}};
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			b = a;
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			${OUTPUT}
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	""
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryend
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry""".strip()
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# Input values
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIN_ISCALAR = [  2,  1,  1,  3,  5 ]
2183c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIN_USCALAR = [  1,  3,  4,  7, 11 ]
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIN_IVECTOR = [
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	( 1,  2,  3,  4),
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	( 2,  1,  2,  6),
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	( 3,  7,  2,  5),
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry]
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIN_UVECTOR = [
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	( 2,  3,  5,  8),
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	( 4,  6,  2,  9),
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	( 1, 13,  7,  4),
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry]
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIN_VALUES = {
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"int":		[Scalar(x)								for x in IN_ISCALAR],
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uint":		[Scalar(x)								for x in IN_USCALAR],
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec2":	[Vec2(x[0], x[1])						for x in IN_IVECTOR],
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec2":	[Vec2(x[0], x[1])						for x in IN_UVECTOR],
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec3":	[Vec3(x[0], x[1], x[2])					for x in IN_IVECTOR],
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec3":	[Vec3(x[0], x[1], x[2])					for x in IN_UVECTOR],
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec4":	[Vec4(x[0], x[1], x[2], x[3])			for x in IN_IVECTOR],
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec4":	[Vec4(x[0], x[1], x[2], x[3])			for x in IN_UVECTOR],
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"float":	[Scalar(x).toFloat()					for x in IN_ISCALAR],
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec2":		[Vec2(x[0], x[1]).toFloat()				for x in IN_IVECTOR],
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3":		[Vec3(x[0], x[1], x[2]).toFloat()		for x in IN_IVECTOR],
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec4":		[Vec4(x[0], x[1], x[2], x[3]).toFloat()	for x in IN_IVECTOR],
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVALID_CONVERSIONS = {
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"int":		["float", "uint"],
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uint":		["float"],
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec2":	["uvec2", "vec2"],
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec2":	["vec2"],
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec3":	["uvec3", "vec3"],
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec3":	["vec3"],
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec4":	["uvec4", "vec4"],
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec4":	["vec4"]
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySCALAR_TO_VECTOR_CONVERSIONS = {
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"int":		["vec2", "vec3", "vec4", "uvec2", "uvec3", "uvec4"],
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uint":		["vec2", "vec3", "vec4"]
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVALID_ASSIGNMENTS = {
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"int":		["ivec2", "ivec3", "ivec4"],
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uint":		["uvec2", "uvec3", "uvec4"],
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec2":	["int", "float"],
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec3":	["int", "float"],
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec4":	["int", "float"],
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec2":	["uint", "float"],
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec3":	["uint", "float"],
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec4":	["uint", "float"],
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"float":	["vec2", "vec3", "vec4"],
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec2":		["float"],
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec3":		["float"],
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec4":		["float"]
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2783c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIN_TYPE_ORDER = [
279f189365bd621a14ac442faf93d81d031aad3a6f8Pyry Haulos	"int",	 "uint",
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"ivec2", "uvec2", "ivec3",
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"uvec3", "ivec4", "uvec4",
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"float",
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	"vec2",  "vec3",  "vec4"
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry]
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef isScalarTypeName (name):
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return name in ["float", "int", "uint"]
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef isVec2TypeName (name):
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return name in ["vec2", "ivec2", "uvec2"]
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef isVec3TypeName (name):
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return name in ["vec3", "ivec3", "uvec3"]
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef isVec4TypeName (name):
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return name in ["vec4", "ivec4", "uvec4"]
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# Utilities
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef scalarToVector(a, b):
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if isinstance(a, Scalar) and isinstance(b, Vec2):
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		a = a.toVec2()
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	elif isinstance(a, Scalar) and isinstance(b, Vec3):
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		a = a.toVec3()
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	elif isinstance(a, Scalar) and isinstance(b, Vec4):
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		a = a.toVec4()
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return a
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef isUintTypeName (type_name):
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return type_name in ["uint", "uvec2", "uvec3", "uvec4"]
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef convLiteral (type, value):
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if isUintTypeName(type):
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return int(value)
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else:
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return value
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef valueToStr(value_type, value):
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if isinstance(value, Scalar):
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return str(value)
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else:
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		assert isinstance(value, genutil.Vec)
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = value_type + "("
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out += ", ".join([str(convLiteral(value_type, x)) for x in value.getScalars()])
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out += ")"
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return out
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef valuesToStr(prefix, value_type, values):
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_value_strs(value_list, value_type):
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for value in value_list:
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			yield valueToStr(value_type, value)
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return "%s = [ %s ];" % (prefix, " | ".join(gen_value_strs(values, value_type)))
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# Test cases
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ArithmeticCase(genutil.ShaderCase):
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, op, in_type, out_type, reverse=False):
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.op_func = {
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"+":	operator.add,
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"-":	operator.sub,
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"*":	operator.mul,
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"/":	operator.div,
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.op			= op
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.reverse	= reverse
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":		self.name,
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"EXPR":		self.get_expr(),
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":	self.gen_values(),
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(ARTIHMETIC_CASE_TEMPLATE, params)
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a, b):
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		assert(self.op in self.op_func)
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		a = scalarToVector(a, b)
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if self.reverse:
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			b, a = a, b
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return self.op_func[self.op](a, b)
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_expr(self):
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expr = ["in0", self.op, str(self.get_operand())]
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if self.reverse:
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expr.reverse()
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return " ".join(expr)
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_operand(self):
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		operands = {
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"float":	Scalar(2.0),
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"vec2":		Vec2(1.0, 2.0),
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"vec3":		Vec3(1.0, 2.0, 3.0),
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"vec4":		Vec4(1.0, 2.0, 3.0, 4.0),
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uint":		Uint(2),
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uvec2":	UVec2(1, 2),
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uvec3":	UVec3(1, 2, 3),
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"uvec4":	UVec4(1, 2, 3, 4),
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		assert self.out_type in operands
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return operands[self.out_type]
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		y			= self.get_operand()
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x, y) for x in in_values]
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ComparisonsCase(ArithmeticCase):
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, op, in_type, out_type, reverse=False):
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		super(ComparisonsCase, self).__init__(name, op, in_type, out_type, reverse)
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.op_func = {
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"==":	operator.eq,
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"!=":	operator.ne,
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"<":	operator.lt,
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			">":	operator.gt,
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"<=":	operator.le,
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			">=":	operator.ge,
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a, b):
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		assert(self.op in self.op_func)
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if isinstance(a, Scalar) and isinstance(b, Scalar):
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a, b = float(a), float(b)
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if self.reverse:
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			b, a = a, b
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return Scalar(self.op_func[self.op](a, b))
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		y			= self.get_operand()
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x, y) for x in in_values]
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output bool out0", "bool", out_values))
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ParenthesizedCase(genutil.ShaderCase):
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type, reverse=False, input_in_parens=False):
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name				= name
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type			= in_type
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type			= out_type
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.reverse			= reverse
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.input_in_parens	= input_in_parens
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":		self.name,
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"EXPR":		self.get_expr(),
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":	self.gen_values(),
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(ARTIHMETIC_CASE_TEMPLATE, params)
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a):
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		b, c	= self.get_operand(0), self.get_operand(1)
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		a		= scalarToVector(a, b)
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if self.input_in_parens:
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return b*(a+c)
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else:
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return a*(b+c)
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_expr(self):
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		def make_paren_expr():
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out = [
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"in0" if self.input_in_parens else self.get_operand(0),
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				"+",
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				self.get_operand(1)
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			]
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "(%s)" % (" ".join([str(x) for x in out]))
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		expr = [
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in0" if not self.input_in_parens else self.get_operand(0),
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"*",
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			make_paren_expr()
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		]
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if self.reverse:
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			expr.reverse()
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return " ".join([str(x) for x in expr])
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_operand(self, ndx=0):
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return IN_VALUES[self.out_type][ndx]
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x) for x in in_values]
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FunctionsCase(genutil.ShaderCase):
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type):
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":		self.name,
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"OUTTYPE":	self.out_type,
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":	self.gen_values(),
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(FUNCTIONS_CASE_TEMPLATE, params)
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a):
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if isUintTypeName(self.out_type):
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return a.toUint() * Uint(2)
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else:
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return a.toFloat() * Scalar(2.0)
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x) for x in in_values]
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ArrayCase(genutil.ShaderCase):
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type, reverse=False):
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.reverse	= reverse
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":			self.name,
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":		self.gen_values(),
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"ARRAYTYPE":	self.out_type,
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"ARRAYVALUES":	self.gen_array_values(),
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"EXPR":			self.get_expr(),
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(ARRAY_CASE_TEMPLATE, params)
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a):
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		b = IN_VALUES[self.out_type][1]
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		a = scalarToVector(a, b)
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return a + b
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_expr(self):
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if not self.reverse:
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "in0 + x[1]"
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else:
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "x[1] + in0"
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x) for x in in_values]
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_array_values(self):
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = [valueToStr(self.out_type, x) for x in IN_VALUES[self.out_type]]
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return ", ".join(out)
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ArrayUnpackCase(genutil.ShaderCase):
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type):
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":			self.name,
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":		self.gen_values(),
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"ARRAYTYPE":	"float",
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"ARRAYVALUES":	self.gen_array_values(),
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"EXPR":			self.get_expr(),
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(ARRAY_CASE_TEMPLATE, params)
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a):
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if isinstance(a, Scalar) and isVec2TypeName(self.out_type):
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = a.toVec2()
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif isinstance(a, Scalar) and isVec3TypeName(self.out_type):
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = a.toVec3()
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif isinstance(a, Scalar) and isVec4TypeName(self.out_type):
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = a.toVec4()
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		b = IN_VALUES["float"]
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = [Scalar(x)+y for x, y in zip(a.getScalars(), b)]
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if self.out_type == "float":
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return out[0].toFloat()
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "uint":
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return out[0].toUint()
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "vec2":
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return Vec2(out[0], out[1]).toFloat()
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "uvec2":
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return Vec2(out[0], out[1]).toUint()
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "vec3":
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return Vec3(out[0], out[1], out[2]).toFloat()
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "uvec3":
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return Vec3(out[0], out[1], out[2]).toUint()
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "vec4":
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return Vec4(out[0], out[1], out[2], out[3]).toFloat()
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif self.out_type == "uvec4":
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return Vec4(out[0], out[1], out[2], out[3]).toUint()
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_expr(self):
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		def num_scalars(typename):
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return IN_VALUES[typename][0].getNumScalars()
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		def gen_sums():
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			in_scalars	= num_scalars(self.in_type)
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			out_scalars	= num_scalars(self.out_type)
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for ndx in range(out_scalars):
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				if in_scalars > 1:
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					yield "in0[%i] + x[%i]" % (ndx, ndx)
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				else:
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					yield "in0 + x[%i]" % (ndx)
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "%s(%s)" % (self.out_type, ", ".join(gen_sums()))
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x) for x in in_values]
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_array_values(self):
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = [valueToStr(self.out_type, x) for x in IN_VALUES["float"]]
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return ", ".join(out)
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass StructCase(genutil.ShaderCase):
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type, reverse=False):
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.reverse	= reverse
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":			self.name,
6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":		self.gen_values(),
6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"OUTTYPE":		self.out_type,
6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"STRUCTVALUE":	self.get_struct_value(),
6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"EXPR":			self.get_expr(),
6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(STRUCT_CASE_TEMPLATE, params)
6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a):
6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if isinstance(a, Scalar) and isVec2TypeName(self.out_type):
6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = a.toVec2()
6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif isinstance(a, Scalar) and isVec3TypeName(self.out_type):
6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = a.toVec3()
6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		elif isinstance(a, Scalar) and isVec4TypeName(self.out_type):
6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			a = a.toVec4()
6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		b = IN_VALUES[self.out_type][0]
6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return a + b
6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_expr(self):
6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if not self.reverse:
6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "in0 + x.val"
6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else:
6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return "x.val + in0"
6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x) for x in in_values]
6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_struct_value(self):
6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return valueToStr(self.out_type, IN_VALUES[self.out_type][0])
7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass InvalidCase(genutil.ShaderCase):
7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type):
7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":		self.name,
7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"OPERAND":	str(self.get_operand()),
7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"VALUES":	self.gen_values(),
7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(INVALID_CASE_TEMPLATE, params)
7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def apply(self, a, b):
7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return b
7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_operand(self):
7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return IN_VALUES[self.out_type][0]
7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_values(self):
7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values	= IN_VALUES[self.in_type]
7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		y			= self.get_operand()
7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out_values	= [self.apply(x, y) for x in in_values]
7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = []
7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("input %s in0" % (self.in_type), self.in_type, in_values))
7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out.append(valuesToStr("output %s out0" % (self.out_type), self.out_type, out_values))
7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return "\n".join(out)
7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass InvalidArrayCase(genutil.ShaderCase):
7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type):
7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":	self.name,
7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"EXPR":	self.gen_expr(),
7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(INVALID_ARRAY_CASE_TEMPLATE, params)
7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_expr(self):
7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		in_values = [valueToStr(self.out_type, x) for x in IN_VALUES[self.in_type]]
7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		out = "%s a[] = %s[] (%s);" % (self.out_type, self.in_type, ", ".join(in_values))
7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return out
7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass InvalidStructCase(genutil.ShaderCase):
7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __init__(self, name, in_type, out_type):
7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.name		= name
7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.in_type	= in_type
7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		self.out_type	= out_type
7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def __str__(self):
7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		params = {
7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"NAME":		self.name,
7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"INTYPE":	self.in_type,
7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"OUTTYPE":	self.out_type,
7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"INVALUE":	self.get_value(),
7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return genutil.fillTemplate(INVALID_STRUCT_CASE_TEMPLATE, params)
7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def get_value(self):
7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return valueToStr(self.in_type, IN_VALUES[self.in_type][0])
7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry# Case file generation
7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genConversionPairs(order=IN_TYPE_ORDER, scalar_to_vector=True, additional={}):
7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	def gen_order(conversions):
7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		key_set = set(conversions.iterkeys())
7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for typename in order:
7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if typename in key_set:
7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				yield typename
7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	conversions = {}
7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type in VALID_CONVERSIONS:
7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		conversions[in_type] = [] + VALID_CONVERSIONS[in_type]
7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if in_type in SCALAR_TO_VECTOR_CONVERSIONS and scalar_to_vector:
7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			conversions[in_type] += SCALAR_TO_VECTOR_CONVERSIONS[in_type]
7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for key in additional.iterkeys():
7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			value = conversions.get(key, [])
7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			conversions[key] = value + additional[key]
7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type in gen_order(conversions):
7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for out_type in conversions[in_type]:
7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			yield (in_type, out_type)
7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genInvalidConversions():
8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	types = IN_TYPE_ORDER
8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	valid_pairs = set(genConversionPairs(additional=VALID_ASSIGNMENTS))
8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for pair in itertools.permutations(types, 2):
8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if pair not in valid_pairs:
8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			yield pair
8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genArithmeticCases(reverse=False):
8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	op_names = [
8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("add", "Addition",			"+"),
8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("sub", "Subtraction",		"-"),
8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("mul", "Multiplication",	"*"),
8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("div", "Division",			"/")
8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	]
8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for name, desc, op in op_names:
8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		casegroup = CaseGroup(name, desc, [])
8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for in_type, out_type in genConversionPairs():
8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if op == "-" and isUintTypeName(out_type):
8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				continue # Can't handle at the moment
8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			name = in_type + "_to_" + out_type
8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			casegroup.children.append(ArithmeticCase(name, op, in_type, out_type, reverse))
8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield casegroup
8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genComparisonCases(reverse=False):
8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	op_names = [
8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("equal",				"Equal",					"=="),
8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("not_equal",			"Not equal",				"!="),
8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("less",				"Less than",				"<"),
8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("greater",				"Greater than",				">"),
8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("less_or_equal",		"Less than or equal",		"<="),
8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		("greater_or_equal",	"Greater than or equal",	">="),
8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	]
8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for name, desc, op in op_names:
8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		casegroup	= CaseGroup(name, desc, [])
8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		type_order	= IN_TYPE_ORDER if name in ["equal", "not_equal"] else ["int", "uint"]
8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for in_type, out_type in genConversionPairs(order=type_order, scalar_to_vector=False):
8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			name = in_type + "_to_" + out_type
8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			casegroup.children.append(ComparisonsCase(name, op, in_type, out_type, reverse))
8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield casegroup
8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genParenthesizedCases():
8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for reverse in [True, False]:
8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if reverse:
8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			name = "paren_expr_before_literal"
8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			desc = "Parenthesized expression before literal"
8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else:
8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			name = "literal_before_paren_expr"
8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			desc = "Literal before parenthesized expression"
8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		reversegroup = CaseGroup(name, desc, [])
8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for input_in_parens in [True, False]:
8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if input_in_parens:
8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				name = "input_in_parens"
8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				desc = "Input variable in parenthesized expression"
8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else:
8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				name = "input_outside_parens"
8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				desc = "Input variable outside parenthesized expression"
8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			casegroup = CaseGroup(name, desc, [])
8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for in_type, out_type in genConversionPairs():
8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				name = in_type + "_to_" + out_type
8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				casegroup.children.append(
8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					ParenthesizedCase(name, in_type, out_type, reverse, input_in_parens)
8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				)
8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			reversegroup.children.append(casegroup)
8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield reversegroup
8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genArrayCases(reverse=False):
8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genConversionPairs():
8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield ArrayCase(name, in_type, out_type, reverse)
8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genArrayUnpackCases(reverse=False):
8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genConversionPairs():
8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield ArrayUnpackCase(name, in_type, out_type)
8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genFunctionsCases():
8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genConversionPairs(scalar_to_vector=False):
8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield FunctionsCase(name, in_type, out_type)
8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genStructCases(reverse=False):
8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genConversionPairs():
8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield StructCase(name, in_type, out_type, reverse)
8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genInvalidCases(reverse=False):
8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genInvalidConversions():
9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield InvalidCase(name, in_type, out_type)
9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genInvalidArrayCases():
9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genConversionPairs(scalar_to_vector=False):
9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield InvalidArrayCase(name, in_type, out_type)
9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genInvalidStructCases():
9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for in_type, out_type in genConversionPairs(scalar_to_vector=False):
9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		name = in_type + "_to_" + out_type
9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		yield InvalidStructCase(name, in_type, out_type)
9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydef genAllCases():
9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup(
9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"arithmetic", "Arithmetic operations",
9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		[
9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("input_before_literal", "Input before literal",
9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genArithmeticCases(reverse=False)),
9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("literal_before_input", "Literal before input",
9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genArithmeticCases(reverse=True)),
9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		]
9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	)
9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup(
9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"comparisons", "Comparisons",
9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		[
9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("input_before_literal", "Input before literal",
9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genComparisonCases(reverse=False)),
9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("literal_before_input", "Literal before input",
9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genComparisonCases(reverse=True)),
9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		]
9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	)
9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup(
9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"array_subscripts", "Array subscripts",
9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		[
9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("input_before_subscript", "Input before subscript",
9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genArrayCases(reverse=False)),
9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("subscript_before_input", "Subscript before input",
9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genArrayCases(reverse=True)),
9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#	CaseGroup("unpack", "Unpack array and repack as value",
9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		#			  genArrayUnpackCases()),
9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		]
9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	)
9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup("functions", "Function calls",
9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					genFunctionsCases())
9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup("struct_fields", "Struct field selectors",
9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		[
9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("input_before_field", "Input before field",
9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genStructCases(reverse=False)),
9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("field_before_input", "Field before input",
9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genStructCases(reverse=True)),
9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		]
9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	)
9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup("parenthesized_expressions", "Parenthesized expressions",
9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					genParenthesizedCases())
9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	yield CaseGroup(
9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"invalid", "Invalid conversions",
9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		[
9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("variables", "Single variables",
9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genInvalidCases()),
9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("arrays", "Arrays",
9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genInvalidArrayCases()),
9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			CaseGroup("structs", "Structs",
9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					  genInvalidStructCases()),
9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		]
9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	)
9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryif __name__ == "__main__":
9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	print "Generating shader case files."
9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	genutil.writeAllCases("implicit_conversions.test", genAllCases())
980