• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.1 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2015 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 Sampler object state query tests
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es31fSamplerStateQueryTests.hpp"
25 #include "glsTextureStateQueryTests.hpp"
26 #include "glsStateQueryUtil.hpp"
27 #include "glwEnums.hpp"
28 
29 namespace deqp
30 {
31 namespace gles31
32 {
33 namespace Functional
34 {
35 
36 using namespace gls::StateQueryUtil;
37 using namespace gls::TextureStateQueryTests;
38 
getVerifierSuffix(QueryType type)39 static const char* getVerifierSuffix (QueryType type)
40 {
41 	switch (type)
42 	{
43 		case QUERY_SAMPLER_PARAM_FLOAT:
44 		case QUERY_SAMPLER_PARAM_FLOAT_VEC4:					return "_float";
45 
46 		case QUERY_SAMPLER_PARAM_INTEGER:
47 		case QUERY_SAMPLER_PARAM_INTEGER_VEC4:					return "_integer";
48 
49 		case QUERY_SAMPLER_PARAM_PURE_INTEGER:
50 		case QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4:				return "_pure_int";
51 
52 		case QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER:
53 		case QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4:	return "_pure_uint";
54 
55 		default:
56 			DE_ASSERT(DE_FALSE);
57 			return DE_NULL;
58 	}
59 }
60 
isIsVectorQuery(TesterType tester)61 static bool isIsVectorQuery (TesterType tester)
62 {
63 	return tester == TESTER_TEXTURE_BORDER_COLOR;
64 }
65 
isExtendedParamQuery(TesterType tester)66 static bool isExtendedParamQuery (TesterType tester)
67 {
68 	return	tester == TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER ||
69 			tester == TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER ||
70 			tester == TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER;
71 }
72 
SamplerStateQueryTests(Context & context)73 SamplerStateQueryTests::SamplerStateQueryTests (Context& context)
74 	: TestCaseGroup(context, "sampler", "Sampler state query tests")
75 {
76 }
77 
init(void)78 void SamplerStateQueryTests::init (void)
79 {
80 	using namespace gls::TextureStateQueryTests;
81 
82 	static const QueryType scalarVerifiers[] =
83 	{
84 		QUERY_SAMPLER_PARAM_INTEGER,
85 		QUERY_SAMPLER_PARAM_FLOAT,
86 		QUERY_SAMPLER_PARAM_PURE_INTEGER,
87 		QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER,
88 	};
89 	static const QueryType nonPureVerifiers[] =
90 	{
91 		QUERY_SAMPLER_PARAM_INTEGER,
92 		QUERY_SAMPLER_PARAM_FLOAT,
93 	};
94 	static const QueryType vectorVerifiers[] =
95 	{
96 		QUERY_SAMPLER_PARAM_INTEGER_VEC4,
97 		QUERY_SAMPLER_PARAM_FLOAT_VEC4,
98 		QUERY_SAMPLER_PARAM_PURE_INTEGER_VEC4,
99 		QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER_VEC4,
100 	};
101 
102 #define FOR_EACH_VERIFIER(VERIFIERS, X) \
103 	for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); ++verifierNdx)	\
104 	{																						\
105 		const char* verifierSuffix = getVerifierSuffix((VERIFIERS)[verifierNdx]);			\
106 		const QueryType verifier = (VERIFIERS)[verifierNdx];								\
107 		targetGroup->addChild(X);															\
108 	}
109 
110 	static const struct
111 	{
112 		const char*	name;
113 		const char*	desc;
114 		TesterType	tester;
115 		bool		newInGLES31;
116 	} states[] =
117 	{
118 		{ "texture_wrap_s",					"TEXTURE_WRAP_S",					TESTER_TEXTURE_WRAP_S,					false	},
119 		{ "texture_wrap_t",					"TEXTURE_WRAP_T",					TESTER_TEXTURE_WRAP_T,					false	},
120 		{ "texture_wrap_r",					"TEXTURE_WRAP_R",					TESTER_TEXTURE_WRAP_R,					false	},
121 		{ "texture_mag_filter",				"TEXTURE_MAG_FILTER",				TESTER_TEXTURE_MAG_FILTER,				false	},
122 		{ "texture_min_filter",				"TEXTURE_MIN_FILTER",				TESTER_TEXTURE_MIN_FILTER,				false	},
123 		{ "texture_min_lod",				"TEXTURE_MIN_LOD",					TESTER_TEXTURE_MIN_LOD,					false	},
124 		{ "texture_max_lod",				"TEXTURE_MAX_LOD",					TESTER_TEXTURE_MAX_LOD,					false	},
125 		{ "texture_compare_mode",			"TEXTURE_COMPARE_MODE",				TESTER_TEXTURE_COMPARE_MODE,			false	},
126 		{ "texture_compare_func",			"TEXTURE_COMPARE_FUNC",				TESTER_TEXTURE_COMPARE_FUNC,			false	},
127 		{ "texture_srgb_decode",			"TEXTURE_SRGB_DECODE_EXT",			TESTER_TEXTURE_SRGB_DECODE_EXT,			true	},
128 		{ "texture_border_color",			"TEXTURE_BORDER_COLOR",				TESTER_TEXTURE_BORDER_COLOR,			true	},
129 		{ "texture_wrap_s_clamp_to_border",	"TEXTURE_WRAP_S_CLAMP_TO_BORDER",	TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER,	true	},
130 		{ "texture_wrap_t_clamp_to_border",	"TEXTURE_WRAP_T_CLAMP_TO_BORDER",	TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER,	true	},
131 		{ "texture_wrap_r_clamp_to_border",	"TEXTURE_WRAP_R_CLAMP_TO_BORDER",	TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER,	true	},
132 	};
133 	static const struct
134 	{
135 		const char* name;
136 		const char* desc;
137 		QueryType	verifier;
138 	} pureSetters[] =
139 	{
140 		{ "set_pure_int",	"Set state with pure int",			QUERY_SAMPLER_PARAM_PURE_INTEGER			},
141 		{ "set_pure_uint",	"Set state with pure unsigned int",	QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER	},
142 	};
143 	static const struct
144 	{
145 		const char*	name;
146 		const char*	desc;
147 		TesterType	intTester;
148 		TesterType	uintTester;
149 	} pureStates[] =
150 	{
151 		{ "texture_wrap_s",					"TEXTURE_WRAP_S",					TESTER_TEXTURE_WRAP_S_SET_PURE_INT,				TESTER_TEXTURE_WRAP_S_SET_PURE_UINT					},
152 		{ "texture_wrap_t",					"TEXTURE_WRAP_T",					TESTER_TEXTURE_WRAP_T_SET_PURE_INT,				TESTER_TEXTURE_WRAP_T_SET_PURE_UINT					},
153 		{ "texture_wrap_r",					"TEXTURE_WRAP_R",					TESTER_TEXTURE_WRAP_R_SET_PURE_INT,				TESTER_TEXTURE_WRAP_R_SET_PURE_UINT					},
154 		{ "texture_mag_filter",				"TEXTURE_MAG_FILTER",				TESTER_TEXTURE_MAG_FILTER_SET_PURE_INT,			TESTER_TEXTURE_MAG_FILTER_SET_PURE_UINT				},
155 		{ "texture_min_filter",				"TEXTURE_MIN_FILTER",				TESTER_TEXTURE_MIN_FILTER_SET_PURE_INT,			TESTER_TEXTURE_MIN_FILTER_SET_PURE_UINT				},
156 		{ "texture_min_lod",				"TEXTURE_MIN_LOD",					TESTER_TEXTURE_MIN_LOD_SET_PURE_INT,			TESTER_TEXTURE_MIN_LOD_SET_PURE_UINT				},
157 		{ "texture_max_lod",				"TEXTURE_MAX_LOD",					TESTER_TEXTURE_MAX_LOD_SET_PURE_INT,			TESTER_TEXTURE_MAX_LOD_SET_PURE_UINT				},
158 		{ "texture_compare_mode",			"TEXTURE_COMPARE_MODE",				TESTER_TEXTURE_COMPARE_MODE_SET_PURE_INT,		TESTER_TEXTURE_COMPARE_MODE_SET_PURE_UINT			},
159 		{ "texture_compare_func",			"TEXTURE_COMPARE_FUNC",				TESTER_TEXTURE_COMPARE_FUNC_SET_PURE_INT,		TESTER_TEXTURE_COMPARE_FUNC_SET_PURE_UINT			},
160 		{ "texture_srgb_decode",			"TEXTURE_SRGB_DECODE_EXT",			TESTER_TEXTURE_SRGB_DECODE_EXT_SET_PURE_INT,	TESTER_TEXTURE_SRGB_DECODE_EXT_SET_PURE_UINT		},
161 		// \note texture_border_color is already checked
162 		// \note texture_wrap_*_clamp_to_border brings no additional coverage
163 	};
164 
165 	// set_value
166 	{
167 		tcu::TestCaseGroup* const targetGroup = new tcu::TestCaseGroup(m_testCtx, "set_value", "Set value and query it");
168 		addChild(targetGroup);
169 
170 		for (int stateNdx = 0; stateNdx < DE_LENGTH_OF_ARRAY(states); ++stateNdx)
171 		{
172 			// already tested in gles3
173 			if (!states[stateNdx].newInGLES31)
174 				continue;
175 
176 			if (isExtendedParamQuery(states[stateNdx].tester))
177 			{
178 				// no need to cover for all getters if the only thing new is the param name
179 				FOR_EACH_VERIFIER(nonPureVerifiers, createSamplerParamTest(m_testCtx,
180 																		   m_context.getRenderContext(),
181 																		   std::string() + states[stateNdx].name + verifierSuffix,
182 																		   states[stateNdx].desc,
183 																		   verifier,
184 																		   states[stateNdx].tester));
185 			}
186 			else if (isIsVectorQuery(states[stateNdx].tester))
187 			{
188 				FOR_EACH_VERIFIER(vectorVerifiers, createSamplerParamTest(m_testCtx,
189 																		  m_context.getRenderContext(),
190 																		  std::string() + states[stateNdx].name + verifierSuffix,
191 																		  states[stateNdx].desc,
192 																		  verifier,
193 																		  states[stateNdx].tester));
194 			}
195 			else
196 			{
197 				FOR_EACH_VERIFIER(scalarVerifiers, createSamplerParamTest(m_testCtx,
198 																		  m_context.getRenderContext(),
199 																		  std::string() + states[stateNdx].name + verifierSuffix,
200 																		  states[stateNdx].desc,
201 																		  verifier,
202 																		  states[stateNdx].tester));
203 			}
204 		}
205 	}
206 
207 #undef FOR_EACH_VERIFIER
208 
209 	// set_pure_uint
210 	// set_pure_int
211 	for (int setterNdx = 0; setterNdx < DE_LENGTH_OF_ARRAY(pureSetters); ++setterNdx)
212 	{
213 		tcu::TestCaseGroup* const targetGroup = new tcu::TestCaseGroup(m_testCtx, pureSetters[setterNdx].name, pureSetters[setterNdx].desc);
214 		addChild(targetGroup);
215 
216 		for (int stateNdx = 0; stateNdx < DE_LENGTH_OF_ARRAY(pureStates); ++stateNdx)
217 		{
218 			const TesterType	tester	= (pureSetters[setterNdx].verifier == QUERY_SAMPLER_PARAM_PURE_INTEGER)				? (pureStates[stateNdx].intTester)
219 										: (pureSetters[setterNdx].verifier == QUERY_SAMPLER_PARAM_PURE_UNSIGNED_INTEGER)	? (pureStates[stateNdx].uintTester)
220 										: (TESTER_LAST);
221 
222 			targetGroup->addChild(createSamplerParamTest(m_testCtx,
223 														 m_context.getRenderContext(),
224 														 std::string() + pureStates[stateNdx].name,
225 														 pureStates[stateNdx].desc,
226 														 pureSetters[setterNdx].verifier,
227 														 tester));
228 		}
229 	}
230 }
231 
232 } // Functional
233 } // gles31
234 } // deqp
235