xref: /aosp_15_r20/external/deqp/modules/gles2/functional/es2fAttribLocationTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
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 Attribute location test
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es2fAttribLocationTests.hpp"
25 
26 #include "glsAttributeLocationTests.hpp"
27 
28 #include "deStringUtil.hpp"
29 #include "gluDefs.hpp"
30 #include "gluRenderContext.hpp"
31 #include "glwDefs.hpp"
32 #include "glwEnums.hpp"
33 #include "tcuTestLog.hpp"
34 
35 #include <vector>
36 
37 using namespace deqp::gls::AttributeLocationTestUtil;
38 using std::vector;
39 
40 namespace deqp
41 {
42 namespace gles2
43 {
44 namespace Functional
45 {
46 
createAttributeLocationTests(Context & context)47 TestCaseGroup *createAttributeLocationTests(Context &context)
48 {
49     const AttribType types[] = {AttribType("float", 1, GL_FLOAT),     AttribType("vec2", 1, GL_FLOAT_VEC2),
50                                 AttribType("vec3", 1, GL_FLOAT_VEC3), AttribType("vec4", 1, GL_FLOAT_VEC4),
51 
52                                 AttribType("mat2", 2, GL_FLOAT_MAT2), AttribType("mat3", 3, GL_FLOAT_MAT3),
53                                 AttribType("mat4", 4, GL_FLOAT_MAT4)};
54 
55     TestCaseGroup *const root = new TestCaseGroup(context, "attribute_location", "Attribute location tests");
56 
57     // Basic bind attribute tests
58     {
59         TestCaseGroup *const bindAttributeGroup = new TestCaseGroup(context, "bind", "Basic attribute binding tests.");
60 
61         root->addChild(bindAttributeGroup);
62 
63         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
64         {
65             const AttribType &type = types[typeNdx];
66             bindAttributeGroup->addChild(
67                 new gls::BindAttributeTest(context.getTestContext(), context.getRenderContext(), type));
68         }
69     }
70 
71     // Bind max number of attributes
72     {
73         TestCaseGroup *const bindMaxAttributeGroup =
74             new TestCaseGroup(context, "bind_max_attributes", "Test using maximum attributes with bind.");
75 
76         root->addChild(bindMaxAttributeGroup);
77 
78         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
79         {
80             const AttribType &type = types[typeNdx];
81             bindMaxAttributeGroup->addChild(
82                 new gls::BindMaxAttributesTest(context.getTestContext(), context.getRenderContext(), type));
83         }
84     }
85 
86     // Test aliasing
87     {
88         TestCaseGroup *const aliasingGroup =
89             new TestCaseGroup(context, "bind_aliasing", "Test attribute location aliasing with bind.");
90 
91         root->addChild(aliasingGroup);
92 
93         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
94         {
95             const AttribType &type = types[typeNdx];
96 
97             // Simple aliasing cases
98             aliasingGroup->addChild(
99                 new gls::BindAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
100 
101             // For types which occupy more than one location. Alias second location.
102             if (type.getLocationSize() > 1)
103                 aliasingGroup->addChild(
104                     new gls::BindAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type, 1));
105 
106             // Use more than maximum attributes with conditional aliasing
107             aliasingGroup->addChild(
108                 new gls::BindMaxAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
109 
110             // Use more than maximum attributes with inactive attributes
111             aliasingGroup->addChild(
112                 new gls::BindInactiveAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
113         }
114     }
115 
116     // Test filling holes in attribute location
117     {
118         TestCaseGroup *const holeGroup = new TestCaseGroup(
119             context, "bind_hole", "Bind all, but one attribute and leave hole in location space for it.");
120 
121         root->addChild(holeGroup);
122 
123         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
124         {
125             const AttribType &type = types[typeNdx];
126 
127             // Bind first location, leave hole size of type and fill rest of locations
128             holeGroup->addChild(
129                 new gls::BindHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
130         }
131     }
132 
133     // Test binding at different times
134     {
135         TestCaseGroup *const bindTimeGroup =
136             new TestCaseGroup(context, "bind_time", "Bind time tests. Test binding at different stages.");
137 
138         root->addChild(bindTimeGroup);
139 
140         bindTimeGroup->addChild(
141             new gls::PreAttachBindAttributeTest(context.getTestContext(), context.getRenderContext()));
142         bindTimeGroup->addChild(
143             new gls::PreLinkBindAttributeTest(context.getTestContext(), context.getRenderContext()));
144         bindTimeGroup->addChild(
145             new gls::PostLinkBindAttributeTest(context.getTestContext(), context.getRenderContext()));
146         bindTimeGroup->addChild(new gls::BindRelinkAttributeTest(context.getTestContext(), context.getRenderContext()));
147         bindTimeGroup->addChild(
148             new gls::BindReattachAttributeTest(context.getTestContext(), context.getRenderContext()));
149     }
150 
151     // Test relinking program
152     {
153         TestCaseGroup *const relinkHoleGroup = new TestCaseGroup(
154             context, "bind_relink_hole", "Test relinking with moving hole in attribute location space.");
155 
156         root->addChild(relinkHoleGroup);
157 
158         for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
159         {
160             const AttribType &type = types[typeNdx];
161 
162             relinkHoleGroup->addChild(
163                 new gls::BindRelinkHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
164         }
165     }
166 
167     return root;
168 }
169 
170 } // namespace Functional
171 } // namespace gles2
172 } // namespace deqp
173