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