1/*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.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 State Query tests.
22 *//*--------------------------------------------------------------------*/
23
24#include "es3fTextureStateQueryTests.hpp"
25#include "glsStateQueryUtil.hpp"
26#include "glsTextureStateQueryTests.hpp"
27
28#include "gluRenderContext.hpp"
29#include "glwEnums.hpp"
30
31using namespace deqp::gls::StateQueryUtil;
32
33namespace deqp
34{
35namespace gles3
36{
37namespace Functional
38{
39
40static const char* getVerifierSuffix (QueryType type)
41{
42	switch (type)
43	{
44		case QUERY_TEXTURE_PARAM_INTEGER:	return "_gettexparameteri";
45		case QUERY_TEXTURE_PARAM_FLOAT:		return "_gettexparameterf";
46		default:
47			DE_ASSERT(DE_FALSE);
48			return DE_NULL;
49	}
50}
51
52#define FOR_EACH_VERIFIER(VERIFIERS, CODE_BLOCK)												\
53	for (int _verifierNdx = 0; _verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); _verifierNdx++)	\
54	{																							\
55		QueryType verifier = VERIFIERS[_verifierNdx];											\
56		CODE_BLOCK;																				\
57	}
58
59TextureStateQueryTests::TextureStateQueryTests (Context& context)
60	: TestCaseGroup(context, "texture", "Texture State Query tests")
61{
62}
63
64void TextureStateQueryTests::init (void)
65{
66	using namespace gls::TextureStateQueryTests;
67
68	static const QueryType verifiers[] =
69	{
70		QUERY_TEXTURE_PARAM_INTEGER,
71		QUERY_TEXTURE_PARAM_FLOAT
72	};
73
74	static const struct
75	{
76		const char*	name;
77		glw::GLenum	target;
78	} textureTargets[] =
79	{
80		{ "texture_2d",			GL_TEXTURE_2D		},
81		{ "texture_3d",			GL_TEXTURE_3D		},
82		{ "texture_2d_array",	GL_TEXTURE_2D_ARRAY	},
83		{ "texture_cube_map",	GL_TEXTURE_CUBE_MAP	}
84	};
85	static const struct
86	{
87		const char*	name;
88		const char*	desc;
89		TesterType	tester;
90	} states[] =
91	{
92		{ "texture_swizzle_r",			"TEXTURE_SWIZZLE_R",		TESTER_TEXTURE_SWIZZLE_R		},
93		{ "texture_swizzle_g",			"TEXTURE_SWIZZLE_G",		TESTER_TEXTURE_SWIZZLE_G		},
94		{ "texture_swizzle_b",			"TEXTURE_SWIZZLE_B",		TESTER_TEXTURE_SWIZZLE_B		},
95		{ "texture_swizzle_a",			"TEXTURE_SWIZZLE_A",		TESTER_TEXTURE_SWIZZLE_A		},
96		{ "texture_wrap_s",				"TEXTURE_WRAP_S",			TESTER_TEXTURE_WRAP_S			},
97		{ "texture_wrap_t",				"TEXTURE_WRAP_T",			TESTER_TEXTURE_WRAP_T			},
98		{ "texture_wrap_r",				"TEXTURE_WRAP_R",			TESTER_TEXTURE_WRAP_R			},
99		{ "texture_mag_filter",			"TEXTURE_MAG_FILTER",		TESTER_TEXTURE_MAG_FILTER		},
100		{ "texture_min_filter",			"TEXTURE_MIN_FILTER",		TESTER_TEXTURE_MIN_FILTER		},
101		{ "texture_min_lod",			"TEXTURE_MIN_LOD",			TESTER_TEXTURE_MIN_LOD			},
102		{ "texture_max_lod",			"TEXTURE_MAX_LOD",			TESTER_TEXTURE_MAX_LOD			},
103		{ "texture_base_level",			"TEXTURE_BASE_LEVEL",		TESTER_TEXTURE_BASE_LEVEL		},
104		{ "texture_max_level",			"TEXTURE_MAX_LEVEL",		TESTER_TEXTURE_MAX_LEVEL		},
105		{ "texture_compare_mode",		"TEXTURE_COMPARE_MODE",		TESTER_TEXTURE_COMPARE_MODE		},
106		{ "texture_compare_func",		"TEXTURE_COMPARE_FUNC",		TESTER_TEXTURE_COMPARE_FUNC		},
107		{ "texture_immutable_levels",	"TEXTURE_IMMUTABLE_LEVELS",	TESTER_TEXTURE_IMMUTABLE_LEVELS	},
108		{ "texture_immutable_format",	"TEXTURE_IMMUTABLE_FORMAT",	TESTER_TEXTURE_IMMUTABLE_FORMAT	},
109	};
110
111	for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(textureTargets); ++targetNdx)
112	{
113		addChild(createIsTextureTest(m_testCtx,
114									 m_context.getRenderContext(),
115									 std::string() + textureTargets[targetNdx].name + "_is_texture",
116									 "IsTexture",
117									 textureTargets[targetNdx].target));
118
119		for (int stateNdx = 0; stateNdx < DE_LENGTH_OF_ARRAY(states); ++stateNdx)
120		{
121			if (!isLegalTesterForTarget(textureTargets[targetNdx].target, states[stateNdx].tester))
122				continue;
123
124			FOR_EACH_VERIFIER(verifiers, addChild(createTexParamTest(m_testCtx,
125																	 m_context.getRenderContext(),
126																	 std::string() + textureTargets[targetNdx].name	+ "_" + states[stateNdx].name + getVerifierSuffix(verifier),
127																	 states[stateNdx].desc,
128																	 verifier,
129																	 textureTargets[targetNdx].target,
130																	 states[stateNdx].tester)));
131		}
132	}
133}
134
135} // Functional
136} // gles3
137} // deqp
138