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 Texture Param State Query tests. 22 *//*--------------------------------------------------------------------*/ 23 24#include "es31fTextureStateQueryTests.hpp" 25#include "glsTextureStateQueryTests.hpp" 26#include "glsStateQueryUtil.hpp" 27#include "glwEnums.hpp" 28 29namespace deqp 30{ 31namespace gles31 32{ 33namespace Functional 34{ 35 36using namespace gls::StateQueryUtil; 37using namespace gls::TextureStateQueryTests; 38 39static const char* getVerifierSuffix (QueryType type) 40{ 41 switch (type) 42 { 43 case QUERY_TEXTURE_PARAM_FLOAT: 44 case QUERY_TEXTURE_PARAM_FLOAT_VEC4: return "_float"; 45 46 case QUERY_TEXTURE_PARAM_INTEGER: 47 case QUERY_TEXTURE_PARAM_INTEGER_VEC4: return "_integer"; 48 49 case QUERY_TEXTURE_PARAM_PURE_INTEGER: 50 case QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4: return "_pure_int"; 51 52 case QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER: 53 case QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4: return "_pure_uint"; 54 55 default: 56 DE_ASSERT(DE_FALSE); 57 return DE_NULL; 58 } 59} 60 61static bool isIsVectorQuery (TesterType tester) 62{ 63 return tester == TESTER_TEXTURE_BORDER_COLOR; 64} 65 66static 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 73TextureStateQueryTests::TextureStateQueryTests (Context& context) 74 : TestCaseGroup(context, "texture", "Texture State Query tests") 75{ 76} 77 78TextureStateQueryTests::~TextureStateQueryTests (void) 79{ 80} 81 82void TextureStateQueryTests::init (void) 83{ 84 static const QueryType scalarVerifiers[] = 85 { 86 QUERY_TEXTURE_PARAM_INTEGER, 87 QUERY_TEXTURE_PARAM_FLOAT, 88 QUERY_TEXTURE_PARAM_PURE_INTEGER, 89 QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER, 90 }; 91 static const QueryType nonPureVerifiers[] = 92 { 93 QUERY_TEXTURE_PARAM_INTEGER, 94 QUERY_TEXTURE_PARAM_FLOAT, 95 }; 96 static const QueryType vec4Verifiers[] = 97 { 98 QUERY_TEXTURE_PARAM_INTEGER_VEC4, 99 QUERY_TEXTURE_PARAM_FLOAT_VEC4, 100 QUERY_TEXTURE_PARAM_PURE_INTEGER_VEC4, 101 QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER_VEC4, 102 }; 103 104#define FOR_EACH_VERIFIER(VERIFIERS, X) \ 105 for (int verifierNdx = 0; verifierNdx < DE_LENGTH_OF_ARRAY(VERIFIERS); ++verifierNdx) \ 106 { \ 107 const char* verifierSuffix = getVerifierSuffix(VERIFIERS[verifierNdx]); \ 108 const QueryType verifier = VERIFIERS[verifierNdx]; \ 109 targetGroup->addChild(X); \ 110 } 111 112 static const struct 113 { 114 const char* name; 115 glw::GLenum target; 116 bool newInGLES31; 117 } textureTargets[] = 118 { 119 { "texture_2d", GL_TEXTURE_2D, false, }, 120 { "texture_3d", GL_TEXTURE_3D, false, }, 121 { "texture_2d_array", GL_TEXTURE_2D_ARRAY, false, }, 122 { "texture_cube_map", GL_TEXTURE_CUBE_MAP, false, }, 123 { "texture_2d_multisample", GL_TEXTURE_2D_MULTISAMPLE, true, }, 124 { "texture_2d_multisample_array", GL_TEXTURE_2D_MULTISAMPLE_ARRAY, true, }, // GL_OES_texture_storage_multisample_2d_array 125 { "texture_buffer", GL_TEXTURE_BUFFER, true, }, // GL_EXT_texture_buffer 126 { "texture_cube_array", GL_TEXTURE_CUBE_MAP_ARRAY, true, }, // GL_EXT_texture_cube_map_array 127 }; 128 static const struct 129 { 130 const char* name; 131 const char* desc; 132 TesterType tester; 133 bool newInGLES31; 134 } states[] = 135 { 136 { "texture_swizzle_r", "TEXTURE_SWIZZLE_R", TESTER_TEXTURE_SWIZZLE_R, false }, 137 { "texture_swizzle_g", "TEXTURE_SWIZZLE_G", TESTER_TEXTURE_SWIZZLE_G, false }, 138 { "texture_swizzle_b", "TEXTURE_SWIZZLE_B", TESTER_TEXTURE_SWIZZLE_B, false }, 139 { "texture_swizzle_a", "TEXTURE_SWIZZLE_A", TESTER_TEXTURE_SWIZZLE_A, false }, 140 { "texture_wrap_s", "TEXTURE_WRAP_S", TESTER_TEXTURE_WRAP_S, false }, 141 { "texture_wrap_t", "TEXTURE_WRAP_T", TESTER_TEXTURE_WRAP_T, false }, 142 { "texture_wrap_r", "TEXTURE_WRAP_R", TESTER_TEXTURE_WRAP_R, false }, 143 { "texture_mag_filter", "TEXTURE_MAG_FILTER", TESTER_TEXTURE_MAG_FILTER, false }, 144 { "texture_min_filter", "TEXTURE_MIN_FILTER", TESTER_TEXTURE_MIN_FILTER, false }, 145 { "texture_min_lod", "TEXTURE_MIN_LOD", TESTER_TEXTURE_MIN_LOD, false }, 146 { "texture_max_lod", "TEXTURE_MAX_LOD", TESTER_TEXTURE_MAX_LOD, false }, 147 { "texture_base_level", "TEXTURE_BASE_LEVEL", TESTER_TEXTURE_BASE_LEVEL, false }, 148 { "texture_max_level", "TEXTURE_MAX_LEVEL", TESTER_TEXTURE_MAX_LEVEL, false }, 149 { "texture_compare_mode", "TEXTURE_COMPARE_MODE", TESTER_TEXTURE_COMPARE_MODE, false }, 150 { "texture_compare_func", "TEXTURE_COMPARE_FUNC", TESTER_TEXTURE_COMPARE_FUNC, false }, 151 { "texture_immutable_levels", "TEXTURE_IMMUTABLE_LEVELS", TESTER_TEXTURE_IMMUTABLE_LEVELS, false }, 152 { "texture_immutable_format", "TEXTURE_IMMUTABLE_FORMAT", TESTER_TEXTURE_IMMUTABLE_FORMAT, false }, 153 { "depth_stencil_mode", "DEPTH_STENCIL_TEXTURE_MODE", TESTER_DEPTH_STENCIL_TEXTURE_MODE, true }, 154 { "texture_srgb_decode", "TEXTURE_SRGB_DECODE_EXT", TESTER_TEXTURE_SRGB_DECODE_EXT, true }, 155 { "texture_border_color", "TEXTURE_BORDER_COLOR", TESTER_TEXTURE_BORDER_COLOR, true }, 156 { "texture_wrap_s_clamp_to_border", "TEXTURE_WRAP_S_CLAMP_TO_BORDER", TESTER_TEXTURE_WRAP_S_CLAMP_TO_BORDER, true }, 157 { "texture_wrap_t_clamp_to_border", "TEXTURE_WRAP_T_CLAMP_TO_BORDER", TESTER_TEXTURE_WRAP_T_CLAMP_TO_BORDER, true }, 158 { "texture_wrap_r_clamp_to_border", "TEXTURE_WRAP_R_CLAMP_TO_BORDER", TESTER_TEXTURE_WRAP_R_CLAMP_TO_BORDER, true }, 159 }; 160 static const struct 161 { 162 const char* name; 163 const char* desc; 164 QueryType verifier; 165 } pureSetters[] = 166 { 167 { "set_pure_int", "Set state with pure int", QUERY_TEXTURE_PARAM_PURE_INTEGER }, 168 { "set_pure_uint", "Set state with pure unsigned int", QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER }, 169 }; 170 static const struct 171 { 172 const char* name; 173 const char* desc; 174 TesterType intTester; 175 TesterType uintTester; 176 } pureStates[] = 177 { 178 { "texture_swizzle_r", "TEXTURE_SWIZZLE_R", TESTER_TEXTURE_SWIZZLE_R_SET_PURE_INT, TESTER_TEXTURE_SWIZZLE_R_SET_PURE_UINT }, 179 { "texture_swizzle_g", "TEXTURE_SWIZZLE_G", TESTER_TEXTURE_SWIZZLE_G_SET_PURE_INT, TESTER_TEXTURE_SWIZZLE_G_SET_PURE_UINT }, 180 { "texture_swizzle_b", "TEXTURE_SWIZZLE_B", TESTER_TEXTURE_SWIZZLE_B_SET_PURE_INT, TESTER_TEXTURE_SWIZZLE_B_SET_PURE_UINT }, 181 { "texture_swizzle_a", "TEXTURE_SWIZZLE_A", TESTER_TEXTURE_SWIZZLE_A_SET_PURE_INT, TESTER_TEXTURE_SWIZZLE_A_SET_PURE_UINT }, 182 { "texture_wrap_s", "TEXTURE_WRAP_S", TESTER_TEXTURE_WRAP_S_SET_PURE_INT, TESTER_TEXTURE_WRAP_S_SET_PURE_UINT }, 183 { "texture_wrap_t", "TEXTURE_WRAP_T", TESTER_TEXTURE_WRAP_T_SET_PURE_INT, TESTER_TEXTURE_WRAP_T_SET_PURE_UINT }, 184 { "texture_wrap_r", "TEXTURE_WRAP_R", TESTER_TEXTURE_WRAP_R_SET_PURE_INT, TESTER_TEXTURE_WRAP_R_SET_PURE_UINT }, 185 { "texture_mag_filter", "TEXTURE_MAG_FILTER", TESTER_TEXTURE_MAG_FILTER_SET_PURE_INT, TESTER_TEXTURE_MAG_FILTER_SET_PURE_UINT }, 186 { "texture_min_filter", "TEXTURE_MIN_FILTER", TESTER_TEXTURE_MIN_FILTER_SET_PURE_INT, TESTER_TEXTURE_MIN_FILTER_SET_PURE_UINT }, 187 { "texture_min_lod", "TEXTURE_MIN_LOD", TESTER_TEXTURE_MIN_LOD_SET_PURE_INT, TESTER_TEXTURE_MIN_LOD_SET_PURE_UINT }, 188 { "texture_max_lod", "TEXTURE_MAX_LOD", TESTER_TEXTURE_MAX_LOD_SET_PURE_INT, TESTER_TEXTURE_MAX_LOD_SET_PURE_UINT }, 189 { "texture_base_level", "TEXTURE_BASE_LEVEL", TESTER_TEXTURE_BASE_LEVEL_SET_PURE_INT, TESTER_TEXTURE_BASE_LEVEL_SET_PURE_UINT }, 190 { "texture_max_level", "TEXTURE_MAX_LEVEL", TESTER_TEXTURE_MAX_LEVEL_SET_PURE_INT, TESTER_TEXTURE_MAX_LEVEL_SET_PURE_UINT }, 191 { "texture_compare_mode", "TEXTURE_COMPARE_MODE", TESTER_TEXTURE_COMPARE_MODE_SET_PURE_INT, TESTER_TEXTURE_COMPARE_MODE_SET_PURE_UINT }, 192 { "texture_compare_func", "TEXTURE_COMPARE_FUNC", TESTER_TEXTURE_COMPARE_FUNC_SET_PURE_INT, TESTER_TEXTURE_COMPARE_FUNC_SET_PURE_UINT }, 193 // \note texture_immutable_levels is not settable 194 // \note texture_immutable_format is not settable 195 { "depth_stencil_mode", "DEPTH_STENCIL_TEXTURE_MODE", TESTER_DEPTH_STENCIL_TEXTURE_MODE_SET_PURE_INT, TESTER_DEPTH_STENCIL_TEXTURE_MODE_SET_PURE_UINT }, 196 { "texture_srgb_decode", "TEXTURE_SRGB_DECODE_EXT", TESTER_TEXTURE_SRGB_DECODE_EXT_SET_PURE_INT, TESTER_TEXTURE_SRGB_DECODE_EXT_SET_PURE_UINT }, 197 // \note texture_border_color is already checked 198 // \note texture_wrap_*_clamp_to_border brings no additional coverage 199 }; 200 201 for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(textureTargets); ++targetNdx) 202 { 203 tcu::TestCaseGroup* const targetGroup = new tcu::TestCaseGroup(m_testCtx, textureTargets[targetNdx].name, textureTargets[targetNdx].name); 204 addChild(targetGroup); 205 206 if (textureTargets[targetNdx].newInGLES31) 207 { 208 targetGroup->addChild(createIsTextureTest(m_testCtx, 209 m_context.getRenderContext(), 210 "is_texture", 211 "IsTexture", 212 textureTargets[targetNdx].target)); 213 } 214 215 for (int stateNdx = 0; stateNdx < DE_LENGTH_OF_ARRAY(states); ++stateNdx) 216 { 217 if (!isLegalTesterForTarget(textureTargets[targetNdx].target, states[stateNdx].tester)) 218 continue; 219 220 // for old targets, check only new states 221 if (!textureTargets[targetNdx].newInGLES31 && !states[stateNdx].newInGLES31) 222 continue; 223 224 if (isExtendedParamQuery(states[stateNdx].tester)) 225 { 226 // no need to cover for all getters if the only thing new is the param name 227 FOR_EACH_VERIFIER(nonPureVerifiers, createTexParamTest(m_testCtx, 228 m_context.getRenderContext(), 229 std::string() + states[stateNdx].name + verifierSuffix, 230 states[stateNdx].desc, 231 verifier, 232 textureTargets[targetNdx].target, 233 states[stateNdx].tester)); 234 } 235 else if (isIsVectorQuery(states[stateNdx].tester)) 236 { 237 FOR_EACH_VERIFIER(vec4Verifiers, createTexParamTest(m_testCtx, 238 m_context.getRenderContext(), 239 std::string() + states[stateNdx].name + verifierSuffix, 240 states[stateNdx].desc, 241 verifier, 242 textureTargets[targetNdx].target, 243 states[stateNdx].tester)); 244 } 245 else 246 { 247 FOR_EACH_VERIFIER(scalarVerifiers, createTexParamTest(m_testCtx, 248 m_context.getRenderContext(), 249 std::string() + states[stateNdx].name + verifierSuffix, 250 states[stateNdx].desc, 251 verifier, 252 textureTargets[targetNdx].target, 253 states[stateNdx].tester)); 254 } 255 } 256 } 257 258#undef FOR_EACH_VERIFIER 259 260 // set_pure_uint 261 // set_pure_int 262 for (int setterNdx = 0; setterNdx < DE_LENGTH_OF_ARRAY(pureSetters); ++setterNdx) 263 { 264 tcu::TestCaseGroup* const targetGroup = new tcu::TestCaseGroup(m_testCtx, pureSetters[setterNdx].name, pureSetters[setterNdx].desc); 265 addChild(targetGroup); 266 267 for (int stateNdx = 0; stateNdx < DE_LENGTH_OF_ARRAY(pureStates); ++stateNdx) 268 { 269 const TesterType tester = (pureSetters[setterNdx].verifier == QUERY_TEXTURE_PARAM_PURE_INTEGER) ? (pureStates[stateNdx].intTester) 270 : (pureSetters[setterNdx].verifier == QUERY_TEXTURE_PARAM_PURE_UNSIGNED_INTEGER) ? (pureStates[stateNdx].uintTester) 271 : (TESTER_LAST); 272 // need 3d texture to test R wrap 273 const glw::GLenum target = (pureStates[stateNdx].intTester == TESTER_TEXTURE_WRAP_R_SET_PURE_INT) ? (GL_TEXTURE_3D) : (GL_TEXTURE_2D); 274 275 targetGroup->addChild(createTexParamTest(m_testCtx, 276 m_context.getRenderContext(), 277 std::string() + pureStates[stateNdx].name, 278 pureStates[stateNdx].desc, 279 pureSetters[setterNdx].verifier, 280 target, 281 tester)); 282 } 283 } 284} 285 286} // Functional 287} // gles31 288} // deqp 289