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 tests
22 *//*--------------------------------------------------------------------*/
24 #include "es2fVertexArrayTest.hpp"
25 #include "glsVertexArrayTests.hpp"
27 #include "glwEnums.hpp"
29 using namespace deqp::gls;
39 static std::string typeToString (T t)
41 std::stringstream strm;
47 class SingleVertexArrayUsageTests : public TestCaseGroup
50 SingleVertexArrayUsageTests (Context& context);
51 virtual ~SingleVertexArrayUsageTests (void);
53 virtual void init (void);
56 SingleVertexArrayUsageTests (const SingleVertexArrayUsageTests& other);
57 SingleVertexArrayUsageTests& operator= (const SingleVertexArrayUsageTests& other);
60 SingleVertexArrayUsageTests::SingleVertexArrayUsageTests (Context& context)
61 : TestCaseGroup(context, "usages", "Single vertex atribute, usage")
65 SingleVertexArrayUsageTests::~SingleVertexArrayUsageTests (void)
69 void SingleVertexArrayUsageTests::init (void)
72 Array::Usage usages[] = {Array::USAGE_STATIC_DRAW, Array::USAGE_STREAM_DRAW, Array::USAGE_DYNAMIC_DRAW};
73 int counts[] = {1, 256};
74 int strides[] = {0, -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
75 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_FIXED, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE};
77 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
79 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
81 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
83 for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(usages); usageNdx++)
85 const int componentCount = 2;
86 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]);
87 const bool aligned = (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0;
88 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
89 Array::OUTPUTTYPE_VEC2,
90 Array::STORAGE_BUFFER,
96 GLValue::getMinValue(inputTypes[inputTypeNdx]),
97 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
99 MultiVertexArrayTest::Spec spec;
100 spec.primitive = Array::PRIMITIVE_TRIANGLES;
101 spec.drawCount = counts[countNdx];
103 spec.arrays.push_back(arraySpec);
105 std::string name = spec.getName();
108 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
115 class SingleVertexArrayStrideTests : public TestCaseGroup
118 SingleVertexArrayStrideTests (Context& context);
119 virtual ~SingleVertexArrayStrideTests (void);
121 virtual void init (void);
124 SingleVertexArrayStrideTests (const SingleVertexArrayStrideTests& other);
125 SingleVertexArrayStrideTests& operator= (const SingleVertexArrayStrideTests& other);
128 SingleVertexArrayStrideTests::SingleVertexArrayStrideTests (Context& context)
129 : TestCaseGroup(context, "strides", "Single stride vertex atribute")
133 SingleVertexArrayStrideTests::~SingleVertexArrayStrideTests (void)
137 void SingleVertexArrayStrideTests::init (void)
139 // Test strides with different input types, component counts and storage, Usage(?)
140 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, /*Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE,*/ Array::INPUTTYPE_FIXED};
141 Array::Storage storages[] = {Array::STORAGE_USER, Array::STORAGE_BUFFER};
142 int counts[] = {1, 256};
143 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
145 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
147 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
149 for (int componentCount = 2; componentCount < 5; componentCount++)
151 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
153 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
155 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]);
156 const bool bufferAligned = (storages[storageNdx] == Array::STORAGE_BUFFER) && (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0;
158 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
159 Array::OUTPUTTYPE_VEC4,
160 storages[storageNdx],
161 Array::USAGE_DYNAMIC_DRAW,
166 GLValue::getMinValue(inputTypes[inputTypeNdx]),
167 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
169 MultiVertexArrayTest::Spec spec;
170 spec.primitive = Array::PRIMITIVE_TRIANGLES;
171 spec.drawCount = counts[countNdx];
173 spec.arrays.push_back(arraySpec);
175 std::string name = spec.getName();
177 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
185 class SingleVertexArrayFirstTests : public TestCaseGroup
188 SingleVertexArrayFirstTests (Context& context);
189 virtual ~SingleVertexArrayFirstTests (void);
191 virtual void init (void);
194 SingleVertexArrayFirstTests (const SingleVertexArrayFirstTests& other);
195 SingleVertexArrayFirstTests& operator= (const SingleVertexArrayFirstTests& other);
198 SingleVertexArrayFirstTests::SingleVertexArrayFirstTests (Context& context)
199 : TestCaseGroup(context, "first", "Single vertex atribute different first values")
203 SingleVertexArrayFirstTests::~SingleVertexArrayFirstTests (void)
207 void SingleVertexArrayFirstTests::init (void)
209 // Test strides with different input types, component counts and storage, Usage(?)
210 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED};
211 int counts[] = {5, 256};
212 int firsts[] = {6, 24};
213 int offsets[] = {1, 16, 17};
214 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
216 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
218 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++)
220 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
222 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
224 for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); firstNdx++)
226 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]);
227 const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && (offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx]) == 0);
229 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
230 Array::OUTPUTTYPE_VEC2,
231 Array::STORAGE_BUFFER,
232 Array::USAGE_DYNAMIC_DRAW,
237 GLValue::getMinValue(inputTypes[inputTypeNdx]),
238 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
240 MultiVertexArrayTest::Spec spec;
241 spec.primitive = Array::PRIMITIVE_TRIANGLES;
242 spec.drawCount = counts[countNdx];
243 spec.first = firsts[firstNdx];
244 spec.arrays.push_back(arraySpec);
246 std::string name = Array::inputTypeToString(inputTypes[inputTypeNdx]) + "_first" + typeToString(firsts[firstNdx]) + "_offset" + typeToString(offsets[offsetNdx]) + "_stride" + typeToString(stride) + "_quads" + typeToString(counts[countNdx]);
248 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
256 class SingleVertexArrayOffsetTests : public TestCaseGroup
259 SingleVertexArrayOffsetTests (Context& context);
260 virtual ~SingleVertexArrayOffsetTests (void);
262 virtual void init (void);
265 SingleVertexArrayOffsetTests (const SingleVertexArrayOffsetTests& other);
266 SingleVertexArrayOffsetTests& operator= (const SingleVertexArrayOffsetTests& other);
269 SingleVertexArrayOffsetTests::SingleVertexArrayOffsetTests (Context& context)
270 : TestCaseGroup(context, "offset", "Single vertex atribute offset element")
274 SingleVertexArrayOffsetTests::~SingleVertexArrayOffsetTests (void)
278 void SingleVertexArrayOffsetTests::init (void)
280 // Test strides with different input types, component counts and storage, Usage(?)
281 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED};
282 int counts[] = {1, 256};
283 int offsets[] = {1, 4, 17, 32};
284 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
286 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
288 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++)
290 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
292 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
294 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]);
295 const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && ((offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0);
297 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
298 Array::OUTPUTTYPE_VEC2,
299 Array::STORAGE_BUFFER,
300 Array::USAGE_DYNAMIC_DRAW,
305 GLValue::getMinValue(inputTypes[inputTypeNdx]),
306 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
308 MultiVertexArrayTest::Spec spec;
309 spec.primitive = Array::PRIMITIVE_TRIANGLES;
310 spec.drawCount = counts[countNdx];
312 spec.arrays.push_back(arraySpec);
314 std::string name = spec.getName();
316 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
323 class SingleVertexArrayNormalizeTests : public TestCaseGroup
326 SingleVertexArrayNormalizeTests (Context& context);
327 virtual ~SingleVertexArrayNormalizeTests (void);
329 virtual void init (void);
332 SingleVertexArrayNormalizeTests (const SingleVertexArrayNormalizeTests& other);
333 SingleVertexArrayNormalizeTests& operator= (const SingleVertexArrayNormalizeTests& other);
336 SingleVertexArrayNormalizeTests::SingleVertexArrayNormalizeTests (Context& context)
337 : TestCaseGroup(context, "normalize", "Single normalize vertex atribute")
341 SingleVertexArrayNormalizeTests::~SingleVertexArrayNormalizeTests (void)
345 void SingleVertexArrayNormalizeTests::init (void)
347 // Test normalization with different input types, component counts and storage
348 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_FIXED};
349 Array::Storage storages[] = {Array::STORAGE_USER};
350 int counts[] = {1, 256};
352 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
354 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
356 for (int componentCount = 2; componentCount < 5; componentCount++)
358 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
360 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
361 Array::OUTPUTTYPE_VEC4,
362 storages[storageNdx],
363 Array::USAGE_DYNAMIC_DRAW,
368 GLValue::getMinValue(inputTypes[inputTypeNdx]),
369 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
371 MultiVertexArrayTest::Spec spec;
372 spec.primitive = Array::PRIMITIVE_TRIANGLES;
373 spec.drawCount = counts[countNdx];
375 spec.arrays.push_back(arraySpec);
377 std::string name = spec.getName();
378 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
385 class SingleVertexArrayOutputTypeTests : public TestCaseGroup
388 SingleVertexArrayOutputTypeTests (Context& context);
389 virtual ~SingleVertexArrayOutputTypeTests (void);
391 virtual void init (void);
394 SingleVertexArrayOutputTypeTests (const SingleVertexArrayOutputTypeTests& other);
395 SingleVertexArrayOutputTypeTests& operator= (const SingleVertexArrayOutputTypeTests& other);
398 SingleVertexArrayOutputTypeTests::SingleVertexArrayOutputTypeTests (Context& context)
399 : TestCaseGroup(context, "output_types", "Single output type vertex atribute")
403 SingleVertexArrayOutputTypeTests::~SingleVertexArrayOutputTypeTests (void)
407 void SingleVertexArrayOutputTypeTests::init (void)
409 // Test output types with different input types, component counts and storage, Usage?, Precision?, float?
410 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_FIXED};
411 Array::OutputType outputTypes[] = {Array::OUTPUTTYPE_VEC2, Array::OUTPUTTYPE_VEC3, Array::OUTPUTTYPE_VEC4};
412 Array::Storage storages[] = {Array::STORAGE_USER};
413 int counts[] = {1, 256};
415 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
417 for (int outputTypeNdx = 0; outputTypeNdx < DE_LENGTH_OF_ARRAY(outputTypes); outputTypeNdx++)
419 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
421 for (int componentCount = 2; componentCount < 5; componentCount++)
423 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
425 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
426 outputTypes[outputTypeNdx],
427 storages[storageNdx],
428 Array::USAGE_DYNAMIC_DRAW,
433 GLValue::getMinValue(inputTypes[inputTypeNdx]),
434 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
436 MultiVertexArrayTest::Spec spec;
437 spec.primitive = Array::PRIMITIVE_TRIANGLES;
438 spec.drawCount = counts[countNdx];
440 spec.arrays.push_back(arraySpec);
442 std::string name = spec.getName();
443 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
451 class SingleVertexArrayTestGroup : public TestCaseGroup
454 SingleVertexArrayTestGroup (Context& context);
455 virtual ~SingleVertexArrayTestGroup (void);
457 virtual void init (void);
460 SingleVertexArrayTestGroup (const SingleVertexArrayTestGroup& other);
461 SingleVertexArrayTestGroup& operator= (const SingleVertexArrayTestGroup& other);
464 SingleVertexArrayTestGroup::SingleVertexArrayTestGroup (Context& context)
465 : TestCaseGroup(context, "single_attribute", "Single vertex atribute")
469 SingleVertexArrayTestGroup::~SingleVertexArrayTestGroup (void)
473 void SingleVertexArrayTestGroup::init (void)
475 addChild(new SingleVertexArrayStrideTests(m_context));
476 addChild(new SingleVertexArrayNormalizeTests(m_context));
477 addChild(new SingleVertexArrayOutputTypeTests(m_context));
478 addChild(new SingleVertexArrayUsageTests(m_context));
479 addChild(new SingleVertexArrayOffsetTests(m_context));
480 addChild(new SingleVertexArrayFirstTests(m_context));
483 class MultiVertexArrayCountTests : public TestCaseGroup
486 MultiVertexArrayCountTests (Context& context);
487 virtual ~MultiVertexArrayCountTests (void);
489 virtual void init (void);
492 MultiVertexArrayCountTests (const MultiVertexArrayCountTests& other);
493 MultiVertexArrayCountTests& operator= (const MultiVertexArrayCountTests& other);
495 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
498 MultiVertexArrayCountTests::MultiVertexArrayCountTests (Context& context)
499 : TestCaseGroup(context, "attribute_count", "Attribute counts")
503 MultiVertexArrayCountTests::~MultiVertexArrayCountTests (void)
507 std::string MultiVertexArrayCountTests::getTestName (const MultiVertexArrayTest::Spec& spec)
509 std::stringstream name;
511 << spec.arrays.size();
516 void MultiVertexArrayCountTests::init (void)
518 // Test attribute counts
519 int arrayCounts[] = {2, 3, 4, 5, 6, 7, 8};
521 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
523 MultiVertexArrayTest::Spec spec;
525 spec.primitive = Array::PRIMITIVE_TRIANGLES;
526 spec.drawCount = 256;
529 for (int arrayNdx = 0; arrayNdx < arrayCounts[arrayCountNdx]; arrayNdx++)
531 MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT,
532 Array::OUTPUTTYPE_VEC2,
534 Array::USAGE_DYNAMIC_DRAW,
539 GLValue::getMinValue(Array::INPUTTYPE_FLOAT),
540 GLValue::getMaxValue(Array::INPUTTYPE_FLOAT));
542 spec.arrays.push_back(arraySpec);
545 std::string name = getTestName(spec);
546 std::string desc = getTestName(spec);
548 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
552 class MultiVertexArrayStorageTests : public TestCaseGroup
555 MultiVertexArrayStorageTests (Context& context);
556 virtual ~MultiVertexArrayStorageTests (void);
558 virtual void init (void);
561 MultiVertexArrayStorageTests (const MultiVertexArrayStorageTests& other);
562 MultiVertexArrayStorageTests& operator= (const MultiVertexArrayStorageTests& other);
564 void addStorageCases (MultiVertexArrayTest::Spec spec, int depth);
565 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
568 MultiVertexArrayStorageTests::MultiVertexArrayStorageTests (Context& context)
569 : TestCaseGroup(context, "storage", "Attribute storages")
573 MultiVertexArrayStorageTests::~MultiVertexArrayStorageTests (void)
577 std::string MultiVertexArrayStorageTests::getTestName (const MultiVertexArrayTest::Spec& spec)
579 std::stringstream name;
581 << spec.arrays.size();
583 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
587 << Array::storageToString(spec.arrays[arrayNdx].storage);
593 void MultiVertexArrayStorageTests::addStorageCases (MultiVertexArrayTest::Spec spec, int depth)
597 // Skip trivial case, used elsewhere
599 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
601 if (spec.arrays[arrayNdx].storage != Array::STORAGE_USER)
611 std::string name = getTestName(spec);
612 std::string desc = getTestName(spec);
614 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
618 Array::Storage storages[] = {Array::STORAGE_USER, Array::STORAGE_BUFFER};
619 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
621 MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT,
622 Array::OUTPUTTYPE_VEC2,
623 storages[storageNdx],
624 Array::USAGE_DYNAMIC_DRAW,
629 GLValue::getMinValue(Array::INPUTTYPE_FLOAT),
630 GLValue::getMaxValue(Array::INPUTTYPE_FLOAT));
632 MultiVertexArrayTest::Spec _spec = spec;
633 _spec.arrays.push_back(arraySpec);
634 addStorageCases(_spec, depth-1);
639 void MultiVertexArrayStorageTests::init (void)
641 // Test different storages
642 int arrayCounts[] = {3};
644 MultiVertexArrayTest::Spec spec;
646 spec.primitive = Array::PRIMITIVE_TRIANGLES;
647 spec.drawCount = 256;
650 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
651 addStorageCases(spec, arrayCounts[arrayCountNdx]);
654 class MultiVertexArrayStrideTests : public TestCaseGroup
657 MultiVertexArrayStrideTests (Context& context);
658 virtual ~MultiVertexArrayStrideTests (void);
660 virtual void init (void);
663 MultiVertexArrayStrideTests (const MultiVertexArrayStrideTests& other);
664 MultiVertexArrayStrideTests& operator= (const MultiVertexArrayStrideTests& other);
666 void addStrideCases (MultiVertexArrayTest::Spec spec, int depth);
667 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
670 MultiVertexArrayStrideTests::MultiVertexArrayStrideTests (Context& context)
671 : TestCaseGroup(context, "stride", "Strides")
675 MultiVertexArrayStrideTests::~MultiVertexArrayStrideTests (void)
679 std::string MultiVertexArrayStrideTests::getTestName (const MultiVertexArrayTest::Spec& spec)
681 std::stringstream name;
684 << spec.arrays.size();
686 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
690 << Array::inputTypeToString(spec.arrays[arrayNdx].inputType)
691 << spec.arrays[arrayNdx].componentCount << "_"
692 << spec.arrays[arrayNdx].stride;
698 void MultiVertexArrayStrideTests::init (void)
700 // Test different strides, with multiple arrays, input types??
701 int arrayCounts[] = {3};
703 MultiVertexArrayTest::Spec spec;
705 spec.primitive = Array::PRIMITIVE_TRIANGLES;
706 spec.drawCount = 256;
709 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
710 addStrideCases(spec, arrayCounts[arrayCountNdx]);
713 void MultiVertexArrayStrideTests::addStrideCases (MultiVertexArrayTest::Spec spec, int depth)
717 std::string name = getTestName(spec);
718 std::string desc = getTestName(spec);
719 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
723 int strides[] = {0, -1, 17, 32};
725 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
727 const int componentCount = 2;
728 MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT,
729 Array::OUTPUTTYPE_VEC2,
731 Array::USAGE_DYNAMIC_DRAW,
734 (strides[strideNdx] >= 0 ? strides[strideNdx] : componentCount * Array::inputTypeSize(Array::INPUTTYPE_FLOAT)),
736 GLValue::getMinValue(Array::INPUTTYPE_FLOAT),
737 GLValue::getMaxValue(Array::INPUTTYPE_FLOAT));
739 MultiVertexArrayTest::Spec _spec = spec;
740 _spec.arrays.push_back(arraySpec);
741 addStrideCases(_spec, depth-1);
745 class MultiVertexArrayOutputTests : public TestCaseGroup
748 MultiVertexArrayOutputTests (Context& context);
749 virtual ~MultiVertexArrayOutputTests (void);
751 virtual void init (void);
754 MultiVertexArrayOutputTests (const MultiVertexArrayOutputTests& other);
755 MultiVertexArrayOutputTests& operator= (const MultiVertexArrayOutputTests& other);
757 void addInputTypeCases (MultiVertexArrayTest::Spec spec, int depth);
758 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
761 MultiVertexArrayOutputTests::MultiVertexArrayOutputTests (Context& context)
762 : TestCaseGroup(context, "input_types", "input types")
766 MultiVertexArrayOutputTests::~MultiVertexArrayOutputTests (void)
770 std::string MultiVertexArrayOutputTests::getTestName (const MultiVertexArrayTest::Spec& spec)
772 std::stringstream name;
775 << spec.arrays.size();
777 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
781 << Array::inputTypeToString(spec.arrays[arrayNdx].inputType)
782 << spec.arrays[arrayNdx].componentCount << "_"
783 << Array::outputTypeToString(spec.arrays[arrayNdx].outputType);
789 void MultiVertexArrayOutputTests::init (void)
791 // Test different input types, with multiple arrays
792 int arrayCounts[] = {3};
794 MultiVertexArrayTest::Spec spec;
796 spec.primitive = Array::PRIMITIVE_TRIANGLES;
797 spec.drawCount = 256;
800 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
801 addInputTypeCases(spec, arrayCounts[arrayCountNdx]);
804 void MultiVertexArrayOutputTests::addInputTypeCases (MultiVertexArrayTest::Spec spec, int depth)
808 std::string name = getTestName(spec);
809 std::string desc = getTestName(spec);
810 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
814 Array::InputType inputTypes[] = {Array::INPUTTYPE_FIXED, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT};
815 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
817 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
818 Array::OUTPUTTYPE_VEC2,
820 Array::USAGE_DYNAMIC_DRAW,
825 GLValue::getMinValue(inputTypes[inputTypeNdx]),
826 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
828 MultiVertexArrayTest::Spec _spec = spec;
829 _spec.arrays.push_back(arraySpec);
830 addInputTypeCases(_spec, depth-1);
834 class MultiVertexArrayTestGroup : public TestCaseGroup
837 MultiVertexArrayTestGroup (Context& context);
838 virtual ~MultiVertexArrayTestGroup (void);
840 virtual void init (void);
843 MultiVertexArrayTestGroup (const MultiVertexArrayTestGroup& other);
844 MultiVertexArrayTestGroup& operator= (const MultiVertexArrayTestGroup& other);
847 MultiVertexArrayTestGroup::MultiVertexArrayTestGroup (Context& context)
848 : TestCaseGroup(context, "multiple_attributes", "Multiple vertex atributes")
852 MultiVertexArrayTestGroup::~MultiVertexArrayTestGroup (void)
856 void MultiVertexArrayTestGroup::init (void)
858 addChild(new MultiVertexArrayCountTests(m_context));
859 addChild(new MultiVertexArrayStorageTests(m_context));
860 addChild(new MultiVertexArrayStrideTests(m_context));
861 addChild(new MultiVertexArrayOutputTests(m_context));
864 VertexArrayTestGroup::VertexArrayTestGroup (Context& context)
865 : TestCaseGroup(context, "vertex_arrays", "Vertex array and array tests")
869 VertexArrayTestGroup::~VertexArrayTestGroup (void)
873 void VertexArrayTestGroup::init (void)
875 addChild(new SingleVertexArrayTestGroup(m_context));
876 addChild(new MultiVertexArrayTestGroup(m_context));