1 /*-------------------------------------------------------------------------
2 * drawElements Quality Program OpenGL ES 3.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 "es3fVertexArrayTest.hpp"
25 #include "glsVertexArrayTests.hpp"
29 using namespace deqp::gls;
38 class SingleVertexArrayUsageGroup : public TestCaseGroup
41 SingleVertexArrayUsageGroup (Context& context, Array::Usage usage);
42 virtual ~SingleVertexArrayUsageGroup (void);
44 virtual void init (void);
47 SingleVertexArrayUsageGroup (const SingleVertexArrayUsageGroup& other);
48 SingleVertexArrayUsageGroup& operator= (const SingleVertexArrayUsageGroup& other);
53 SingleVertexArrayUsageGroup::SingleVertexArrayUsageGroup (Context& context, Array::Usage usage)
54 : TestCaseGroup (context, Array::usageTypeToString(usage).c_str(), Array::usageTypeToString(usage).c_str())
59 SingleVertexArrayUsageGroup::~SingleVertexArrayUsageGroup (void)
64 static std::string typeToString (T t)
66 std::stringstream strm;
71 void SingleVertexArrayUsageGroup::init (void)
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 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]);
84 const bool aligned = (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0;
85 const std::string name = "stride" + typeToString(stride) + "_" + Array::inputTypeToString(inputTypes[inputTypeNdx]) + "_quads" + typeToString(counts[countNdx]);
87 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
88 Array::OUTPUTTYPE_VEC2,
89 Array::STORAGE_BUFFER,
95 GLValue::getMinValue(inputTypes[inputTypeNdx]),
96 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
98 MultiVertexArrayTest::Spec spec;
99 spec.primitive = Array::PRIMITIVE_TRIANGLES;
100 spec.drawCount = counts[countNdx];
102 spec.arrays.push_back(arraySpec);
105 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
111 class SingleVertexArrayUsageTests : public TestCaseGroup
114 SingleVertexArrayUsageTests (Context& context);
115 virtual ~SingleVertexArrayUsageTests (void);
117 virtual void init (void);
120 SingleVertexArrayUsageTests (const SingleVertexArrayUsageTests& other);
121 SingleVertexArrayUsageTests& operator= (const SingleVertexArrayUsageTests& other);
124 SingleVertexArrayUsageTests::SingleVertexArrayUsageTests (Context& context)
125 : TestCaseGroup(context, "usages", "Single vertex atribute, usage")
129 SingleVertexArrayUsageTests::~SingleVertexArrayUsageTests (void)
133 void SingleVertexArrayUsageTests::init (void)
136 Array::Usage usages[] = { Array::USAGE_STATIC_DRAW, Array::USAGE_STREAM_DRAW, Array::USAGE_DYNAMIC_DRAW, Array::USAGE_STATIC_COPY, Array::USAGE_STREAM_COPY, Array::USAGE_DYNAMIC_COPY, Array::USAGE_STATIC_READ, Array::USAGE_STREAM_READ, Array::USAGE_DYNAMIC_READ };
137 for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(usages); usageNdx++)
139 addChild(new SingleVertexArrayUsageGroup(m_context, usages[usageNdx]));
143 class SingleVertexArrayStrideGroup : public TestCaseGroup
146 SingleVertexArrayStrideGroup (Context& context, Array::InputType type);
147 virtual ~SingleVertexArrayStrideGroup (void);
149 virtual void init (void);
152 SingleVertexArrayStrideGroup (const SingleVertexArrayStrideGroup& other);
153 SingleVertexArrayStrideGroup& operator= (const SingleVertexArrayStrideGroup& other);
155 Array::InputType m_type;
158 SingleVertexArrayStrideGroup::SingleVertexArrayStrideGroup (Context& context, Array::InputType type)
159 : TestCaseGroup (context, Array::inputTypeToString(type).c_str(), Array::inputTypeToString(type).c_str())
164 SingleVertexArrayStrideGroup::~SingleVertexArrayStrideGroup (void)
168 void SingleVertexArrayStrideGroup::init (void)
170 Array::Storage storages[] = {Array::STORAGE_USER, Array::STORAGE_BUFFER};
171 int counts[] = {1, 256};
172 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
174 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
176 for (int componentCount = 2; componentCount < 5; componentCount++)
178 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
180 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
182 const bool packed = m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10;
183 const int stride = (strides[strideNdx] < 0) ? ((packed) ? (16) : (Array::inputTypeSize(m_type) * componentCount)) : (strides[strideNdx]);
184 const int alignment = (packed) ? (Array::inputTypeSize(m_type) * componentCount) : (Array::inputTypeSize(m_type));
185 const bool bufferUnaligned = (storages[storageNdx] == Array::STORAGE_BUFFER) && (stride % alignment) != 0;
187 std::string name = Array::storageToString(storages[storageNdx]) + "_stride" + typeToString(stride) + "_components" + typeToString(componentCount) + "_quads" + typeToString(counts[countNdx]);
189 if((m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10) && componentCount != 4)
192 MultiVertexArrayTest::Spec::ArraySpec arraySpec(m_type,
193 Array::OUTPUTTYPE_VEC4,
194 storages[storageNdx],
195 Array::USAGE_DYNAMIC_DRAW,
200 GLValue::getMinValue(m_type),
201 GLValue::getMaxValue(m_type));
203 MultiVertexArrayTest::Spec spec;
204 spec.primitive = Array::PRIMITIVE_TRIANGLES;
205 spec.drawCount = counts[countNdx];
207 spec.arrays.push_back(arraySpec);
209 if (!bufferUnaligned)
210 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
217 class SingleVertexArrayStrideTests : public TestCaseGroup
220 SingleVertexArrayStrideTests (Context& context);
221 virtual ~SingleVertexArrayStrideTests (void);
223 virtual void init (void);
226 SingleVertexArrayStrideTests (const SingleVertexArrayStrideTests& other);
227 SingleVertexArrayStrideTests& operator= (const SingleVertexArrayStrideTests& other);
230 SingleVertexArrayStrideTests::SingleVertexArrayStrideTests (Context& context)
231 : TestCaseGroup(context, "strides", "Single stride vertex atribute")
235 SingleVertexArrayStrideTests::~SingleVertexArrayStrideTests (void)
239 void SingleVertexArrayStrideTests::init (void)
241 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, /*Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE,*/ Array::INPUTTYPE_FIXED, Array::INPUTTYPE_INT_2_10_10_10 };
243 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
245 addChild(new SingleVertexArrayStrideGroup(m_context, inputTypes[inputTypeNdx]));
249 class SingleVertexArrayFirstGroup : public TestCaseGroup
252 SingleVertexArrayFirstGroup (Context& context, Array::InputType type);
253 virtual ~SingleVertexArrayFirstGroup (void);
255 virtual void init (void);
258 SingleVertexArrayFirstGroup (const SingleVertexArrayFirstGroup& other);
259 SingleVertexArrayFirstGroup& operator= (const SingleVertexArrayFirstGroup& other);
260 Array::InputType m_type;
263 SingleVertexArrayFirstGroup::SingleVertexArrayFirstGroup (Context& context, Array::InputType type)
264 : TestCaseGroup (context, Array::inputTypeToString(type).c_str(), Array::inputTypeToString(type).c_str())
269 SingleVertexArrayFirstGroup::~SingleVertexArrayFirstGroup (void)
273 void SingleVertexArrayFirstGroup::init (void)
275 int counts[] = {5, 256};
276 int firsts[] = {6, 24};
277 int offsets[] = {1, 16, 17};
278 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
280 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++)
282 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
284 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
286 for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); firstNdx++)
288 const bool packed = m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10;
289 const int componentCount = (packed) ? (4) : (2);
290 const int stride = (strides[strideNdx] < 0) ? ((packed) ? (8) : (Array::inputTypeSize(m_type) * componentCount)) : (strides[strideNdx]);
291 const int alignment = (packed) ? (Array::inputTypeSize(m_type) * componentCount) : (Array::inputTypeSize(m_type));
292 const bool aligned = ((stride % alignment) == 0) && ((offsets[offsetNdx] % alignment) == 0);
293 std::string name = "first" + typeToString(firsts[firstNdx]) + "_offset" + typeToString(offsets[offsetNdx]) + "_stride" + typeToString(stride) + "_quads" + typeToString(counts[countNdx]);
295 MultiVertexArrayTest::Spec::ArraySpec arraySpec(m_type,
296 Array::OUTPUTTYPE_VEC2,
297 Array::STORAGE_BUFFER,
298 Array::USAGE_DYNAMIC_DRAW,
303 GLValue::getMinValue(m_type),
304 GLValue::getMaxValue(m_type));
306 MultiVertexArrayTest::Spec spec;
307 spec.primitive = Array::PRIMITIVE_TRIANGLES;
308 spec.drawCount = counts[countNdx];
309 spec.first = firsts[firstNdx];
310 spec.arrays.push_back(arraySpec);
313 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
320 class SingleVertexArrayFirstTests : public TestCaseGroup
323 SingleVertexArrayFirstTests (Context& context);
324 virtual ~SingleVertexArrayFirstTests (void);
326 virtual void init (void);
329 SingleVertexArrayFirstTests (const SingleVertexArrayFirstTests& other);
330 SingleVertexArrayFirstTests& operator= (const SingleVertexArrayFirstTests& other);
333 SingleVertexArrayFirstTests::SingleVertexArrayFirstTests (Context& context)
334 : TestCaseGroup(context, "first", "Single vertex attribute, different first values to drawArrays")
338 SingleVertexArrayFirstTests::~SingleVertexArrayFirstTests (void)
342 void SingleVertexArrayFirstTests::init (void)
344 // Test offset with different input types, component counts and storage, Usage(?)
345 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_INT_2_10_10_10 };
347 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
349 addChild(new SingleVertexArrayFirstGroup(m_context, inputTypes[inputTypeNdx]));
353 class SingleVertexArrayOffsetGroup : public TestCaseGroup
356 SingleVertexArrayOffsetGroup (Context& context, Array::InputType type);
357 virtual ~SingleVertexArrayOffsetGroup (void);
359 virtual void init (void);
362 SingleVertexArrayOffsetGroup (const SingleVertexArrayOffsetGroup& other);
363 SingleVertexArrayOffsetGroup& operator= (const SingleVertexArrayOffsetGroup& other);
364 Array::InputType m_type;
367 SingleVertexArrayOffsetGroup::SingleVertexArrayOffsetGroup (Context& context, Array::InputType type)
368 : TestCaseGroup (context, Array::inputTypeToString(type).c_str(), Array::inputTypeToString(type).c_str())
373 SingleVertexArrayOffsetGroup::~SingleVertexArrayOffsetGroup (void)
377 void SingleVertexArrayOffsetGroup::init (void)
379 int counts[] = {1, 256};
380 int offsets[] = {1, 4, 17, 32};
381 int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL.
383 for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++)
385 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
387 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
389 const bool packed = m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10;
390 const int componentCount = (packed) ? (4) : (2);
391 const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(m_type) * componentCount : strides[strideNdx]);
392 const int alignment = (packed) ? (Array::inputTypeSize(m_type) * componentCount) : (Array::inputTypeSize(m_type));
393 const bool aligned = ((stride % alignment) == 0) && ((offsets[offsetNdx] % alignment) == 0);
394 const std::string name = "offset" + typeToString(offsets[offsetNdx]) + "_stride" + typeToString(stride) + "_quads" + typeToString(counts[countNdx]);
396 MultiVertexArrayTest::Spec::ArraySpec arraySpec(m_type,
397 Array::OUTPUTTYPE_VEC2,
398 Array::STORAGE_BUFFER,
399 Array::USAGE_DYNAMIC_DRAW,
404 GLValue::getMinValue(m_type),
405 GLValue::getMaxValue(m_type));
407 MultiVertexArrayTest::Spec spec;
408 spec.primitive = Array::PRIMITIVE_TRIANGLES;
409 spec.drawCount = counts[countNdx];
411 spec.arrays.push_back(arraySpec);
414 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
420 class SingleVertexArrayOffsetTests : public TestCaseGroup
423 SingleVertexArrayOffsetTests (Context& context);
424 virtual ~SingleVertexArrayOffsetTests (void);
426 virtual void init (void);
429 SingleVertexArrayOffsetTests (const SingleVertexArrayOffsetTests& other);
430 SingleVertexArrayOffsetTests& operator= (const SingleVertexArrayOffsetTests& other);
433 SingleVertexArrayOffsetTests::SingleVertexArrayOffsetTests (Context& context)
434 : TestCaseGroup(context, "offset", "Single vertex atribute offset element")
438 SingleVertexArrayOffsetTests::~SingleVertexArrayOffsetTests (void)
442 void SingleVertexArrayOffsetTests::init (void)
444 // Test offset with different input types, component counts and storage, Usage(?)
445 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_INT_2_10_10_10 };
447 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
449 addChild(new SingleVertexArrayOffsetGroup(m_context, inputTypes[inputTypeNdx]));
453 class SingleVertexArrayNormalizeGroup : public TestCaseGroup
456 SingleVertexArrayNormalizeGroup (Context& context, Array::InputType type);
457 virtual ~SingleVertexArrayNormalizeGroup (void);
459 virtual void init (void);
462 SingleVertexArrayNormalizeGroup (const SingleVertexArrayNormalizeGroup& other);
463 SingleVertexArrayNormalizeGroup& operator= (const SingleVertexArrayNormalizeGroup& other);
464 Array::InputType m_type;
467 SingleVertexArrayNormalizeGroup::SingleVertexArrayNormalizeGroup (Context& context, Array::InputType type)
468 : TestCaseGroup (context, Array::inputTypeToString(type).c_str(), Array::inputTypeToString(type).c_str())
473 SingleVertexArrayNormalizeGroup::~SingleVertexArrayNormalizeGroup (void)
477 void SingleVertexArrayNormalizeGroup::init (void)
479 int counts[] = {1, 256};
481 for (int componentCount = 2; componentCount < 5; componentCount++)
483 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
485 if((m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10) && componentCount != 4)
488 std::string name = "components" + typeToString(componentCount) + "_quads" + typeToString(counts[countNdx]);
490 MultiVertexArrayTest::Spec::ArraySpec arraySpec(m_type,
491 Array::OUTPUTTYPE_VEC4,
493 Array::USAGE_DYNAMIC_DRAW,
498 GLValue::getMinValue(m_type),
499 GLValue::getMaxValue(m_type));
501 MultiVertexArrayTest::Spec spec;
502 spec.primitive = Array::PRIMITIVE_TRIANGLES;
503 spec.drawCount = counts[countNdx];
505 spec.arrays.push_back(arraySpec);
507 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
512 class SingleVertexArrayNormalizeTests : public TestCaseGroup
515 SingleVertexArrayNormalizeTests (Context& context);
516 virtual ~SingleVertexArrayNormalizeTests (void);
518 virtual void init (void);
521 SingleVertexArrayNormalizeTests (const SingleVertexArrayNormalizeTests& other);
522 SingleVertexArrayNormalizeTests& operator= (const SingleVertexArrayNormalizeTests& other);
525 SingleVertexArrayNormalizeTests::SingleVertexArrayNormalizeTests (Context& context)
526 : TestCaseGroup(context, "normalize", "Single normalize vertex atribute")
530 SingleVertexArrayNormalizeTests::~SingleVertexArrayNormalizeTests (void)
534 void SingleVertexArrayNormalizeTests::init (void)
536 // Test normalization with different input types, component counts and storage
537 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_FIXED, Array::INPUTTYPE_UNSIGNED_INT, Array::INPUTTYPE_INT, Array::INPUTTYPE_HALF , Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10, Array::INPUTTYPE_INT_2_10_10_10 };
539 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
541 addChild(new SingleVertexArrayNormalizeGroup(m_context, inputTypes[inputTypeNdx]));
545 class SingleVertexArrayOutputTypeGroup : public TestCaseGroup
548 SingleVertexArrayOutputTypeGroup (Context& context, Array::InputType type);
549 virtual ~SingleVertexArrayOutputTypeGroup (void);
551 virtual void init (void);
554 SingleVertexArrayOutputTypeGroup (const SingleVertexArrayOutputTypeGroup& other);
555 SingleVertexArrayOutputTypeGroup& operator= (const SingleVertexArrayOutputTypeGroup& other);
556 Array::InputType m_type;
559 SingleVertexArrayOutputTypeGroup::SingleVertexArrayOutputTypeGroup (Context& context, Array::InputType type)
560 : TestCaseGroup (context, Array::inputTypeToString(type).c_str(), Array::inputTypeToString(type).c_str())
565 SingleVertexArrayOutputTypeGroup::~SingleVertexArrayOutputTypeGroup (void)
569 void SingleVertexArrayOutputTypeGroup::init (void)
571 Array::OutputType outputTypes[] = {Array::OUTPUTTYPE_VEC2, Array::OUTPUTTYPE_VEC3, Array::OUTPUTTYPE_VEC4, Array::OUTPUTTYPE_IVEC2, Array::OUTPUTTYPE_IVEC3, Array::OUTPUTTYPE_IVEC4, Array::OUTPUTTYPE_UVEC2, Array::OUTPUTTYPE_UVEC3, Array::OUTPUTTYPE_UVEC4 };
572 Array::Storage storages[] = {Array::STORAGE_USER};
573 int counts[] = {1, 256};
575 for (int outputTypeNdx = 0; outputTypeNdx < DE_LENGTH_OF_ARRAY(outputTypes); outputTypeNdx++)
577 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
579 for (int componentCount = 2; componentCount < 5; componentCount++)
581 for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++)
583 std::string name = "components" + typeToString(componentCount) + "_" + Array::outputTypeToString(outputTypes[outputTypeNdx]) + "_quads" + typeToString(counts[countNdx]);
585 const bool inputIsSignedInteger = m_type == Array::INPUTTYPE_INT || m_type == Array::INPUTTYPE_SHORT || m_type == Array::INPUTTYPE_BYTE;
586 const bool inputIsUnignedInteger = m_type == Array::INPUTTYPE_UNSIGNED_INT || m_type == Array::INPUTTYPE_UNSIGNED_SHORT || m_type == Array::INPUTTYPE_UNSIGNED_BYTE;
587 const bool outputIsSignedInteger = outputTypes[outputTypeNdx] == Array::OUTPUTTYPE_IVEC2 || outputTypes[outputTypeNdx] == Array::OUTPUTTYPE_IVEC3 || outputTypes[outputTypeNdx] == Array::OUTPUTTYPE_IVEC4;
588 const bool outputIsUnsignedInteger = outputTypes[outputTypeNdx] == Array::OUTPUTTYPE_UVEC2 || outputTypes[outputTypeNdx] == Array::OUTPUTTYPE_UVEC3 || outputTypes[outputTypeNdx] == Array::OUTPUTTYPE_UVEC4;
590 // If input type is float type and output type is int type skip
591 if ((m_type == Array::INPUTTYPE_FLOAT || m_type == Array::INPUTTYPE_HALF || m_type == Array::INPUTTYPE_FIXED) && (outputTypes[outputTypeNdx] >= Array::OUTPUTTYPE_INT))
594 if((m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10) && (outputTypes[outputTypeNdx] >= Array::OUTPUTTYPE_INT))
597 if((m_type == Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10 || m_type == Array::INPUTTYPE_INT_2_10_10_10) && componentCount != 4)
600 // Loading signed data as unsigned causes undefined values and vice versa
601 if (inputIsSignedInteger && outputIsUnsignedInteger)
603 if (inputIsUnignedInteger && outputIsSignedInteger)
606 MultiVertexArrayTest::Spec::ArraySpec arraySpec(m_type,
607 outputTypes[outputTypeNdx],
608 storages[storageNdx],
609 Array::USAGE_DYNAMIC_DRAW,
614 GLValue::getMinValue(m_type),
615 GLValue::getMaxValue(m_type));
617 MultiVertexArrayTest::Spec spec;
618 spec.primitive = Array::PRIMITIVE_TRIANGLES;
619 spec.drawCount = counts[countNdx];
621 spec.arrays.push_back(arraySpec);
623 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str()));
630 class SingleVertexArrayOutputTypeTests : public TestCaseGroup
633 SingleVertexArrayOutputTypeTests (Context& context);
634 virtual ~SingleVertexArrayOutputTypeTests (void);
636 virtual void init (void);
639 SingleVertexArrayOutputTypeTests (const SingleVertexArrayOutputTypeTests& other);
640 SingleVertexArrayOutputTypeTests& operator= (const SingleVertexArrayOutputTypeTests& other);
643 SingleVertexArrayOutputTypeTests::SingleVertexArrayOutputTypeTests (Context& context)
644 : TestCaseGroup(context, "output_types", "Single output type vertex atribute")
648 SingleVertexArrayOutputTypeTests::~SingleVertexArrayOutputTypeTests (void)
652 void SingleVertexArrayOutputTypeTests::init (void)
654 // Test output types with different input types, component counts and storage, Usage?, Precision?, float?
655 Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_FIXED, Array::INPUTTYPE_UNSIGNED_INT, Array::INPUTTYPE_INT, Array::INPUTTYPE_HALF, Array::INPUTTYPE_UNSIGNED_INT_2_10_10_10, Array::INPUTTYPE_INT_2_10_10_10 };
657 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
659 addChild(new SingleVertexArrayOutputTypeGroup(m_context, inputTypes[inputTypeNdx]));
664 class SingleVertexArrayTestGroup : public TestCaseGroup
667 SingleVertexArrayTestGroup (Context& context);
668 virtual ~SingleVertexArrayTestGroup (void);
670 virtual void init (void);
673 SingleVertexArrayTestGroup (const SingleVertexArrayTestGroup& other);
674 SingleVertexArrayTestGroup& operator= (const SingleVertexArrayTestGroup& other);
677 SingleVertexArrayTestGroup::SingleVertexArrayTestGroup (Context& context)
678 : TestCaseGroup(context, "single_attribute", "Single vertex atribute")
682 SingleVertexArrayTestGroup::~SingleVertexArrayTestGroup (void)
686 void SingleVertexArrayTestGroup::init (void)
688 addChild(new SingleVertexArrayStrideTests(m_context));
689 addChild(new SingleVertexArrayNormalizeTests(m_context));
690 addChild(new SingleVertexArrayOutputTypeTests(m_context));
691 addChild(new SingleVertexArrayUsageTests(m_context));
692 addChild(new SingleVertexArrayOffsetTests(m_context));
693 addChild(new SingleVertexArrayFirstTests(m_context));
696 class MultiVertexArrayCountTests : public TestCaseGroup
699 MultiVertexArrayCountTests (Context& context);
700 virtual ~MultiVertexArrayCountTests (void);
702 virtual void init (void);
705 MultiVertexArrayCountTests (const MultiVertexArrayCountTests& other);
706 MultiVertexArrayCountTests& operator= (const MultiVertexArrayCountTests& other);
708 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
711 MultiVertexArrayCountTests::MultiVertexArrayCountTests (Context& context)
712 : TestCaseGroup(context, "attribute_count", "Attribute counts")
716 MultiVertexArrayCountTests::~MultiVertexArrayCountTests (void)
720 std::string MultiVertexArrayCountTests::getTestName (const MultiVertexArrayTest::Spec& spec)
722 std::stringstream name;
724 << spec.arrays.size();
729 void MultiVertexArrayCountTests::init (void)
731 // Test attribute counts
732 int arrayCounts[] = {2, 3, 4, 5, 6, 7, 8};
734 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
736 MultiVertexArrayTest::Spec spec;
738 spec.primitive = Array::PRIMITIVE_TRIANGLES;
739 spec.drawCount = 256;
742 for (int arrayNdx = 0; arrayNdx < arrayCounts[arrayCountNdx]; arrayNdx++)
744 MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT,
745 Array::OUTPUTTYPE_VEC2,
747 Array::USAGE_DYNAMIC_DRAW,
752 GLValue::getMinValue(Array::INPUTTYPE_FLOAT),
753 GLValue::getMaxValue(Array::INPUTTYPE_FLOAT));
755 spec.arrays.push_back(arraySpec);
758 std::string name = getTestName(spec);
759 std::string desc = getTestName(spec);
761 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
765 class MultiVertexArrayStorageTests : public TestCaseGroup
768 MultiVertexArrayStorageTests (Context& context);
769 virtual ~MultiVertexArrayStorageTests (void);
771 virtual void init (void);
774 MultiVertexArrayStorageTests (const MultiVertexArrayStorageTests& other);
775 MultiVertexArrayStorageTests& operator= (const MultiVertexArrayStorageTests& other);
777 void addStorageCases (MultiVertexArrayTest::Spec spec, int depth);
778 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
781 MultiVertexArrayStorageTests::MultiVertexArrayStorageTests (Context& context)
782 : TestCaseGroup(context, "storage", "Attribute storages")
786 MultiVertexArrayStorageTests::~MultiVertexArrayStorageTests (void)
790 std::string MultiVertexArrayStorageTests::getTestName (const MultiVertexArrayTest::Spec& spec)
792 std::stringstream name;
794 << spec.arrays.size();
796 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
800 << Array::storageToString(spec.arrays[arrayNdx].storage);
806 void MultiVertexArrayStorageTests::addStorageCases (MultiVertexArrayTest::Spec spec, int depth)
810 // Skip trivial case, used elsewhere
812 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
814 if (spec.arrays[arrayNdx].storage != Array::STORAGE_USER)
824 std::string name = getTestName(spec);
825 std::string desc = getTestName(spec);
827 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
831 Array::Storage storages[] = {Array::STORAGE_USER, Array::STORAGE_BUFFER};
832 for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++)
834 MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT,
835 Array::OUTPUTTYPE_VEC2,
836 storages[storageNdx],
837 Array::USAGE_DYNAMIC_DRAW,
842 GLValue::getMinValue(Array::INPUTTYPE_FLOAT),
843 GLValue::getMaxValue(Array::INPUTTYPE_FLOAT));
845 MultiVertexArrayTest::Spec _spec = spec;
846 _spec.arrays.push_back(arraySpec);
847 addStorageCases(_spec, depth-1);
852 void MultiVertexArrayStorageTests::init (void)
854 // Test different storages
855 int arrayCounts[] = {3};
857 MultiVertexArrayTest::Spec spec;
859 spec.primitive = Array::PRIMITIVE_TRIANGLES;
860 spec.drawCount = 256;
863 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
864 addStorageCases(spec, arrayCounts[arrayCountNdx]);
867 class MultiVertexArrayStrideTests : public TestCaseGroup
870 MultiVertexArrayStrideTests (Context& context);
871 virtual ~MultiVertexArrayStrideTests (void);
873 virtual void init (void);
876 MultiVertexArrayStrideTests (const MultiVertexArrayStrideTests& other);
877 MultiVertexArrayStrideTests& operator= (const MultiVertexArrayStrideTests& other);
879 void addStrideCases (MultiVertexArrayTest::Spec spec, int depth);
880 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
883 MultiVertexArrayStrideTests::MultiVertexArrayStrideTests (Context& context)
884 : TestCaseGroup(context, "stride", "Strides")
888 MultiVertexArrayStrideTests::~MultiVertexArrayStrideTests (void)
892 std::string MultiVertexArrayStrideTests::getTestName (const MultiVertexArrayTest::Spec& spec)
894 std::stringstream name;
897 << spec.arrays.size();
899 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
903 << Array::inputTypeToString(spec.arrays[arrayNdx].inputType)
904 << spec.arrays[arrayNdx].componentCount << "_"
905 << spec.arrays[arrayNdx].stride;
911 void MultiVertexArrayStrideTests::init (void)
913 // Test different strides, with multiple arrays, input types??
914 int arrayCounts[] = {3};
916 MultiVertexArrayTest::Spec spec;
918 spec.primitive = Array::PRIMITIVE_TRIANGLES;
919 spec.drawCount = 256;
922 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
923 addStrideCases(spec, arrayCounts[arrayCountNdx]);
926 void MultiVertexArrayStrideTests::addStrideCases (MultiVertexArrayTest::Spec spec, int depth)
930 std::string name = getTestName(spec);
931 std::string desc = getTestName(spec);
932 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
936 int strides[] = {0, -1, 17, 32};
938 for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++)
940 const int componentCount = 2;
941 MultiVertexArrayTest::Spec::ArraySpec arraySpec(Array::INPUTTYPE_FLOAT,
942 Array::OUTPUTTYPE_VEC2,
944 Array::USAGE_DYNAMIC_DRAW,
947 (strides[strideNdx] >= 0 ? strides[strideNdx] : componentCount * Array::inputTypeSize(Array::INPUTTYPE_FLOAT)),
949 GLValue::getMinValue(Array::INPUTTYPE_FLOAT),
950 GLValue::getMaxValue(Array::INPUTTYPE_FLOAT));
952 MultiVertexArrayTest::Spec _spec = spec;
953 _spec.arrays.push_back(arraySpec);
954 addStrideCases(_spec, depth-1);
958 class MultiVertexArrayOutputTests : public TestCaseGroup
961 MultiVertexArrayOutputTests (Context& context);
962 virtual ~MultiVertexArrayOutputTests (void);
964 virtual void init (void);
967 MultiVertexArrayOutputTests (const MultiVertexArrayOutputTests& other);
968 MultiVertexArrayOutputTests& operator= (const MultiVertexArrayOutputTests& other);
970 void addInputTypeCases (MultiVertexArrayTest::Spec spec, int depth);
971 std::string getTestName (const MultiVertexArrayTest::Spec& spec);
974 MultiVertexArrayOutputTests::MultiVertexArrayOutputTests (Context& context)
975 : TestCaseGroup(context, "input_types", "input types")
979 MultiVertexArrayOutputTests::~MultiVertexArrayOutputTests (void)
983 std::string MultiVertexArrayOutputTests::getTestName (const MultiVertexArrayTest::Spec& spec)
985 std::stringstream name;
988 << spec.arrays.size();
990 for (int arrayNdx = 0; arrayNdx < (int)spec.arrays.size(); arrayNdx++)
994 << Array::inputTypeToString(spec.arrays[arrayNdx].inputType)
995 << spec.arrays[arrayNdx].componentCount << "_"
996 << Array::outputTypeToString(spec.arrays[arrayNdx].outputType);
1002 void MultiVertexArrayOutputTests::init (void)
1004 // Test different input types, with multiple arrays
1005 int arrayCounts[] = {3};
1007 MultiVertexArrayTest::Spec spec;
1009 spec.primitive = Array::PRIMITIVE_TRIANGLES;
1010 spec.drawCount = 256;
1013 for (int arrayCountNdx = 0; arrayCountNdx < DE_LENGTH_OF_ARRAY(arrayCounts); arrayCountNdx++)
1014 addInputTypeCases(spec, arrayCounts[arrayCountNdx]);
1017 void MultiVertexArrayOutputTests::addInputTypeCases (MultiVertexArrayTest::Spec spec, int depth)
1021 std::string name = getTestName(spec);
1022 std::string desc = getTestName(spec);
1023 addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), desc.c_str()));
1027 Array::InputType inputTypes[] = {Array::INPUTTYPE_FIXED, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE, Array::INPUTTYPE_UNSIGNED_SHORT};
1028 for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++)
1030 MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx],
1031 Array::OUTPUTTYPE_VEC2,
1032 Array::STORAGE_USER,
1033 Array::USAGE_DYNAMIC_DRAW,
1038 GLValue::getMinValue(inputTypes[inputTypeNdx]),
1039 GLValue::getMaxValue(inputTypes[inputTypeNdx]));
1041 MultiVertexArrayTest::Spec _spec = spec;
1042 _spec.arrays.push_back(arraySpec);
1043 addInputTypeCases(_spec, depth-1);
1047 class MultiVertexArrayTestGroup : public TestCaseGroup
1050 MultiVertexArrayTestGroup (Context& context);
1051 virtual ~MultiVertexArrayTestGroup (void);
1053 virtual void init (void);
1056 MultiVertexArrayTestGroup (const MultiVertexArrayTestGroup& other);
1057 MultiVertexArrayTestGroup& operator= (const MultiVertexArrayTestGroup& other);
1060 MultiVertexArrayTestGroup::MultiVertexArrayTestGroup (Context& context)
1061 : TestCaseGroup(context, "multiple_attributes", "Multiple vertex atributes")
1065 MultiVertexArrayTestGroup::~MultiVertexArrayTestGroup (void)
1069 void MultiVertexArrayTestGroup::init (void)
1071 addChild(new MultiVertexArrayCountTests(m_context));
1072 addChild(new MultiVertexArrayStorageTests(m_context));
1073 addChild(new MultiVertexArrayStrideTests(m_context));
1074 addChild(new MultiVertexArrayOutputTests(m_context));
1077 VertexArrayTestGroup::VertexArrayTestGroup (Context& context)
1078 : TestCaseGroup(context, "vertex_arrays", "Vertex array and array tests")
1082 VertexArrayTestGroup::~VertexArrayTestGroup (void)
1086 void VertexArrayTestGroup::init (void)
1088 addChild(new SingleVertexArrayTestGroup(m_context));
1089 addChild(new MultiVertexArrayTestGroup(m_context));