1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 2.0 Module
3 * -------------------------------------------------
5 * Copyright 2014 The Android Open Source Project
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * \brief Vertex array and buffer unaligned access stress tests
22 *//*--------------------------------------------------------------------*/
24 #include "es2sVertexArrayTests.hpp"
25 #include "glsVertexArrayTests.hpp"
27 #include "glwEnums.hpp"
29 using namespace deqp::gls;
41 static std::string typeToString (T t)
43 std::stringstream strm;
48 class SingleVertexArrayUsageTests : public TestCaseGroup
51 SingleVertexArrayUsageTests (Context& context);
52 virtual ~SingleVertexArrayUsageTests (void);
54 virtual void init (void);
57 SingleVertexArrayUsageTests (const SingleVertexArrayUsageTests& other);
58 SingleVertexArrayUsageTests& operator= (const SingleVertexArrayUsageTests& other);
61 SingleVertexArrayUsageTests::SingleVertexArrayUsageTests (Context& context)
62 : TestCaseGroup(context, "usages", "Single vertex atribute, usage")
66 SingleVertexArrayUsageTests::~SingleVertexArrayUsageTests (void)
70 void SingleVertexArrayUsageTests::init (void)
73 Array::Usage usages[] = {Array::USAGE_STATIC_DRAW, Array::USAGE_STREAM_DRAW, Array::USAGE_DYNAMIC_DRAW};
74 int counts[] = {1, 256};
76 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_FIXED, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE};
78 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
80 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
82 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
84 for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(usages); usageNdx++)
86 const int componentCount = 2;
87 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]);
88 const bool aligned = (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0;
89 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
90 Array::OUTPUTTYPE_VEC2,
91 Array::STORAGE_BUFFER,
97 GLValue::getMinValue(inputTypes[inputTypeNdx]),
98 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
100 MultiVertexArrayTest::Spec spec;
101 spec.primitive = Array::PRIMITIVE_TRIANGLES;
102 spec.drawCount = counts[countNdx];
104 spec.arrays.push_back(arraySpec);
106 std::string name = spec.getName();
109 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
116 class SingleVertexArrayStrideTests : public TestCaseGroup
119 SingleVertexArrayStrideTests (Context& context);
120 virtual ~SingleVertexArrayStrideTests (void);
122 virtual void init (void);
125 SingleVertexArrayStrideTests (const SingleVertexArrayStrideTests& other);
126 SingleVertexArrayStrideTests& operator= (const SingleVertexArrayStrideTests& other);
129 SingleVertexArrayStrideTests::SingleVertexArrayStrideTests (Context& context)
130 : TestCaseGroup(context, "strides", "Single stride vertex atribute")
134 SingleVertexArrayStrideTests::~SingleVertexArrayStrideTests (void)
138 void SingleVertexArrayStrideTests::init (void)
140 // Test strides with different input types, component counts and storage, Usage(?)
141 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, /*Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE,*/ Array::INPUTTYPE_FIXED};
142 Array::Storage storages[] = {Array::STORAGE_BUFFER};
143 int counts[] = {1, 256};
144 int strides[] = {17};
146 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
148 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
150 for (int componentCount = 2; componentCount < 5; componentCount++)
152 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
154 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
156 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]);
157 const bool bufferUnaligned = (storages[storageNdx] == Array::STORAGE_BUFFER) && (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) != 0;
159 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
160 Array::OUTPUTTYPE_VEC4,
161 storages[storageNdx],
162 Array::USAGE_DYNAMIC_DRAW,
167 GLValue::getMinValue(inputTypes[inputTypeNdx]),
168 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
170 MultiVertexArrayTest::Spec spec;
171 spec.primitive = Array::PRIMITIVE_TRIANGLES;
172 spec.drawCount = counts[countNdx];
174 spec.arrays.push_back(arraySpec);
176 std::string name = spec.getName();
178 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
186 class SingleVertexArrayFirstTests : public TestCaseGroup
189 SingleVertexArrayFirstTests (Context& context);
190 virtual ~SingleVertexArrayFirstTests (void);
192 virtual void init (void);
195 SingleVertexArrayFirstTests (const SingleVertexArrayFirstTests& other);
196 SingleVertexArrayFirstTests& operator= (const SingleVertexArrayFirstTests& other);
199 SingleVertexArrayFirstTests::SingleVertexArrayFirstTests (Context& context)
200 : TestCaseGroup(context, "first", "Single vertex atribute different first values")
204 SingleVertexArrayFirstTests::~SingleVertexArrayFirstTests (void)
208 void SingleVertexArrayFirstTests::init (void)
210 // Test strides with different input types, component counts and storage, Usage(?)
211 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED};
212 int counts[] = {5, 256};
213 int firsts[] = {6, 24};
214 int offsets[] = {1, 17};
215 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
217 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
219 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++)
221 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
223 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
225 for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); firstNdx++)
227 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]);
228 const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && (offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx]) == 0);
230 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
231 Array::OUTPUTTYPE_VEC2,
232 Array::STORAGE_BUFFER,
233 Array::USAGE_DYNAMIC_DRAW,
238 GLValue::getMinValue(inputTypes[inputTypeNdx]),
239 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
241 MultiVertexArrayTest::Spec spec;
242 spec.primitive = Array::PRIMITIVE_TRIANGLES;
243 spec.drawCount = counts[countNdx];
244 spec.first = firsts[firstNdx];
245 spec.arrays.push_back(arraySpec);
247 std::string name = Array::inputTypeToString(inputTypes[inputTypeNdx]) + "_first" + typeToString(firsts[firstNdx]) + "_offset" + typeToString(offsets[offsetNdx]) + "_stride" + typeToString(stride) + "_quads" + typeToString(counts[countNdx]);
249 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
257 class SingleVertexArrayOffsetTests : public TestCaseGroup
260 SingleVertexArrayOffsetTests (Context& context);
261 virtual ~SingleVertexArrayOffsetTests (void);
263 virtual void init (void);
266 SingleVertexArrayOffsetTests (const SingleVertexArrayOffsetTests& other);
267 SingleVertexArrayOffsetTests& operator= (const SingleVertexArrayOffsetTests& other);
270 SingleVertexArrayOffsetTests::SingleVertexArrayOffsetTests (Context& context)
271 : TestCaseGroup(context, "offset", "Single vertex atribute offset element")
275 SingleVertexArrayOffsetTests::~SingleVertexArrayOffsetTests (void)
279 void SingleVertexArrayOffsetTests::init (void)
281 // Test strides with different input types, component counts and storage, Usage(?)
282 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED};
283 int counts[] = {1, 256};
284 int offsets[] = {1, 4, 17, 32};
285 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
287 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
289 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++)
291 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
293 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
295 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]);
296 const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && ((offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0);
298 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
299 Array::OUTPUTTYPE_VEC2,
300 Array::STORAGE_BUFFER,
301 Array::USAGE_DYNAMIC_DRAW,
306 GLValue::getMinValue(inputTypes[inputTypeNdx]),
307 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
309 MultiVertexArrayTest::Spec spec;
310 spec.primitive = Array::PRIMITIVE_TRIANGLES;
311 spec.drawCount = counts[countNdx];
313 spec.arrays.push_back(arraySpec);
315 std::string name = spec.getName();
317 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
326 VertexArrayTests::VertexArrayTests (Context& context)
327 : TestCaseGroup(context, "vertex_arrays", "Vertex array and array tests")
331 VertexArrayTests::~VertexArrayTests (void)
335 void VertexArrayTests::init (void)
337 tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "single_attribute", "Single attribute");
342 group->addChild(new SingleVertexArrayStrideTests(m_context));
343 group->addChild(new SingleVertexArrayUsageTests(m_context));
344 group->addChild(new SingleVertexArrayOffsetTests(m_context));
345 group->addChild(new SingleVertexArrayFirstTests(m_context));