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 Long-running stress tests.
223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/
233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2sLongRunningTests.hpp"
253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsLongStressCase.hpp"
263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsLongStressTestUtil.hpp"
273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp"
283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <string>
303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string;
323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp
343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2
363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Stress
383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLongRunningTests::LongRunningTests (Context& context)
413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	: TestCaseGroup(context, "long", "Long-running stress tests")
423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
453c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLongRunningTests::~LongRunningTests (void)
463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LongRunningTests::init (void)
503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{
513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	static const int								Mi			= 1<<20;
523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	const gls::LongStressTestUtil::ProgramLibrary	progLib		(glu::GLSL_VERSION_100_ES);
533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	typedef gls::LongStressCase::FeatureProbabilities Probs;
553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Buffer cases.
573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct MemCase
603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	nameSuffix;
623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	descSuffix;
633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			limit;
643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			redundantBufferFactor;
653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase (const char* n, const char* d, int l, int r) : nameSuffix(n), descSuffix(d), limit(l), redundantBufferFactor(r) {}
663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} memoryLimitCases[] =
673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase("_low_memory",	"; use a low buffer memory usage limit",	8*Mi,		2),
693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase("_high_memory",	"; use a high buffer memory usage limit",	256*Mi,		64)
703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const std::vector<gls::ProgramContext> contexts(1, progLib.generateBufferContext(4));
733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct Case
753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	name;
773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char*	const	desc;
783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			redundantBufferFactor; //!< If non-positive, taken from memoryLimitCases.
793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Probs			probs;
803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case (const char* const name_, const char* const desc_, int bufFact, const Probs& probs_ = Probs()) : name(name_), desc(desc_), redundantBufferFactor(bufFact), probs(probs_) {}
813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("always_reupload",
843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Re-upload buffer data at the beginning of each iteration",
853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 -1,
863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pReuploadBuffer(1.0f)),
873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("always_reupload_bufferdata",
893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Re-upload buffer data at the beginning of each iteration, using glBufferData",
903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 -1,
913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pReuploadBuffer(1.0f).pReuploadWithBufferData(1.0f)),
923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("always_delete",
943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Delete buffers at the end of each iteration, and re-create at the beginning of the next",
953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 -1,
963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pDeleteBuffer(1.0f)),
973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("wasteful",
993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Don't reuse buffers, and only delete them when given memory limit is reached",
1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 2,
1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pWastefulBufferMemoryUsage(1.0f)),
1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("separate_attribute_buffers_wasteful",
1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Give each vertex attribute its own buffer",
1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 2,
1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pSeparateAttribBuffers(1.0f).pWastefulBufferMemoryUsage(1.0f))
1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const bufferGroup = new TestCaseGroup(m_context, "buffer", "Buffer stress tests");
1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(bufferGroup);
1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int memoryLimitNdx = 0; memoryLimitNdx < DE_LENGTH_OF_ARRAY(memoryLimitCases); memoryLimitNdx++)
1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int redundantBufferFactor = cases[caseNdx].redundantBufferFactor > 0 ? cases[caseNdx].redundantBufferFactor : memoryLimitCases[memoryLimitNdx].redundantBufferFactor;
1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				bufferGroup->addChild(new gls::LongStressCase(m_context.getTestContext(), m_context.getRenderContext(),
1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  (string() + cases[caseNdx].name + memoryLimitCases[memoryLimitNdx].nameSuffix).c_str(),
1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  (string() + cases[caseNdx].desc + memoryLimitCases[memoryLimitNdx].descSuffix).c_str(),
1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  0 /* tex memory */, memoryLimitCases[memoryLimitNdx].limit,
1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  1 /* draw calls per iteration */, 50000 /* tris per call */,
1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  contexts, cases[caseNdx].probs,
1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  GL_DYNAMIC_DRAW, GL_DYNAMIC_DRAW,
1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  redundantBufferFactor));
1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Texture cases.
1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct MemCase
1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	nameSuffix;
1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	descSuffix;
1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			limit;
1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			numTextures;
1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase (const char* n, const char* d, int l, int t) : nameSuffix(n), descSuffix(d), limit(l), numTextures(t) {}
1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} memoryLimitCases[] =
1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase("_low_memory",	"; use a low texture memory usage limit",	8*Mi,		6),
1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase("_high_memory",	"; use a high texture memory usage limit",	256*Mi,		192)
1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct Case
1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	name;
1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	desc;
1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			numTextures; //!< If non-positive, taken from memoryLimitCases.
1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Probs			probs;
1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case (const char* const name_, const char* const desc_, int numTextures_, const Probs& probs_ = Probs()) : name(name_), desc(desc_), numTextures(numTextures_), probs(probs_) {}
1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("always_reupload",
1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Re-upload texture data at the beginning of each iteration",
1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 -1,
1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pReuploadTexture(1.0f)),
1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("always_reupload_teximage",
1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Re-upload texture data at the beginning of each iteration, using glTexImage*",
1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 -1,
1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pReuploadTexture(1.0f).pReuploadWithTexImage(1.0f)),
1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("always_delete",
1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Delete textures at the end of each iteration, and re-create at the beginning of the next",
1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 -1,
1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pDeleteTexture(1.0f)),
1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("wasteful",
1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Don't reuse textures, and only delete them when given memory limit is reached",
1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 6,
1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pWastefulTextureMemoryUsage(1.0f))
1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const textureGroup = new TestCaseGroup(m_context, "texture", "Texture stress tests");
1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(textureGroup);
1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int memoryLimitNdx = 0; memoryLimitNdx < DE_LENGTH_OF_ARRAY(memoryLimitCases); memoryLimitNdx++)
1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const int								numTextures		= cases[caseNdx].numTextures > 0 ? cases[caseNdx].numTextures : memoryLimitCases[memoryLimitNdx].numTextures;
1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				const std::vector<gls::ProgramContext>	contexts		(1, progLib.generateTextureContext(numTextures, 512, 512, 0.1f));
1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				textureGroup->addChild(new gls::LongStressCase(m_context.getTestContext(), m_context.getRenderContext(),
1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																(string() + cases[caseNdx].name + memoryLimitCases[memoryLimitNdx].nameSuffix).c_str(),
1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																(string() + cases[caseNdx].desc + memoryLimitCases[memoryLimitNdx].descSuffix).c_str(),
1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																memoryLimitCases[memoryLimitNdx].limit, 1*Mi /* buf memory */,
1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																1 /* draw calls per iteration */, 10000 /* tris per call */,
1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																contexts, cases[caseNdx].probs,
1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry																GL_STATIC_DRAW, GL_STATIC_DRAW));
1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Draw call cases.
1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		const std::vector<gls::ProgramContext> contexts(1, progLib.generateTextureContext(1, 128, 128, 0.5f));
2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct Case
2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	name;
2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	desc;
2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			drawCallsPerIteration;
2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			numTrisPerDrawCall;
2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Probs			probs;
2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case (const char* const name_, const char* const desc_, const int calls, const int tris, const Probs& probs_ = Probs())
2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				: name(name_), desc(desc_), drawCallsPerIteration(calls), numTrisPerDrawCall(tris), probs(probs_) {}
2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("client_memory_data",
2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Use client-memory for index and attribute data, instead of GL buffers",
2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 200, 500,
2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pClientMemoryAttributeData(1.0f).pClientMemoryIndexData(1.0f)),
2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("vary_draw_function",
2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Choose between glDrawElements and glDrawArrays each iteration, with uniform probability",
2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 200, 500,
2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pUseDrawArrays(0.5f)),
2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("few_big_calls",
2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Per iteration, do a few draw calls with a big number of triangles per call",
2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 2, 50000),
2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("many_small_calls",
2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Per iteration, do many draw calls with a small number of triangles per call",
2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 2000, 50)
2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const drawCallGroup = new TestCaseGroup(m_context, "draw_call", "Draw call stress tests");
2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(drawCallGroup);
2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			drawCallGroup->addChild(new gls::LongStressCase(m_context.getTestContext(), m_context.getRenderContext(),
2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															cases[caseNdx].name, cases[caseNdx].desc,
2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															1*Mi /* tex memory */, 2*Mi /* buf memory */,
2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															cases[caseNdx].drawCallsPerIteration, cases[caseNdx].numTrisPerDrawCall,
2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															contexts, cases[caseNdx].probs,
2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															GL_STATIC_DRAW, GL_STATIC_DRAW));
2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Shader cases.
2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		std::vector<gls::ProgramContext> contexts;
2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		contexts.push_back(progLib.generateFragmentPointLightContext(512, 512));
2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		contexts.push_back(progLib.generateVertexUniformLoopLightContext(512, 512));
2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct Case
2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	name;
2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	desc;
2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const Probs			probs;
2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case (const char* const name_, const char* const desc_, const Probs& probs_ = Probs()) : name(name_), desc(desc_), probs(probs_) {}
2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} cases[] =
2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("several_programs",
2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Use several different programs, choosing between them uniformly on each iteration"),
2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			Case("several_programs_always_rebuild",
2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 "Use several different programs, choosing between them uniformly on each iteration, and always rebuild the program",
2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				 Probs().pRebuildProgram(1.0f))
2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const shaderGroup = new TestCaseGroup(m_context, "program", "Shader program stress tests");
2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(shaderGroup);
2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			shaderGroup->addChild(new gls::LongStressCase(m_context.getTestContext(), m_context.getRenderContext(),
2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  cases[caseNdx].name, cases[caseNdx].desc,
2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  3*Mi /* tex memory */, 1*Mi /* buf memory */,
2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  1 /* draw calls per iteration */, 10000 /* tris per call */,
2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  contexts, cases[caseNdx].probs,
2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														  GL_STATIC_DRAW, GL_STATIC_DRAW));
2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	// Mixed cases.
2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	{
2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		static const struct MemCase
2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	nameSuffix;
2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const char* const	descSuffix;
2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			texLimit;
2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			const int			bufLimit;
2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase (const char* n, const char* d, int t, int b) : nameSuffix(n), descSuffix(d), texLimit(t), bufLimit(b) {}
2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		} memoryLimitCases[] =
2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase("_low_memory",	"; use a low memory usage limit",	8*Mi,	8*Mi),
2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			MemCase("_high_memory",	"; use a high memory usage limit",	128*Mi,	128*Mi)
2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		};
2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		TestCaseGroup* const mixedGroup = new TestCaseGroup(m_context, "mixed", "Mixed stress tests");
3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		addChild(mixedGroup);
3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		for (int memoryLimitNdx = 0; memoryLimitNdx < DE_LENGTH_OF_ARRAY(memoryLimitCases); memoryLimitNdx++)
3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		{
3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			mixedGroup->addChild(new gls::LongStressCase(m_context.getTestContext(), m_context.getRenderContext(),
3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 (string() + "buffer_texture_wasteful"					+ memoryLimitCases[memoryLimitNdx].nameSuffix).c_str(),
3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 (string() + "Use both buffers and textures wastefully"	+ memoryLimitCases[memoryLimitNdx].descSuffix).c_str(),
3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 memoryLimitCases[memoryLimitNdx].texLimit, memoryLimitCases[memoryLimitNdx].bufLimit,
3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 1 /* draw calls per iteration */, 10000 /* tris per call */,
3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 std::vector<gls::ProgramContext>(1, progLib.generateBufferAndTextureContext(4, 512, 512)),
3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 Probs()
3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pReuploadTexture				(0.3f)
3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pReuploadWithTexImage			(0.5f)
3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pReuploadBuffer				(0.3f)
3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pReuploadWithBufferData		(0.5f)
3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pDeleteTexture				(0.2f)
3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pDeleteBuffer					(0.2f)
3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pWastefulTextureMemoryUsage	(0.5f)
3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pWastefulBufferMemoryUsage	(0.5f)
3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pRandomBufferUploadTarget		(1.0f)
3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 .pRandomBufferUsage			(1.0f),
3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry														 GL_STATIC_DRAW, GL_STATIC_DRAW));
3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			{
3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				std::vector<gls::ProgramContext> contexts;
3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				contexts.push_back(progLib.generateFragmentPointLightContext(512, 512));
3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				contexts.push_back(progLib.generateVertexUniformLoopLightContext(512, 512));
3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry				mixedGroup->addChild(new gls::LongStressCase(m_context.getTestContext(), m_context.getRenderContext(),
3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 (string() + "random"					+ memoryLimitCases[memoryLimitNdx].nameSuffix).c_str(),
3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 (string() + "Highly random behavior"	+ memoryLimitCases[memoryLimitNdx].descSuffix).c_str(),
3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															  memoryLimitCases[memoryLimitNdx].texLimit, memoryLimitCases[memoryLimitNdx].bufLimit,
3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 1 /* draw calls per iteration */, 10000 /* tris per call */,
3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 contexts,
3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 Probs()
3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pRebuildProgram				(0.3f)
3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pReuploadTexture				(0.3f)
3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pReuploadWithTexImage			(0.3f)
3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pReuploadBuffer				(0.3f)
3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pReuploadWithBufferData		(0.3f)
3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pDeleteTexture				(0.2f)
3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pDeleteBuffer					(0.2f)
3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pWastefulTextureMemoryUsage	(0.3f)
3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pWastefulBufferMemoryUsage	(0.3f)
3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pClientMemoryAttributeData	(0.2f)
3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pClientMemoryIndexData		(0.2f)
3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pSeparateAttribBuffers		(0.4f)
3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pUseDrawArrays				(0.4f)
3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pRandomBufferUploadTarget		(1.0f)
3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 .pRandomBufferUsage			(1.0f),
3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry															 GL_STATIC_DRAW, GL_STATIC_DRAW));
3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry			}
3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry		}
3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry	}
3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}
3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry
3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Stress
3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2
3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp
358