13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 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 Vertex attribute binding stress tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31sVertexAttributeBindingTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluObjectWrapper.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Stress
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_vertexSource =				"#version 310 es\n"
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"in highp vec4 a_position;\n"
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"void main (void)\n"
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"{\n"
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"	gl_Position = a_position;\n"
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"}\n";
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_fragmentSource =				"#version 310 es\n"
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"layout(location = 0) out mediump vec4 fragColor;\n"
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"void main (void)\n"
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"{\n"
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"	fragColor = vec4(1.0, 1.0, 1.0, 1.0);\n"
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"}\n";
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_colorFragmentShader =		"#version 310 es\n"
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"in mediump vec4 v_color;\n"
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"layout(location = 0) out mediump vec4 fragColor;\n"
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"void main (void)\n"
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"{\n"
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"	fragColor = v_color;\n"
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														"}\n";
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Verifies image contains only yellow or greeen, or a linear combination
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// of these colors.
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool verifyImageYellowGreen (const tcu::Surface& image, tcu::TestLog& log, bool logImageOnSuccess)
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::TestLog;
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RGBA green		(0, 255, 0, 255);
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RGBA yellow		(255, 255, 0, 255);
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int colorThreshold	= 20;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface error			(image.getWidth(), image.getHeight());
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool isOk					= true;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << "Verifying image contents." << TestLog::EndMessage;
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < image.getHeight(); y++)
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int x = 0; x < image.getWidth(); x++)
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::RGBA pixel = image.getPixel(x, y);
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool pixelOk = true;
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Any pixel with !(G ~= 255) is faulty (not a linear combinations of green and yellow)
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (de::abs(pixel.getGreen() - 255) > colorThreshold)
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pixelOk = false;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Any pixel with !(B ~= 0) is faulty (not a linear combinations of green and yellow)
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (de::abs(pixel.getBlue() - 0) > colorThreshold)
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			pixelOk = false;
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		error.setPixel(x, y, (pixelOk) ? (tcu::RGBA(0, 255, 0, 255)) : (tcu::RGBA(255, 0, 0, 255)));
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		isOk = isOk && pixelOk;
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!isOk)
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "Image verification failed." << TestLog::EndMessage;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::ImageSet("Verfication result", "Result of rendering")
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::Image("Result",		"Result",		image)
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::Image("ErrorMask",	"Error mask",	error)
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			<< TestLog::EndImageSet;
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		log << TestLog::Message << "Image verification passed." << TestLog::EndMessage;
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (logImageOnSuccess)
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::ImageSet("Verfication result", "Result of rendering")
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				<< TestLog::Image("Result", "Result", image)
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				<< TestLog::EndImageSet;
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BindingRenderCase : public TestCase
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TEST_RENDER_SIZE = 64
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						BindingRenderCase	(Context& ctx, const char* name, const char* desc, bool unalignedData);
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual				~BindingRenderCase	(void);
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		init				(void);
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		deinit				(void);
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult		iterate				(void);
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		renderTo			(tcu::Surface& dst) = 0;
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createBuffers		(void) = 0;
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	virtual void		createShader		(void) = 0;
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected:
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool			m_unalignedData;
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glw::GLuint			m_vao;
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram*	m_program;
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1503c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindingRenderCase::BindingRenderCase (Context& ctx, const char* name, const char* desc, bool unalignedData)
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(ctx, name, desc)
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_unalignedData	(unalignedData)
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_vao				(0)
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_program			(DE_NULL)
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindingRenderCase::~BindingRenderCase (void)
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindingRenderCase::init (void)
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// check requirements
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_context.getRenderTarget().getWidth() < TEST_RENDER_SIZE || m_context.getRenderTarget().getHeight() < TEST_RENDER_SIZE)
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::NotSupportedError("Test requires at least " + de::toString<int>(TEST_RENDER_SIZE) + "x" + de::toString<int>(TEST_RENDER_SIZE) + " render target");
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// resources
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_context.getRenderContext().getFunctions().genVertexArrays(1, &m_vao);
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_context.getRenderContext().getFunctions().getError() != GL_NO_ERROR)
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("could not gen vao");
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	createBuffers();
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	createShader();
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindingRenderCase::deinit (void)
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_vao)
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getRenderContext().getFunctions().deleteVertexArrays(1, &m_vao);
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_vao = 0;
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_program;
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = DE_NULL;
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1903c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindingRenderCase::IterateResult BindingRenderCase::iterate (void)
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface surface(TEST_RENDER_SIZE, TEST_RENDER_SIZE);
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// draw pattern
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	renderTo(surface);
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// verify results
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (verifyImageYellowGreen(surface, m_testCtx.getLog(), false))
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (m_unalignedData)
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Failed to draw with unaligned data");
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed");
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleBindingCase : public BindingRenderCase
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum CaseFlag
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_ATTRIB_UNALIGNED			= (1<<0),		// !< unalign attributes with relativeOffset
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_ATTRIB_ALIGNED				= (1<<1),		// !< align attributes with relativeOffset to the buffer begin (and not buffer offset)
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_ATTRIBS_MULTIPLE_ELEMS		= (1<<2),		// !< use multiple attribute elements
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_ATTRIBS_SHARED_ELEMS		= (1<<3),		// !< use multiple shared attribute elements. xyzw & rgba stored as (x, y, zr, wg, b, a)
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_BUF_ALIGNED_OFFSET			= (1<<4),		// !< use aligned offset to the buffer object
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_BUF_UNALIGNED_OFFSET		= (1<<5),		// !< use unaligned offset to the buffer object
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		FLAG_BUF_UNALIGNED_STRIDE		= (1<<6),		// !< unalign buffer elements
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						SingleBindingCase	(Context& ctx, const char* name, int flags);
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~SingleBindingCase	(void);
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				init				(void);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				deinit				(void);
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	struct TestSpec
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		bufferOffset;
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		bufferStride;
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		positionAttrOffset;
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		colorAttrOffset;
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool	hasColorAttr;
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enum
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GRID_SIZE = 20
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	};
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				renderTo			(tcu::Surface& dst);
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static TestSpec		genTestSpec			(int flags);
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static std::string	genTestDescription	(int flags);
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static bool			isDataUnaligned		(int flags);
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				createBuffers		(void);
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				createShader		(void);
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::string			genVertexSource		(void);
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const TestSpec		m_spec;
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glw::GLuint			m_buf;
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2603c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleBindingCase::SingleBindingCase (Context& ctx, const char* name, int flags)
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: BindingRenderCase	(ctx, name, genTestDescription(flags).c_str(), isDataUnaligned(flags))
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_spec			(genTestSpec(flags))
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_buf				(0)
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(!((flags & FLAG_ATTRIB_UNALIGNED) && (flags & FLAG_ATTRIB_ALIGNED)));
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(!((flags & FLAG_ATTRIB_ALIGNED) && (flags & FLAG_BUF_UNALIGNED_STRIDE)));
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(isDataUnaligned(flags));
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2713c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleBindingCase::~SingleBindingCase (void)
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::init (void)
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// log what we are trying to do
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.getLog()	<< tcu::TestLog::Message
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "Rendering " << (int)GRID_SIZE << "x" << (int)GRID_SIZE << " grid.\n"
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "Buffer format:\n"
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "	bufferOffset: " << m_spec.bufferOffset << "\n"
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "	bufferStride: " << m_spec.bufferStride << "\n"
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "Vertex position format:\n"
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "	type: float4\n"
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "	offset: " << m_spec.positionAttrOffset << "\n"
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< "	total offset: " << m_spec.bufferOffset + m_spec.positionAttrOffset << "\n"
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						<< tcu::TestLog::EndMessage;
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_spec.hasColorAttr)
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog()	<< tcu::TestLog::Message
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							<< "Color:\n"
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							<< "	type: float4\n"
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							<< "	offset: " << m_spec.colorAttrOffset << "\n"
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							<< "	total offset: " << m_spec.bufferOffset + m_spec.colorAttrOffset << "\n"
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry							<< tcu::TestLog::EndMessage;
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// init
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BindingRenderCase::init();
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::deinit (void)
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_buf)
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_buf);
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_buf = 0;
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BindingRenderCase::deinit();
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::renderTo (tcu::Surface& dst)
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::CallLogWrapper gl				(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			positionLoc		= gl.glGetAttribLocation(m_program->getProgram(), "a_position");
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			colorLoc		= gl.glGetAttribLocation(m_program->getProgram(), "a_color");
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			colorUniformLoc	= gl.glGetUniformLocation(m_program->getProgram(), "u_color");
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.enableLogging(true);
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glClear(GL_COLOR_BUFFER_BIT);
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glViewport(0, 0, dst.getWidth(), dst.getHeight());
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glBindVertexArray(m_vao);
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.glGetError(), "set vao");
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glUseProgram(m_program->getProgram());
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.glGetError(), "use program");
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_spec.hasColorAttr)
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glBindVertexBuffer(3, m_buf, m_spec.bufferOffset, m_spec.bufferStride);
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glVertexAttribBinding(positionLoc, 3);
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, m_spec.positionAttrOffset);
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glEnableVertexAttribArray(positionLoc);
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glVertexAttribBinding(colorLoc, 3);
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glVertexAttribFormat(colorLoc, 4, GL_FLOAT, GL_FALSE, m_spec.colorAttrOffset);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glEnableVertexAttribArray(colorLoc);
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.glGetError(), "set va");
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glDrawArrays(GL_TRIANGLES, 0, GRID_SIZE*GRID_SIZE*6);
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.glGetError(), "draw");
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glBindVertexBuffer(3, m_buf, m_spec.bufferOffset, m_spec.bufferStride);
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glVertexAttribBinding(positionLoc, 3);
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, m_spec.positionAttrOffset);
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glEnableVertexAttribArray(positionLoc);
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.glGetError(), "set va");
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glUniform4f(colorUniformLoc, 0.0f, 1.0f, 0.0f, 1.0f);
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		gl.glDrawArrays(GL_TRIANGLES, 0, GRID_SIZE*GRID_SIZE*6);
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		GLU_EXPECT_NO_ERROR(gl.glGetError(), "draw");
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glFinish();
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glBindVertexArray(0);
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glUseProgram(0);
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.glGetError(), "clean");
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3713c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleBindingCase::TestSpec SingleBindingCase::genTestSpec (int flags)
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	datumSize				= 4;
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	bufferOffset			= (flags & FLAG_BUF_ALIGNED_OFFSET) ? (32) : (flags & FLAG_BUF_UNALIGNED_OFFSET) ? (19) : (0);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	attrBufAlignment		= ((bufferOffset % datumSize) == 0) ? (0) : (datumSize - (bufferOffset % datumSize));
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	positionAttrOffset		= (flags & FLAG_ATTRIB_UNALIGNED) ? (3) : (flags & FLAG_ATTRIB_ALIGNED) ? (attrBufAlignment) : (0);
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool	hasColorAttr			= (flags & FLAG_ATTRIBS_SHARED_ELEMS) || (flags & FLAG_ATTRIBS_MULTIPLE_ELEMS);
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	colorAttrOffset			= (flags & FLAG_ATTRIBS_SHARED_ELEMS) ? (2 * datumSize) : (flags & FLAG_ATTRIBS_MULTIPLE_ELEMS) ? (4 * datumSize) : (-1);
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	bufferStrideBase		= de::max(positionAttrOffset + 4 * datumSize, colorAttrOffset + 4 * datumSize);
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	bufferStrideAlignment	= ((bufferStrideBase % datumSize) == 0) ? (0) : (datumSize - (bufferStrideBase % datumSize));
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	bufferStridePadding		= ((flags & FLAG_BUF_UNALIGNED_STRIDE) && deIsAligned32(bufferStrideBase, datumSize)) ? (13) : (!(flags & FLAG_BUF_UNALIGNED_STRIDE) && !deIsAligned32(bufferStrideBase, datumSize)) ? (bufferStrideAlignment) : (0);
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	TestSpec spec;
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	spec.bufferOffset			= bufferOffset;
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	spec.bufferStride			= bufferStrideBase + bufferStridePadding;
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	spec.positionAttrOffset		= positionAttrOffset;
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	spec.colorAttrOffset		= colorAttrOffset;
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	spec.hasColorAttr			= hasColorAttr;
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIB_UNALIGNED)
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(!deIsAligned32(spec.bufferOffset + spec.positionAttrOffset, datumSize));
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else if (flags & FLAG_ATTRIB_ALIGNED)
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(deIsAligned32(spec.bufferOffset + spec.positionAttrOffset, datumSize));
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_BUF_UNALIGNED_STRIDE)
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(!deIsAligned32(spec.bufferStride, datumSize));
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(deIsAligned32(spec.bufferStride, datumSize));
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return spec;
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string SingleBindingCase::genTestDescription (int flags)
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream buf;
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	buf << "draw test pattern";
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIB_UNALIGNED)
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", attribute offset (unaligned)";
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIB_ALIGNED)
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", attribute offset (aligned)";
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIBS_MULTIPLE_ELEMS)
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", 2 attributes";
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIBS_SHARED_ELEMS)
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", 2 attributes (some components shared)";
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_BUF_ALIGNED_OFFSET)
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", buffer offset aligned";
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_BUF_UNALIGNED_OFFSET)
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", buffer offset unaligned";
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_BUF_UNALIGNED_STRIDE)
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << ", buffer stride unaligned";
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return buf.str();
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool SingleBindingCase::isDataUnaligned (int flags)
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIB_UNALIGNED)
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return true;
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (flags & FLAG_ATTRIB_ALIGNED)
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		return false;
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return (flags & FLAG_BUF_UNALIGNED_OFFSET) || (flags & FLAG_BUF_UNALIGNED_STRIDE);
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::createBuffers (void)
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&	gl		= m_context.getRenderContext().getFunctions();
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<deUint8>	dataBuf	(m_spec.bufferOffset + m_spec.bufferStride * GRID_SIZE * GRID_SIZE * 6);
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// In interleaved mode color rg and position zw are the same. Select "good" values for r and g
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4			colorA	(0.0f, 1.0f, 0.0f, 1.0f);
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::Vec4			colorB	(0.5f, 1.0f, 0.0f, 1.0f);
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < GRID_SIZE; ++y)
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int x = 0; x < GRID_SIZE; ++x)
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::Vec4&	color = ((x + y) % 2 == 0) ? (colorA) : (colorB);
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const tcu::Vec4		positions[6] =
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Vec4((x+0) / float(GRID_SIZE) * 2.0f - 1.0f, (y+0) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f),
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Vec4((x+0) / float(GRID_SIZE) * 2.0f - 1.0f, (y+1) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f),
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Vec4((x+1) / float(GRID_SIZE) * 2.0f - 1.0f, (y+1) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f),
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Vec4((x+0) / float(GRID_SIZE) * 2.0f - 1.0f, (y+0) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f),
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Vec4((x+1) / float(GRID_SIZE) * 2.0f - 1.0f, (y+1) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f),
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			tcu::Vec4((x+1) / float(GRID_SIZE) * 2.0f - 1.0f, (y+0) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f),
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// copy cell vertices to the buffer.
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int v = 0; v < 6; ++v)
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			memcpy(&dataBuf[m_spec.bufferOffset + m_spec.positionAttrOffset + m_spec.bufferStride * ((y * GRID_SIZE + x) * 6 + v)], positions[v].getPtr(), sizeof(positions[v]));
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// copy color to buffer
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (m_spec.hasColorAttr)
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int v = 0; v < 6; ++v)
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				memcpy(&dataBuf[m_spec.bufferOffset + m_spec.colorAttrOffset + m_spec.bufferStride * ((y * GRID_SIZE + x) * 6 + v)], color.getPtr(), sizeof(color));
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.genBuffers(1, &m_buf);
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindBuffer(GL_ARRAY_BUFFER, m_buf);
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)dataBuf.size(), &dataBuf[0], GL_STATIC_DRAW);
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindBuffer(GL_ARRAY_BUFFER, 0);
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (gl.getError() != GL_NO_ERROR)
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("could not init buffer");
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::createShader (void)
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(genVertexSource()) << glu::FragmentSource(s_colorFragmentShader));
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.getLog() << *m_program;
4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_program->isOk())
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("could not build shader");
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string SingleBindingCase::genVertexSource (void)
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const bool			useUniformColor = !m_spec.hasColorAttr;
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::ostringstream	buf;
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	buf <<	"#version 310 es\n"
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"in highp vec4 a_position;\n";
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!useUniformColor)
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << "in highp vec4 a_color;\n";
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	else
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		buf << "uniform highp vec4 u_color;\n";
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	buf <<	"out highp vec4 v_color;\n"
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"void main (void)\n"
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"{\n"
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	gl_Position = a_position;\n"
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"	v_color = " << ((useUniformColor) ? ("u_color") : ("a_color")) << ";\n"
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			"}\n";
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return buf.str();
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BindVertexBufferCase : public TestCase
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic:
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						BindVertexBufferCase	(Context& ctx, const char* name, const char* desc, int offset, int drawCount);
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry						~BindVertexBufferCase	(void);
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				init					(void);
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	void				deinit					(void);
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	IterateResult		iterate					(void);
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate:
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			m_offset;
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int			m_drawCount;
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32			m_buffer;
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::ShaderProgram*	m_program;
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5313c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindVertexBufferCase::BindVertexBufferCase (Context& ctx, const char* name, const char* desc, int offset, int drawCount)
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase		(ctx, name, desc)
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_offset		(offset)
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_drawCount	(drawCount)
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_buffer		(0)
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_program		(DE_NULL)
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindVertexBufferCase::~BindVertexBufferCase (void)
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deinit();
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindVertexBufferCase::init (void)
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions&	gl		= m_context.getRenderContext().getFunctions();
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<tcu::Vec4>	data	(m_drawCount); // !< some junk data to make sure buffer is really allocated
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.genBuffers(1, &m_buffer);
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bindBuffer(GL_ARRAY_BUFFER, m_buffer);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.bufferData(GL_ARRAY_BUFFER, int(m_drawCount * sizeof(tcu::Vec4)), &data[0], GL_STATIC_DRAW);
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.getError(), "buffer gen");
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(s_vertexSource) << glu::FragmentSource(s_fragmentSource));
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_program->isOk())
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_testCtx.getLog() << *m_program;
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError("could not build program");
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindVertexBufferCase::deinit (void)
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (m_buffer)
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_buffer);
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_buffer = 0;
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_program;
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = DE_NULL;
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5753c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindVertexBufferCase::IterateResult BindVertexBufferCase::iterate (void)
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::CallLogWrapper		gl			(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const deInt32			positionLoc = gl.glGetAttribLocation(m_program->getProgram(), "a_position");
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface			dst			(m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight());
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::VertexArray		vao			(m_context.getRenderContext());
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.enableLogging(true);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glClear(GL_COLOR_BUFFER_BIT);
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup");
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glUseProgram(m_program->getProgram());
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.glGetError(), "use program");
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glBindVertexArray(*vao);
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glEnableVertexAttribArray(positionLoc);
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, 0);
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glVertexAttribBinding(positionLoc, 0);
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glBindVertexBuffer(0, m_buffer, m_offset, int(sizeof(tcu::Vec4)));
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	GLU_EXPECT_NO_ERROR(gl.glGetError(), "set buffer");
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glDrawArrays(GL_POINTS, 0, m_drawCount);
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// allow errors after attempted out-of-bounds memory access
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const deUint32 error = gl.glGetError();
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (error != GL_NO_ERROR)
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_testCtx.getLog() << tcu::TestLog::Message << "Got error: " << glu::getErrorStr(error) << ", ignoring..." << tcu::TestLog::EndMessage;
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// read pixels to wait for rendering
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	gl.glFinish();
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess());
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return STOP;
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6183c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexAttributeBindingTests::VertexAttributeBindingTests (Context& context)
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "vertex_attribute_binding", "Test vertex attribute binding stress tests")
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6233c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexAttributeBindingTests::~VertexAttributeBindingTests (void)
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid VertexAttributeBindingTests::init (void)
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup* const unalignedGroup	= new tcu::TestCaseGroup(m_testCtx, "unaligned",		"Unaligned access");
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::TestCaseGroup* const bufferRangeGroup	= new tcu::TestCaseGroup(m_testCtx, "buffer_bounds",	"Source data over buffer bounds");
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(unalignedGroup);
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	addChild(bufferRangeGroup);
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .unaligned
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "elements_1_unaligned",																		  SingleBindingCase::FLAG_ATTRIB_UNALIGNED));
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "offset_elements_1_unaligned",				SingleBindingCase::FLAG_BUF_ALIGNED_OFFSET		| SingleBindingCase::FLAG_ATTRIB_UNALIGNED));
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_1",				SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET	| 0));
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_1_unaligned",		SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET	| SingleBindingCase::FLAG_ATTRIB_UNALIGNED));
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_2",				SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET	| SingleBindingCase::FLAG_ATTRIBS_MULTIPLE_ELEMS));
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_2_share_elements",	SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET	| SingleBindingCase::FLAG_ATTRIBS_SHARED_ELEMS));
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_stride_elements_1",				SingleBindingCase::FLAG_BUF_UNALIGNED_STRIDE	| 0));
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_stride_elements_2",				SingleBindingCase::FLAG_BUF_UNALIGNED_STRIDE	| SingleBindingCase::FLAG_ATTRIBS_MULTIPLE_ELEMS));
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_stride_elements_2_share_elements",	SingleBindingCase::FLAG_BUF_UNALIGNED_STRIDE	| SingleBindingCase::FLAG_ATTRIBS_SHARED_ELEMS));
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// .buffer_bounds
6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// bind buffer offset cases
6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_over_bounds_10",		"Offset over buffer bounds",				0x00210000, 10));
6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_over_bounds_1000",	"Offset over buffer bounds",				0x00210000, 1000));
6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_near_wrap_10",		"Offset over buffer bounds, near wrapping",	0x7FFFFFF0, 10));
6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_near_wrap_1000",		"Offset over buffer bounds, near wrapping",	0x7FFFFFF0, 1000));
6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Stress
6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31
6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
663