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[] =
50 	{
51 		AttribType("float",	1,  GL_FLOAT),
52 		AttribType("vec2",	1,  GL_FLOAT_VEC2),
53 		AttribType("vec3",	1,  GL_FLOAT_VEC3),
54 		AttribType("vec4",	1,  GL_FLOAT_VEC4),
55 
56 		AttribType("mat2",	2,  GL_FLOAT_MAT2),
57 		AttribType("mat3",	3,  GL_FLOAT_MAT3),
58 		AttribType("mat4",	4,  GL_FLOAT_MAT4)
59 	};
60 
61 	TestCaseGroup* const root = new TestCaseGroup (context, "attribute_location", "Attribute location tests");
62 
63 	// Basic bind attribute tests
64 	{
65 		TestCaseGroup* const bindAttributeGroup = new TestCaseGroup(context, "bind", "Basic attribute binding tests.");
66 
67 		root->addChild(bindAttributeGroup);
68 
69 		for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
70 		{
71 			const AttribType& type = types[typeNdx];
72 			bindAttributeGroup->addChild(new gls::BindAttributeTest(context.getTestContext(), context.getRenderContext(), type));
73 		}
74 	}
75 
76 	// Bind max number of attributes
77 	{
78 		TestCaseGroup* const bindMaxAttributeGroup = new TestCaseGroup(context, "bind_max_attributes", "Test using maximum attributes with bind.");
79 
80 		root->addChild(bindMaxAttributeGroup);
81 
82 		for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
83 		{
84 			const AttribType& type = types[typeNdx];
85 			bindMaxAttributeGroup->addChild(new gls::BindMaxAttributesTest(context.getTestContext(), context.getRenderContext(), type));
86 		}
87 	}
88 
89 	// Test aliasing
90 	{
91 		TestCaseGroup* const aliasingGroup = new TestCaseGroup(context, "bind_aliasing", "Test attribute location aliasing with bind.");
92 
93 		root->addChild(aliasingGroup);
94 
95 		for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
96 		{
97 			const AttribType& type = types[typeNdx];
98 
99 			// Simple aliasing cases
100 			aliasingGroup->addChild(new gls::BindAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
101 
102 			// For types which occupy more than one location. Alias second location.
103 			if (type.getLocationSize() > 1)
104 				aliasingGroup->addChild(new gls::BindAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type, 1));
105 
106 			// Use more than maximum attributes with conditional aliasing
107 			aliasingGroup->addChild(new gls::BindMaxAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
108 
109 			// Use more than maximum attributes with inactive attributes
110 			aliasingGroup->addChild(new gls::BindInactiveAliasingAttributeTest(context.getTestContext(), context.getRenderContext(), type));
111 		}
112 	}
113 
114 	// Test filling holes in attribute location
115 	{
116 		TestCaseGroup* const holeGroup = new TestCaseGroup(context, "bind_hole", "Bind all, but one attribute and leave hole in location space for it.");
117 
118 		root->addChild(holeGroup);
119 
120 		for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
121 		{
122 			const AttribType& type = types[typeNdx];
123 
124 			// Bind first location, leave hole size of type and fill rest of locations
125 			holeGroup->addChild(new gls::BindHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
126 		}
127 	}
128 
129 	// Test binding at different times
130 	{
131 		TestCaseGroup* const bindTimeGroup = new TestCaseGroup(context, "bind_time", "Bind time tests. Test binding at different stages.");
132 
133 		root->addChild(bindTimeGroup);
134 
135 		bindTimeGroup->addChild(new gls::PreAttachBindAttributeTest(context.getTestContext(), context.getRenderContext()));
136 		bindTimeGroup->addChild(new gls::PreLinkBindAttributeTest(context.getTestContext(), context.getRenderContext()));
137 		bindTimeGroup->addChild(new gls::PostLinkBindAttributeTest(context.getTestContext(), context.getRenderContext()));
138 		bindTimeGroup->addChild(new gls::BindRelinkAttributeTest(context.getTestContext(), context.getRenderContext()));
139 		bindTimeGroup->addChild(new gls::BindReattachAttributeTest(context.getTestContext(), context.getRenderContext()));
140 	}
141 
142 	// Test relinking program
143 	{
144 		TestCaseGroup* const relinkHoleGroup = new TestCaseGroup(context, "bind_relink_hole", "Test relinking with moving hole in attribute location space.");
145 
146 		root->addChild(relinkHoleGroup);
147 
148 		for (int typeNdx = 0; typeNdx < DE_LENGTH_OF_ARRAY(types); typeNdx++)
149 		{
150 			const AttribType& type = types[typeNdx];
151 
152 			relinkHoleGroup->addChild(new gls::BindRelinkHoleAttributeTest(context.getTestContext(), context.getRenderContext(), type));
153 		}
154 	}
155 
156 	return root;
157 }
158 
159 } // Functional
160 } // gles2
161 } // deqp
162