13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*-------------------------------------------------------------------------
23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.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 Buffer test utilities.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fBufferTestUtil.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRandomValueIterator.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp"
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuFormatUtil.hpp"
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp"
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp"
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp"
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp"
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp"
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp"
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMemory.h"
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp"
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm>
403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp"
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace BufferTestUtil
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	VERIFY_QUAD_SIZE					= 8,		//!< Quad size in VertexArrayVerifier
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	MAX_LINES_PER_INDEX_ARRAY_DRAW		= 128,		//!< Maximum number of lines per one draw in IndexArrayVerifier
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INDEX_ARRAY_DRAW_VIEWPORT_WIDTH		= 128,
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	INDEX_ARRAY_DRAW_VIEWPORT_HEIGHT	= 128
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry};
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const bool LOG_VERIFIER_CALLS = false; //! \note Especially array verifier generates a lot of calls.
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog;
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector;
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::set;
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Helper functions.
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid fillWithRandomBytes (deUint8* ptr, int numBytes, deUint32 seed)
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::copy(tcu::RandomValueIterator<deUint8>::begin(seed, numBytes), tcu::RandomValueIterator<deUint8>::end(), ptr);
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool compareByteArrays (tcu::TestLog& log, const deUint8* resPtr, const deUint8* refPtr, int numBytes)
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool			isOk			= true;
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		maxSpanLen		= 8;
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int		maxDiffSpans	= 4;
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				numDiffSpans	= 0;
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				diffSpanStart	= -1;
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int				ndx				= 0;
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Section("Verify", "Verification result");
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (;ndx < numBytes; ndx++)
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (resPtr[ndx] != refPtr[ndx])
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (diffSpanStart < 0)
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				diffSpanStart = ndx;
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = false;
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else if (diffSpanStart >= 0)
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			if (numDiffSpans < maxDiffSpans)
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int len			= ndx-diffSpanStart;
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int	printLen	= de::min(len, maxSpanLen);
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				log << TestLog::Message << len << " byte difference at offset " << diffSpanStart << "\n"
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										<< "  expected "	<< tcu::formatArray(tcu::Format::HexIterator<deUint8>(refPtr+diffSpanStart), tcu::Format::HexIterator<deUint8>(refPtr+diffSpanStart+printLen)) << "\n"
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										<< "  got "			<< tcu::formatArray(tcu::Format::HexIterator<deUint8>(resPtr+diffSpanStart), tcu::Format::HexIterator<deUint8>(resPtr+diffSpanStart+printLen))
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< TestLog::EndMessage;
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			else
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				log << TestLog::Message << "(output too long, truncated)" << TestLog::EndMessage;
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			numDiffSpans	+= 1;
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			diffSpanStart	 = -1;
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (diffSpanStart >= 0)
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (numDiffSpans < maxDiffSpans)
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int len			= ndx-diffSpanStart;
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				int	printLen	= de::min(len, maxSpanLen);
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				log << TestLog::Message << len << " byte difference at offset " << diffSpanStart << "\n"
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										<< "  expected "	<< tcu::formatArray(tcu::Format::HexIterator<deUint8>(refPtr+diffSpanStart), tcu::Format::HexIterator<deUint8>(refPtr+diffSpanStart+printLen)) << "\n"
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry										<< "  got "			<< tcu::formatArray(tcu::Format::HexIterator<deUint8>(resPtr+diffSpanStart), tcu::Format::HexIterator<deUint8>(resPtr+diffSpanStart+printLen))
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					<< TestLog::EndMessage;
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		else
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			log << TestLog::Message << "(output too long, truncated)" << TestLog::EndMessage;
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::Message << (isOk ? "Verification passed." : "Verification FAILED!") << TestLog::EndMessage;
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	log << TestLog::EndSection;
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getBufferTargetName (deUint32 target)
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (target)
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_ARRAY_BUFFER:				return "array";
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_ELEMENT_ARRAY_BUFFER:		return "element_array";
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(false);
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return DE_NULL;
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst char* getUsageHintName (deUint32 hint)
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (hint)
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_STREAM_DRAW:	return "stream_draw";
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_STATIC_DRAW:	return "static_draw";
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case GL_DYNAMIC_DRAW:	return "dynamic_draw";
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			DE_ASSERT(false);
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			return DE_NULL;
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// BufferCase
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1643c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferCase::BufferCase (Context& context, const char* name, const char* description)
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCase			(context, name, description)
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, CallLogWrapper	(context.getRenderContext().getFunctions(), m_context.getTestContext().getLog())
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferCase::~BufferCase (void)
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enableLogging(false);
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	BufferCase::deinit();
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferCase::init (void)
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enableLogging(true);
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferCase::deinit (void)
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (set<deUint32>::const_iterator bufIter = m_allocatedBuffers.begin(); bufIter != m_allocatedBuffers.end(); bufIter++)
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDeleteBuffers(1, &(*bufIter));
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1873c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint32 BufferCase::genBuffer (void)
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32 buf = 0;
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glGenBuffers(1, &buf);
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (buf != 0)
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		try
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			m_allocatedBuffers.insert(buf);
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		catch (const std::exception&)
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			glDeleteBuffers(1, &buf);
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			throw;
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return buf;
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferCase::deleteBuffer (deUint32 buffer)
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glDeleteBuffers(1, &buffer);
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_allocatedBuffers.erase(buffer);
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferCase::checkError (void)
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glw::GLenum err = glGetError();
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (err != GL_NO_ERROR)
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		throw tcu::TestError(string("Got ") + glu::getErrorStr(err).toString());
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// ReferenceBuffer
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceBuffer::setSize (int numBytes)
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_data.resize(numBytes);
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceBuffer::setData (int numBytes, const deUint8* bytes)
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_data.resize(numBytes);
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::copy(bytes, bytes+numBytes, m_data.begin());
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceBuffer::setSubData (int offset, int numBytes, const deUint8* bytes)
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(de::inBounds(offset, 0, (int)m_data.size()) && de::inRange(offset+numBytes, offset, (int)m_data.size()));
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::copy(bytes, bytes+numBytes, m_data.begin()+offset);
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// BufferVerifierBase
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferVerifierBase::BufferVerifierBase (Context& context)
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: CallLogWrapper	(context.getRenderContext().getFunctions(), context.getTestContext().getLog())
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_context			(context)
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	enableLogging(LOG_VERIFIER_CALLS);
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// BufferVerifier
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferVerifier::BufferVerifier (Context& context, VerifyType verifyType)
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: m_verifier(DE_NULL)
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	switch (verifyType)
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case VERIFY_AS_VERTEX_ARRAY:	m_verifier = new VertexArrayVerifier(context);	break;
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		case VERIFY_AS_INDEX_ARRAY:		m_verifier = new IndexArrayVerifier	(context);	break;
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		default:
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			TCU_FAIL("Unsupported verifier");
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2613c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferVerifier::~BufferVerifier (void)
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_verifier;
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool BufferVerifier::verify (deUint32 buffer, const deUint8* reference, int offset, int numBytes)
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(numBytes >= getMinSize());
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(offset%getAlignment() == 0);
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT((offset+numBytes)%getAlignment() == 0);
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return m_verifier->verify(buffer, reference, offset, numBytes);
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// VertexArrayVerifier
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2763c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexArrayVerifier::VertexArrayVerifier (Context& context)
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: BufferVerifierBase	(context)
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_program				(DE_NULL)
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_posLoc				(0)
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_byteVecLoc			(0)
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"attribute highp vec2 a_position;\n"
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"attribute mediump vec3 a_byteVec;\n"
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"varying mediump vec3 v_byteVec;\n"
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"void main (void)\n"
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"{\n"
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	gl_Position = vec4(a_position, 0.0, 1.0);\n"
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	v_byteVec = a_byteVec;\n"
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"}\n",
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"varying mediump vec3 v_byteVec;\n"
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"void main (void)\n"
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"{\n"
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	gl_FragColor = vec4(v_byteVec, 1.0);\n"
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"}\n"));
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_program->isOk())
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getTestContext().getLog() << *m_program;
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete m_program;
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_FAIL("Compile failed");
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& funcs = context.getRenderContext().getFunctions();
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_posLoc		= funcs.getAttribLocation(m_program->getProgram(), "a_position");
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_byteVecLoc	= funcs.getAttribLocation(m_program->getProgram(), "a_byteVec");
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3103c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexArrayVerifier::~VertexArrayVerifier (void)
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_program;
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void computePositions (vector<tcu::Vec2>& positions, int gridSizeX, int gridSizeY)
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	positions.resize(gridSizeX*gridSizeY*4);
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < gridSizeY; y++)
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int x = 0; x < gridSizeX; x++)
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	sx0			= (x+0) / (float)gridSizeX;
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	sy0			= (y+0) / (float)gridSizeY;
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	sx1			= (x+1) / (float)gridSizeX;
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	sy1			= (y+1) / (float)gridSizeY;
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	fx0			= 2.0f * sx0 - 1.0f;
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	fy0			= 2.0f * sy0 - 1.0f;
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	fx1			= 2.0f * sx1 - 1.0f;
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		float	fy1			= 2.0f * sy1 - 1.0f;
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		baseNdx		= (y * gridSizeX + x)*4;
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[baseNdx+0] = tcu::Vec2(fx0, fy0);
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[baseNdx+1] = tcu::Vec2(fx0, fy1);
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[baseNdx+2] = tcu::Vec2(fx1, fy0);
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		positions[baseNdx+3] = tcu::Vec2(fx1, fy1);
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void computeIndices (vector<deUint16>& indices, int gridSizeX, int gridSizeY)
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	indices.resize(3 * 2 * gridSizeX * gridSizeY);
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int quadNdx = 0; quadNdx < gridSizeX*gridSizeY; quadNdx++)
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int v00 = quadNdx*4 + 0;
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int v01 = quadNdx*4 + 1;
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int v10 = quadNdx*4 + 2;
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int v11 = quadNdx*4 + 3;
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(v11 < (1<<16));
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[quadNdx*6 + 0] = (deUint16)v10;
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[quadNdx*6 + 1] = (deUint16)v00;
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[quadNdx*6 + 2] = (deUint16)v01;
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[quadNdx*6 + 3] = (deUint16)v10;
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[quadNdx*6 + 4] = (deUint16)v01;
3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		indices[quadNdx*6 + 5] = (deUint16)v11;
3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic inline tcu::Vec4 fetchVtxColor (const deUint8* ptr, int vtxNdx)
3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return tcu::RGBA(*(ptr + vtxNdx*3 + 0),
3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 *(ptr + vtxNdx*3 + 1),
3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 *(ptr + vtxNdx*3 + 2),
3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry					 255).toVec();
3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void renderQuadGridReference (tcu::Surface& dst, int numQuads, int rowLength, const deUint8* inPtr)
3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	using tcu::Vec4;
3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.setSize(rowLength*VERIFY_QUAD_SIZE, (numQuads/rowLength + (numQuads%rowLength != 0 ? 1 : 0))*VERIFY_QUAD_SIZE);
3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::PixelBufferAccess dstAccess = dst.getAccess();
3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::clear(dstAccess, tcu::IVec4(0, 0, 0, 0xff));
3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int quadNdx = 0; quadNdx < numQuads; quadNdx++)
3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		x0		= (quadNdx%rowLength)*VERIFY_QUAD_SIZE;
3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		y0		= (quadNdx/rowLength)*VERIFY_QUAD_SIZE;
3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4	v00		= fetchVtxColor(inPtr, quadNdx*4 + 0);
3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4	v10		= fetchVtxColor(inPtr, quadNdx*4 + 1);
3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4	v01		= fetchVtxColor(inPtr, quadNdx*4 + 2);
3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		Vec4	v11		= fetchVtxColor(inPtr, quadNdx*4 + 3);
3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int y = 0; y < VERIFY_QUAD_SIZE; y++)
3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < VERIFY_QUAD_SIZE; x++)
3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			float		fx		= (float)(x+0.5f) / (float)VERIFY_QUAD_SIZE;
3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			float		fy		= (float)(y+0.5f) / (float)VERIFY_QUAD_SIZE;
3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			bool		tri		= fx + fy <= 1.0f;
3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			float		tx		= tri ? fx : (1.0f-fx);
3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			float		ty		= tri ? fy : (1.0f-fy);
3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4&	t0		= tri ? v00 : v11;
3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4&	t1		= tri ? v01 : v10;
3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Vec4&	t2		= tri ? v10 : v01;
4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Vec4		color	= t0 + (t1-t0)*tx + (t2-t0)*ty;
4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			dstAccess.setPixel(color, x0+x, y0+y);
4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool VertexArrayVerifier::verify (deUint32 buffer, const deUint8* refPtr, int offset, int numBytes)
4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RenderTarget&	renderTarget		= m_context.getRenderContext().getRenderTarget();
4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					numBytesInVtx		= 3;
4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					numBytesInQuad		= numBytesInVtx*4;
4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxQuadsX			= de::min(128, renderTarget.getWidth()	/ VERIFY_QUAD_SIZE);
4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxQuadsY			= de::min(128, renderTarget.getHeight()	/ VERIFY_QUAD_SIZE);
4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							maxQuadsPerBatch	= maxQuadsX*maxQuadsY;
4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							numVerified			= 0;
4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	deUint32					program				= m_program->getProgram();
4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::RGBA					threshold			= renderTarget.getPixelFormat().getColorThreshold() + tcu::RGBA(3,3,3,3);
4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						isOk				= true;
4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<tcu::Vec2>			positions;
4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	vector<deUint16>			indices;
4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface				rendered;
4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface				reference;
4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_ASSERT(numBytes >= numBytesInQuad); // Can't render full quad with smaller buffers.
4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computePositions(positions, maxQuadsX, maxQuadsY);
4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeIndices(indices, maxQuadsX, maxQuadsY);
4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Reset buffer bindings.
4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindBuffer				(GL_ELEMENT_ARRAY_BUFFER,	0);
4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindBuffer				(GL_ARRAY_BUFFER,			0);
4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup rendering state.
4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glViewport					(0, 0, maxQuadsX*VERIFY_QUAD_SIZE, maxQuadsY*VERIFY_QUAD_SIZE);
4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glClearColor				(0.0f, 0.0f, 0.0f, 1.0f);
4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glUseProgram				(program);
4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnableVertexAttribArray	(m_posLoc);
4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glVertexAttribPointer		(m_posLoc, 2, GL_FLOAT, GL_FALSE, 0, &positions[0]);
4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnableVertexAttribArray	(m_byteVecLoc);
4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindBuffer				(GL_ARRAY_BUFFER, buffer);
4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	while (numVerified < numBytes)
4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numRemaining		= numBytes-numVerified;
4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool	isLeftoverBatch		= numRemaining < numBytesInQuad;
4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numBytesToVerify	= isLeftoverBatch ? numBytesInQuad				: de::min(maxQuadsPerBatch*numBytesInQuad, numRemaining - numRemaining%numBytesInQuad);
4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		curOffset			= isLeftoverBatch ? (numBytes-numBytesInQuad)	: numVerified;
4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numQuads			= numBytesToVerify/numBytesInQuad;
4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numCols				= de::min(maxQuadsX, numQuads);
4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numRows				= numQuads/maxQuadsX + (numQuads%maxQuadsX != 0 ? 1 : 0);
4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		string	imageSetDesc		= string("Bytes ") + de::toString(offset+curOffset) + " to " + de::toString(offset+curOffset+numBytesToVerify-1);
4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(numBytesToVerify > 0 && numBytesToVerify%numBytesInQuad == 0);
4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(de::inBounds(curOffset, 0, numBytes));
4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		DE_ASSERT(de::inRange(curOffset+numBytesToVerify, curOffset, numBytes));
4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Render batch.
4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClear					(GL_COLOR_BUFFER_BIT);
4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glVertexAttribPointer	(m_byteVecLoc, 3, GL_UNSIGNED_BYTE, GL_TRUE, 0, (const glw::GLvoid*)(deUintptr)(offset + curOffset));
4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDrawElements			(GL_TRIANGLES, numQuads*6, GL_UNSIGNED_SHORT, &indices[0]);
4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		renderQuadGridReference(reference,  numQuads, numCols, refPtr + offset + curOffset);
4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		rendered.setSize(numCols*VERIFY_QUAD_SIZE, numRows*VERIFY_QUAD_SIZE);
4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels(m_context.getRenderContext(), 0, 0, rendered.getAccess());
4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!tcu::pixelThresholdCompare(m_context.getTestContext().getLog(), "RenderResult", imageSetDesc.c_str(), reference, rendered, threshold, tcu::COMPARE_LOG_RESULT))
4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = false;
4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		numVerified += isLeftoverBatch ? numRemaining : numBytesToVerify;
4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glDisableVertexAttribArray	(m_posLoc);
4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glDisableVertexAttribArray	(m_byteVecLoc);
4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// IndexArrayVerifier
4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
4863c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIndexArrayVerifier::IndexArrayVerifier (Context& context)
4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: BufferVerifierBase	(context)
4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_program				(DE_NULL)
4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_posLoc				(0)
4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	, m_colorLoc			(0)
4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(
4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"attribute highp vec2 a_position;\n"
4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"attribute mediump vec3 a_color;\n"
4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"varying mediump vec3 v_color;\n"
4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"void main (void)\n"
4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"{\n"
4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	gl_Position = vec4(a_position, 0.0, 1.0);\n"
4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	v_color = a_color;\n"
5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"}\n",
5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"varying mediump vec3 v_color;\n"
5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"void main (void)\n"
5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"{\n"
5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"	gl_FragColor = vec4(v_color, 1.0);\n"
5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		"}\n"));
5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	if (!m_program->isOk())
5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		m_context.getTestContext().getLog() << *m_program;
5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		delete m_program;
5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TCU_FAIL("Compile failed");
5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const glw::Functions& funcs = context.getRenderContext().getFunctions();
5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_posLoc	= funcs.getAttribLocation(m_program->getProgram(), "a_position");
5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	m_colorLoc	= funcs.getAttribLocation(m_program->getProgram(), "a_color");
5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIndexArrayVerifier::~IndexArrayVerifier (void)
5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	delete m_program;
5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void computeIndexVerifierPositions (std::vector<tcu::Vec2>& dst)
5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	numPosX		= 16;
5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	numPosY		= 16;
5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.resize(numPosX*numPosY);
5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int y = 0; y < numPosY; y++)
5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int x = 0; x < numPosX; x++)
5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			float	xf	= float(x) / float(numPosX-1);
5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			float	yf	= float(y) / float(numPosY-1);
5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			dst[y*numPosX + x] = tcu::Vec2(2.0f*xf - 1.0f, 2.0f*yf - 1.0f);
5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void computeIndexVerifierColors (std::vector<tcu::Vec3>& dst)
5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int	numColors	= 256;
5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float	minVal		= 0.1f;
5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const float maxVal		= 0.5f;
5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	de::Random	rnd			(0xabc231);
5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	dst.resize(numColors);
5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (std::vector<tcu::Vec3>::iterator i = dst.begin(); i != dst.end(); ++i)
5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		i->x()	= rnd.getFloat(minVal, maxVal);
5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		i->y()	= rnd.getFloat(minVal, maxVal);
5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		i->z()	= rnd.getFloat(minVal, maxVal);
5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<typename T>
5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void execVertexFetch (T* dst, const T* src, const deUint8* indices, int numIndices)
5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	for (int i = 0; i < numIndices; ++i)
5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		dst[i] = src[indices[i]];
5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool IndexArrayVerifier::verify (deUint32 buffer, const deUint8* refPtr, int offset, int numBytes)
5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RenderTarget&	renderTarget		= m_context.getRenderContext().getRenderTarget();
5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					viewportW			= de::min<int>(INDEX_ARRAY_DRAW_VIEWPORT_WIDTH, renderTarget.getWidth());
5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					viewportH			= de::min<int>(INDEX_ARRAY_DRAW_VIEWPORT_HEIGHT, renderTarget.getHeight());
5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const int					minBytesPerBatch	= 2;
5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const tcu::RGBA				threshold			(0,0,0,0);
5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<tcu::Vec2>		positions;
5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<tcu::Vec3>		colors;
5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<tcu::Vec2>		fetchedPos			(MAX_LINES_PER_INDEX_ARRAY_DRAW+1);
5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	std::vector<tcu::Vec3>		fetchedColor		(MAX_LINES_PER_INDEX_ARRAY_DRAW+1);
5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface				indexBufferImg		(viewportW, viewportH);
5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	tcu::Surface				referenceImg		(viewportW, viewportH);
5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	int							numVerified			= 0;
5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	bool						isOk				= true;
5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_STATIC_ASSERT(sizeof(tcu::Vec2) == sizeof(float)*2);
5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	DE_STATIC_ASSERT(sizeof(tcu::Vec3) == sizeof(float)*3);
5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeIndexVerifierPositions(positions);
5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	computeIndexVerifierColors(colors);
5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Reset buffer bindings.
5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindBuffer				(GL_ARRAY_BUFFER,			0);
5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBindBuffer				(GL_ELEMENT_ARRAY_BUFFER,	buffer);
5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Setup rendering state.
5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glViewport					(0, 0, viewportW, viewportH);
6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glClearColor				(0.0f, 0.0f, 0.0f, 1.0f);
6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glUseProgram				(m_program->getProgram());
6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnableVertexAttribArray	(m_posLoc);
6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnableVertexAttribArray	(m_colorLoc);
6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glEnable					(GL_BLEND);
6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBlendFunc					(GL_ONE, GL_ONE);
6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	glBlendEquation				(GL_FUNC_ADD);
6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	while (numVerified < numBytes)
6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numRemaining		= numBytes-numVerified;
6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		bool	isLeftoverBatch		= numRemaining < minBytesPerBatch;
6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		numBytesToVerify	= isLeftoverBatch ? minBytesPerBatch			: de::min(MAX_LINES_PER_INDEX_ARRAY_DRAW+1, numRemaining);
6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		int		curOffset			= isLeftoverBatch ? (numBytes-minBytesPerBatch)	: numVerified;
6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		string	imageSetDesc		= string("Bytes ") + de::toString(offset+curOffset) + " to " + de::toString(offset+curOffset+numBytesToVerify-1);
6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Step 1: Render using index buffer.
6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClear					(GL_COLOR_BUFFER_BIT);
6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glVertexAttribPointer	(m_posLoc, 2, GL_FLOAT, GL_FALSE, 0, &positions[0]);
6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glVertexAttribPointer	(m_colorLoc, 3, GL_FLOAT, GL_FALSE, 0, &colors[0]);
6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDrawElements			(GL_LINE_STRIP, numBytesToVerify, GL_UNSIGNED_BYTE, (void*)(deUintptr)(offset+curOffset));
6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels			(m_context.getRenderContext(), 0, 0, indexBufferImg.getAccess());
6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		// Step 2: Do manual fetch and render without index buffer.
6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		execVertexFetch(&fetchedPos[0], &positions[0], refPtr+offset+curOffset, numBytesToVerify);
6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		execVertexFetch(&fetchedColor[0], &colors[0], refPtr+offset+curOffset, numBytesToVerify);
6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glClear					(GL_COLOR_BUFFER_BIT);
6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glVertexAttribPointer	(m_posLoc, 2, GL_FLOAT, GL_FALSE, 0, &fetchedPos[0]);
6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glVertexAttribPointer	(m_colorLoc, 3, GL_FLOAT, GL_FALSE, 0, &fetchedColor[0]);
6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glDrawArrays			(GL_LINE_STRIP, 0, numBytesToVerify);
6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		glu::readPixels			(m_context.getRenderContext(), 0, 0, referenceImg.getAccess());
6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		if (!tcu::pixelThresholdCompare(m_context.getTestContext().getLog(), "RenderResult", imageSetDesc.c_str(), referenceImg, indexBufferImg, threshold, tcu::COMPARE_LOG_RESULT))
6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			isOk = false;
6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			break;
6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		numVerified += isLeftoverBatch ? numRemaining : numBytesToVerify;
6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	return isOk;
6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // BufferTestUtil
6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional
6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
649