es2pTextureFilteringTests.cpp revision 3c827367444ee418f129b2c238299f49d3264554
1/*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
4 *
5 * Copyright 2014 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 *//*!
20 * \file
21 * \brief Texture filtering performance tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "es2pTextureFilteringTests.hpp"
25#include "es2pTextureCases.hpp"
26#include "tcuMatrixUtil.hpp"
27
28#include "glwEnums.hpp"
29
30using std::string;
31
32namespace deqp
33{
34namespace gles2
35{
36namespace Performance
37{
38
39TextureFilteringTests::TextureFilteringTests (Context& context)
40	: TestCaseGroup(context, "filter", "Texture Filtering Performance Tests")
41{
42}
43
44TextureFilteringTests::~TextureFilteringTests (void)
45{
46}
47
48void TextureFilteringTests::init (void)
49{
50	static const struct
51	{
52		const char*	name;
53		deUint32	format;
54		deUint32	dataType;
55	} texFormats[] =
56	{
57		{ "rgb565",		GL_RGB,				GL_UNSIGNED_SHORT_5_6_5 },
58		{ "rgba8888",	GL_RGBA,			GL_UNSIGNED_BYTE }
59	};
60	static const struct
61	{
62		const char*	name;
63		deUint32	filter;
64		bool		minify;
65	} cases[] =
66	{
67		{ "nearest",				GL_NEAREST,					true	},
68		{ "nearest",				GL_NEAREST,					false	},
69		{ "linear",					GL_LINEAR,					true	},
70		{ "linear",					GL_LINEAR,					false	},
71		{ "nearest_mipmap_nearest",	GL_NEAREST_MIPMAP_NEAREST,	true	},
72		{ "nearest_mipmap_linear",	GL_NEAREST_MIPMAP_LINEAR,	true	},
73		{ "linear_mipmap_nearest",	GL_LINEAR_MIPMAP_NEAREST,	true	},
74		{ "linear_mipmap_linear",	GL_LINEAR_MIPMAP_LINEAR,	true	}
75	};
76
77	tcu::Mat3 minTransform	= tcu::translationMatrix(tcu::Vec2(-0.3f, -0.6f)) * tcu::Mat3(tcu::Vec3(1.7f, 2.3f, 1.0f));
78	tcu::Mat3 magTransform	= tcu::translationMatrix(tcu::Vec2( 0.3f,  0.4f)) * tcu::Mat3(tcu::Vec3(0.3f, 0.2f, 1.0f));
79
80	for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(cases); caseNdx++)
81	{
82		for (int formatNdx = 0; formatNdx < DE_LENGTH_OF_ARRAY(texFormats); formatNdx++)
83		{
84			deUint32	format		= texFormats[formatNdx].format;
85			deUint32	dataType	= texFormats[formatNdx].dataType;
86			deUint32	minFilter	= cases[caseNdx].filter;
87			deUint32	magFilter	= (minFilter == GL_NEAREST || minFilter == GL_LINEAR) ? minFilter : GL_LINEAR;
88			deUint32	wrapS		= GL_REPEAT;
89			deUint32	wrapT		= GL_REPEAT;
90			int			numTextures	= 1;
91			bool		minify		= cases[caseNdx].minify;
92			string		name		= string(cases[caseNdx].name) + (minify ? "_minify_" : "_magnify_") + texFormats[formatNdx].name;
93
94			addChild(new Texture2DRenderCase(m_context, name.c_str(), "", format, dataType, wrapS, wrapT, minFilter, magFilter, minify ? minTransform : magTransform, numTextures, true /* pot */));
95		}
96	}
97}
98
99} // Performance
100} // gles2
101} // deqp
102