13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.0 Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Vertex array and buffer unaligned access stress tests 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2sVertexArrayTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsVertexArrayTests.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace deqp::gls; 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Stress 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate<class T> 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic std::string typeToString (T t) 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::stringstream strm; 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry strm << t; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return strm.str(); 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleVertexArrayUsageTests : public TestCaseGroup 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayUsageTests (Context& context); 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SingleVertexArrayUsageTests (void); 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayUsageTests (const SingleVertexArrayUsageTests& other); 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayUsageTests& operator= (const SingleVertexArrayUsageTests& other); 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayUsageTests::SingleVertexArrayUsageTests (Context& context) 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "usages", "Single vertex atribute, usage") 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayUsageTests::~SingleVertexArrayUsageTests (void) 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleVertexArrayUsageTests::init (void) 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test usage 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::Usage usages[] = {Array::USAGE_STATIC_DRAW, Array::USAGE_STREAM_DRAW, Array::USAGE_DYNAMIC_DRAW}; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int counts[] = {1, 256}; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int strides[] = {17}; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_FIXED, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE}; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(usages); usageNdx++) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int componentCount = 2; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]); 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool aligned = (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::OUTPUTTYPE_VEC2, 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::STORAGE_BUFFER, 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usages[usageNdx], 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry componentCount, 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0, 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stride, 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false, 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMinValue(inputTypes[inputTypeNdx]), 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMaxValue(inputTypes[inputTypeNdx])); 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec spec; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = Array::PRIMITIVE_TRIANGLES; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawCount = counts[countNdx]; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.arrays.push_back(arraySpec); 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name = spec.getName(); 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!aligned) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleVertexArrayStrideTests : public TestCaseGroup 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayStrideTests (Context& context); 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SingleVertexArrayStrideTests (void); 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayStrideTests (const SingleVertexArrayStrideTests& other); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayStrideTests& operator= (const SingleVertexArrayStrideTests& other); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayStrideTests::SingleVertexArrayStrideTests (Context& context) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "strides", "Single stride vertex atribute") 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1343c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayStrideTests::~SingleVertexArrayStrideTests (void) 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleVertexArrayStrideTests::init (void) 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test strides with different input types, component counts and storage, Usage(?) 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_SHORT, Array::INPUTTYPE_BYTE, /*Array::INPUTTYPE_UNSIGNED_SHORT, Array::INPUTTYPE_UNSIGNED_BYTE,*/ Array::INPUTTYPE_FIXED}; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::Storage storages[] = {Array::STORAGE_BUFFER}; 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int counts[] = {1, 256}; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int strides[] = {17}; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int storageNdx = 0; storageNdx < DE_LENGTH_OF_ARRAY(storages); storageNdx++) 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int componentCount = 2; componentCount < 5; componentCount++) 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * componentCount : strides[strideNdx]); 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool bufferUnaligned = (storages[storageNdx] == Array::STORAGE_BUFFER) && (stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) != 0; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::OUTPUTTYPE_VEC4, 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry storages[storageNdx], 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::USAGE_DYNAMIC_DRAW, 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry componentCount, 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0, 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stride, 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false, 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMinValue(inputTypes[inputTypeNdx]), 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMaxValue(inputTypes[inputTypeNdx])); 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec spec; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = Array::PRIMITIVE_TRIANGLES; 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawCount = counts[countNdx]; 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.arrays.push_back(arraySpec); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name = spec.getName(); 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferUnaligned) 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleVertexArrayFirstTests : public TestCaseGroup 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayFirstTests (Context& context); 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SingleVertexArrayFirstTests (void); 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayFirstTests (const SingleVertexArrayFirstTests& other); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayFirstTests& operator= (const SingleVertexArrayFirstTests& other); 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayFirstTests::SingleVertexArrayFirstTests (Context& context) 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "first", "Single vertex atribute different first values") 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2043c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayFirstTests::~SingleVertexArrayFirstTests (void) 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleVertexArrayFirstTests::init (void) 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test strides with different input types, component counts and storage, Usage(?) 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED}; 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int counts[] = {5, 256}; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int firsts[] = {6, 24}; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsets[] = {1, 17}; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL. 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++) 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); firstNdx++) 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && (offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx]) == 0); 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::OUTPUTTYPE_VEC2, 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::STORAGE_BUFFER, 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::USAGE_DYNAMIC_DRAW, 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2, 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offsets[offsetNdx], 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stride, 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false, 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMinValue(inputTypes[inputTypeNdx]), 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMaxValue(inputTypes[inputTypeNdx])); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec spec; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = Array::PRIMITIVE_TRIANGLES; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawCount = counts[countNdx]; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = firsts[firstNdx]; 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.arrays.push_back(arraySpec); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name = Array::inputTypeToString(inputTypes[inputTypeNdx]) + "_first" + typeToString(firsts[firstNdx]) + "_offset" + typeToString(offsets[offsetNdx]) + "_stride" + typeToString(stride) + "_quads" + typeToString(counts[countNdx]); 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!aligned) 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleVertexArrayOffsetTests : public TestCaseGroup 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayOffsetTests (Context& context); 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~SingleVertexArrayOffsetTests (void); 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayOffsetTests (const SingleVertexArrayOffsetTests& other); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleVertexArrayOffsetTests& operator= (const SingleVertexArrayOffsetTests& other); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2703c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayOffsetTests::SingleVertexArrayOffsetTests (Context& context) 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "offset", "Single vertex atribute offset element") 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleVertexArrayOffsetTests::~SingleVertexArrayOffsetTests (void) 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleVertexArrayOffsetTests::init (void) 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Test strides with different input types, component counts and storage, Usage(?) 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::InputType inputTypes[] = {Array::INPUTTYPE_FLOAT, Array::INPUTTYPE_BYTE, Array::INPUTTYPE_FIXED}; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int counts[] = {1, 256}; 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsets[] = {1, 4, 17, 32}; 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int strides[] = {/*0,*/ -1, 17, 32}; // Tread negative value as sizeof input. Same as 0, but done outside of GL. 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int inputTypeNdx = 0; inputTypeNdx < DE_LENGTH_OF_ARRAY(inputTypes); inputTypeNdx++) 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int offsetNdx = 0; offsetNdx < DE_LENGTH_OF_ARRAY(offsets); offsetNdx++) 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int countNdx = 0; countNdx < DE_LENGTH_OF_ARRAY(counts); countNdx++) 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int strideNdx = 0; strideNdx < DE_LENGTH_OF_ARRAY(strides); strideNdx++) 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int stride = (strides[strideNdx] < 0 ? Array::inputTypeSize(inputTypes[inputTypeNdx]) * 2 : strides[strideNdx]); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool aligned = ((stride % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0) && ((offsets[offsetNdx] % Array::inputTypeSize(inputTypes[inputTypeNdx])) == 0); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec::ArraySpec arraySpec(inputTypes[inputTypeNdx], 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::OUTPUTTYPE_VEC2, 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::STORAGE_BUFFER, 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry Array::USAGE_DYNAMIC_DRAW, 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2, 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offsets[offsetNdx], 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stride, 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false, 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMinValue(inputTypes[inputTypeNdx]), 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLValue::getMaxValue(inputTypes[inputTypeNdx])); 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MultiVertexArrayTest::Spec spec; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = Array::PRIMITIVE_TRIANGLES; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawCount = counts[countNdx]; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.arrays.push_back(arraySpec); 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name = spec.getName(); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!aligned) 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new MultiVertexArrayTest(m_testCtx, m_context.getRenderContext(), spec, name.c_str(), name.c_str())); 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexArrayTests::VertexArrayTests (Context& context) 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "vertex_arrays", "Vertex array and array tests") 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexArrayTests::~VertexArrayTests (void) 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid VertexArrayTests::init (void) 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "single_attribute", "Single attribute"); 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(group); 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .single_attribute 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new SingleVertexArrayStrideTests(m_context)); 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new SingleVertexArrayUsageTests(m_context)); 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new SingleVertexArrayOffsetTests(m_context)); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new SingleVertexArrayFirstTests(m_context)); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Stress 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 352