13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.0 Module
33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * -------------------------------------------------
43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project
63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License");
83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License.
93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at
103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *      http://www.apache.org/licenses/LICENSE-2.0
123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software
143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS,
153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and
173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License.
183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*!
203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file
213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Shader switch statement tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Variables:
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  + Selection expression type: static, uniform, dynamic
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  + Switch layout - fall-through or use of default label
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  + Switch nested in loop/conditional statement
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *  + Loop/conditional statement nested in switch
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fShaderSwitchTests.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsShaderRenderCase.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsShaderLibrary.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuStringTemplate.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace deqp::gls;
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::map;
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ShaderSwitchCase : public ShaderRenderCase
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						ShaderSwitchCase			(Context& context, const char* name, const char* description, bool isVertexCase, const char* vtxSource, const char* fragSource, ShaderEvalFunc evalFunc);
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual				~ShaderSwitchCase			(void);
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko PoyryShaderSwitchCase::ShaderSwitchCase (Context& context, const char* name, const char* description, bool isVertexCase, const char* vtxSource, const char* fragSource, ShaderEvalFunc evalFunc)
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: ShaderRenderCase(context.getTestContext(), context.getRenderContext(), context.getContextInfo(), name, description, isVertexCase, evalFunc)
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_vertShaderSource	= vtxSource;
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_fragShaderSource	= fragSource;
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko PoyryShaderSwitchCase::~ShaderSwitchCase (void)
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum SwitchType
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SWITCHTYPE_STATIC = 0,
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SWITCHTYPE_UNIFORM,
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SWITCHTYPE_DYNAMIC,
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	SWITCHTYPE_LAST
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void evalSwitchStatic	(ShaderEvalContext& evalCtx)	{ evalCtx.color.xyz() = evalCtx.coords.swizzle(1,2,3);	}
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void evalSwitchUniform	(ShaderEvalContext& evalCtx)	{ evalCtx.color.xyz() = evalCtx.coords.swizzle(1,2,3);	}
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void evalSwitchDynamic	(ShaderEvalContext& evalCtx)
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (int(deFloatFloor(evalCtx.coords.z()*1.5f + 2.0f)))
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 0:		evalCtx.color.xyz() = evalCtx.coords.swizzle(0,1,2);	break;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 1:		evalCtx.color.xyz() = evalCtx.coords.swizzle(3,2,1);	break;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 2:		evalCtx.color.xyz() = evalCtx.coords.swizzle(1,2,3);	break;
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case 3:		evalCtx.color.xyz() = evalCtx.coords.swizzle(2,1,0);	break;
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:	evalCtx.color.xyz() = evalCtx.coords.swizzle(0,0,0);	break;
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic tcu::TestCase* makeSwitchCase (Context& context, const char* name, const char* desc, SwitchType type, bool isVertex, const LineStream& switchBody)
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream	vtx;
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream	frag;
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream&	op		= isVertex ? vtx : frag;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vtx << "#version 300 es\n"
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "in highp vec4 a_position;\n"
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "in highp vec4 a_coords;\n";
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	frag << "#version 300 es\n"
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 << "layout(location = 0) out mediump vec4 o_color;\n";
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (isVertex)
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vtx << "out mediump vec4 v_color;\n";
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		frag << "in mediump vec4 v_color;\n";
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vtx << "out highp vec4 v_coords;\n";
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		frag << "in highp vec4 v_coords;\n";
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (type == SWITCHTYPE_UNIFORM)
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		op << "uniform highp int ui_two;\n";
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vtx << "\n"
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "void main (void)\n"
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{\n"
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	gl_Position = a_position;\n";
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	frag << "\n"
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 << "void main (void)\n"
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		 << "{\n";
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup.
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	op << "	highp vec4 coords = " << (isVertex ? "a_coords" : "v_coords") << ";\n";
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	op << "	mediump vec3 res = vec3(0.0);\n\n";
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Switch body.
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	map<string, string> params;
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	params["CONDITION"] = type == SWITCHTYPE_STATIC		? "2"								:
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  type == SWITCHTYPE_UNIFORM	? "ui_two"							:
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						  type == SWITCHTYPE_DYNAMIC	? "int(floor(coords.z*1.5 + 2.0))"	: "???";
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	op << tcu::StringTemplate(switchBody.str()).specialize(params).c_str();
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	op << "\n";
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (isVertex)
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vtx << "	v_color = vec4(res, 1.0);\n";
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		frag << "	o_color = v_color;\n";
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		vtx << "	v_coords = a_coords;\n";
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		frag << "	o_color = vec4(res, 1.0);\n";
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vtx << "}\n";
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	frag << "}\n";
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return new ShaderSwitchCase(context, name, desc, isVertex, vtx.str().c_str(), frag.str().c_str(),
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								type == SWITCHTYPE_STATIC	? evalSwitchStatic	:
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								type == SWITCHTYPE_UNIFORM	? evalSwitchUniform	:
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry								type == SWITCHTYPE_DYNAMIC	? evalSwitchDynamic	: (ShaderEvalFunc)DE_NULL);
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void makeSwitchCases (TestCaseGroup* group, const char* name, const char* desc, const LineStream& switchBody)
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const char* switchTypeNames[] = { "static", "uniform", "dynamic" };
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(switchTypeNames) == SWITCHTYPE_LAST);
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int type = 0; type < SWITCHTYPE_LAST; type++)
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group->addChild(makeSwitchCase(group->getContext(), (string(name) + "_" + switchTypeNames[type] + "_vertex").c_str(),	desc, (SwitchType)type, true,	switchBody));
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		group->addChild(makeSwitchCase(group->getContext(), (string(name) + "_" + switchTypeNames[type] + "_fragment").c_str(),	desc, (SwitchType)type, false,	switchBody));
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1683c827367444ee418f129b2c238299f49d3264554Jarkko PoyryShaderSwitchTests::ShaderSwitchTests (Context& context)
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "switch", "Switch statement tests")
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1733c827367444ee418f129b2c238299f49d3264554Jarkko PoyryShaderSwitchTests::~ShaderSwitchTests (void)
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ShaderSwitchTests::init (void)
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Expected swizzles:
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 0: xyz
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 1: wzy
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 2: yzw
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// 3: zyx
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "basic", "Basic switch statement usage",
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:		res = coords.yzw;	break;"
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "const_expr_in_label", "Constant expression in label",
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "const int t = 2;"
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case int(0.0):	res = coords.xyz;	break;"
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2-1:		res = coords.wzy;	break;"
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3&(1<<1):	res = coords.yzw;	break;"
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case t+1:		res = coords.zyx;	break;"
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "default_label", "Default label usage",
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = coords.yzw;"
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "default_not_last", "Default label usage",
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = coords.yzw;	break;"
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "no_default_label", "No match in switch without default label",
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "res = coords.yzw;\n"
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "fall_through", "Fall-through",
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:		coords = coords.yzwx;"
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 4:		res = vec3(coords);	break;"
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "fall_through_default", "Fall-through",
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:		coords = coords.yzwx;"
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = vec3(coords);"
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "conditional_fall_through", "Fall-through",
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "highp vec4 tmp = coords;"
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		tmp = coords.yzwx;"
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:"
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		res = vec3(tmp);"
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		if (${CONDITION} != 3)"
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			break;"
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = tmp.zyx;		break;"
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "conditional_fall_through_2", "Fall-through",
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "highp vec4 tmp = coords;"
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "mediump int c = ${CONDITION};"
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (c)"
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		c += ${CONDITION};"
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		tmp = coords.yzwx;"
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:"
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		res = vec3(tmp);"
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		if (c == 4)"
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			break;"
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = tmp.zyx;		break;"
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "scope", "Basic switch statement usage",
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		mediump vec3 t = coords.yzw;"
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		res = t;"
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		break;"
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 3:		res = coords.zyx;	break;"
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "switch_in_if", "Switch in for loop",
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "if (${CONDITION} >= 0)"
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	switch (${CONDITION})"
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 0:		res = coords.xyz;	break;"
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 1:		res = coords.wzy;	break;"
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 2:		res = coords.yzw;	break;"
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 3:		res = coords.zyx;	break;"
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "switch_in_for_loop", "Switch in for loop",
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "for (int i = 0; i <= ${CONDITION}; i++)"
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	switch (i)"
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 0:		res = coords.xyz;	break;"
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 1:		res = coords.wzy;	break;"
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 2:		res = coords.yzw;	break;"
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 3:		res = coords.zyx;	break;"
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "switch_in_while_loop", "Switch in while loop",
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "int i = 0;"
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "while (i <= ${CONDITION})"
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	switch (i)"
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 0:		res = coords.xyz;	break;"
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 1:		res = coords.wzy;	break;"
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 2:		res = coords.yzw;	break;"
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 3:		res = coords.zyx;	break;"
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	i += 1;"
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "switch_in_do_while_loop", "Switch in do-while loop",
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "int i = 0;"
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "do"
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	switch (i)"
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 0:		res = coords.xyz;	break;"
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 1:		res = coords.wzy;	break;"
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 2:		res = coords.yzw;	break;"
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		case 3:		res = coords.zyx;	break;"
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	i += 1;"
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "} while (i <= ${CONDITION});");
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "if_in_switch", "Basic switch statement usage",
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:		res = coords.wzy;	break;"
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:"
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		if (${CONDITION} == 2)"
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			res = coords.yzw;"
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		else"
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			res = coords.zyx;"
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		break;"
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "for_loop_in_switch", "Basic switch statement usage",
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:"
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		highp vec3 t = coords.yzw;"
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		for (int i = 0; i < ${CONDITION}; i++)"
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			t = t.zyx;"
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		res = t;"
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		break;"
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = coords.zyx;	break;"
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "while_loop_in_switch", "Basic switch statement usage",
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:"
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		highp vec3 t = coords.yzw;"
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		int i = 0;"
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		while (i < ${CONDITION})"
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		{"
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			t = t.zyx;"
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			i += 1;"
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		}"
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		res = t;"
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		break;"
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = coords.zyx;	break;"
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "do_while_loop_in_switch", "Basic switch statement usage",
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:"
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	{"
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		highp vec3 t = coords.yzw;"
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		int i = 0;"
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		do"
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		{"
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			t = t.zyx;"
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			i += 1;"
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		} while (i < ${CONDITION});"
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		res = t;"
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		break;"
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	}"
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = coords.zyx;	break;"
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	makeSwitchCases(this, "switch_in_switch", "Basic switch statement usage",
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		LineStream(1)
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "switch (${CONDITION})"
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "{"
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 0:		res = coords.xyz;	break;"
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 1:"
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	case 2:"
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		switch (${CONDITION} - 1)"
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		{"
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			case 0:		res = coords.wzy;	break;"
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "			case 1:		res = coords.yzw;	break;"
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		}"
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "		break;"
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "	default:	res = coords.zyx;	break;"
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		<< "}");
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Negative cases.
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	ShaderLibrary library(m_testCtx, m_context.getRenderContext(), m_context.getContextInfo());
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<tcu::TestNode*> negativeCases = library.loadShaderFile("shaders/switch.test");
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (vector<tcu::TestNode*>::iterator i = negativeCases.begin(); i != negativeCases.end(); i++)
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(*i);
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
463