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 Drawing tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fDrawTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsDrawTest.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deSTLUtil.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <set> 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum TestIterationType 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_DRAW_COUNT, // !< test with 1, 5, and 25 primitives 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_LAST 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void addTestIterations (gls::DrawTest* test, const gls::DrawTestSpec& baseSpec, TestIterationType type) 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec(baseSpec); 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (type == TYPE_DRAW_COUNT) 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 1; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "draw count = 1"); 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "draw count = 5"); 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 25; 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "draw count = 25"); 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void genBasicSpec (gls::DrawTestSpec& spec, gls::DrawTestSpec::DrawMethod method) 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(2,0); 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = gls::DrawTestSpec::PRIMITIVE_TRIANGLES; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = method; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = gls::DrawTestSpec::INDEXTYPE_LAST; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = gls::DrawTestSpec::STORAGE_LAST; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(2); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 4; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = 2; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 0; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = false; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass AttributeGroup : public TestCaseGroup 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry AttributeGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod, gls::DrawTestSpec::Primitive primitive, gls::DrawTestSpec::IndexType indexType, gls::DrawTestSpec::Storage indexStorage); 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~AttributeGroup (void); 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Primitive m_primitive; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::IndexType m_indexType; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Storage m_indexStorage; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryAttributeGroup::AttributeGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod, gls::DrawTestSpec::Primitive primitive, gls::DrawTestSpec::IndexType indexType, gls::DrawTestSpec::Storage indexStorage) 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitive (primitive) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexType (indexType) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexStorage (indexStorage) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko PoyryAttributeGroup::~AttributeGroup (void) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid AttributeGroup::init (void) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Single attribute 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "single_attribute", "Single attribute array."); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(2,0); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 0; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(1); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 2; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, TYPE_DRAW_COUNT); 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Multiple attribute 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "multiple_attributes", "Multiple attribute arrays"); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(2,0); 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 0; 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(2); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 4; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = 2; 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 0; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = false; 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, TYPE_DRAW_COUNT); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Multiple attribute, second one default. 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "default_attribute", "Attribute specified with glVertexAttrib*."); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(2,0); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(2); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 2; 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct IOPair 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::InputType input; 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OutputType output; 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int componentCount; 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } iopairs[] = 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC2, 4 }, 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC4, 2 }, 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ioNdx = 0; ioNdx < DE_LENGTH_OF_ARRAY(iopairs); ++ioNdx) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = gls::DrawTestSpec::inputTypeToString(iopairs[ioNdx].input) + de::toString(iopairs[ioNdx].componentCount) + " to " + gls::DrawTestSpec::outputTypeToString(iopairs[ioNdx].output); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = iopairs[ioNdx].input; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = iopairs[ioNdx].output; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = iopairs[ioNdx].componentCount; 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 0; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = true; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, desc.c_str()); 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IndexGroup : public TestCaseGroup 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IndexGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IndexGroup (void); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIndexGroup::IndexGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod) 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3033c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIndexGroup::~IndexGroup (void) 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IndexGroup::init (void) 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct IndexTest 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Storage storage; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::IndexType type; 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool aligned; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsets[3]; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexTest tests[] = 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_BYTE, true, { 0, 1, -1 } }, 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_SHORT, true, { 0, 2, -1 } }, 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_SHORT, false, { 1, 3, -1 } }, 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_BYTE, true, { 0, 1, -1 } }, 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_SHORT, true, { 0, 2, -1 } }, 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_SHORT, false, { 1, 3, -1 } }, 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* userPtrGroup = new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer"); 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* unalignedUserPtrGroup = new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer"); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* bufferGroup = new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer"); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* unalignedBufferGroup = new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer"); 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genBasicSpec(spec, m_method); 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(userPtrGroup); 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(unalignedUserPtrGroup); 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(bufferGroup); 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(unalignedBufferGroup); 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx) 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexTest& indexTest = tests[testNdx]; 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* group = (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) : ((indexTest.aligned) ? (bufferGroup) : (unalignedBufferGroup)); 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " + gls::DrawTestSpec::storageToString(indexTest.storage); 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::MovePtr<gls::DrawTest> test (new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str())); 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = indexTest.type; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = indexTest.storage; 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int iterationNdx = 0; iterationNdx < DE_LENGTH_OF_ARRAY(indexTest.offsets) && indexTest.offsets[iterationNdx] != -1; ++iterationNdx) 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDesc = std::string("offset ") + de::toString(indexTest.offsets[iterationNdx]); 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = indexTest.offsets[iterationNdx]; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, iterationDesc.c_str()); 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET && 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE) 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(test.release()); 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FirstGroup : public TestCaseGroup 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FirstGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod); 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~FirstGroup (void); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFirstGroup::FirstGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod) 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3883c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFirstGroup::~FirstGroup (void) 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FirstGroup::init (void) 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int firsts[] = 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0, 1, 17 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genBasicSpec(spec, m_method); 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); ++firstNdx) 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("first_") + de::toString(firsts[firstNdx]); 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string("first ") + de::toString(firsts[firstNdx]); 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str()); 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = firsts[firstNdx]; 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, TYPE_DRAW_COUNT); 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MethodGroup : public TestCaseGroup 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MethodGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod); 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~MethodGroup (void); 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMethodGroup::MethodGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMethodGroup::~MethodGroup (void) 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MethodGroup::init (void) 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool indexed = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS) || (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED) || (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool hasFirst = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS) || (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED); 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const gls::DrawTestSpec::Primitive primitive[] = 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_POINTS, 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLES, 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP, 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINES, 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_STRIP, 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_LOOP 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (hasFirst) 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // First-tests 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new FirstGroup(m_context, "first", "First tests", m_method)); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (indexed) 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Index-tests 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_method != gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED) 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new IndexGroup(m_context, "indices", "Index tests", m_method)); 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(primitive); ++ndx) 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = gls::DrawTestSpec::primitiveToString(primitive[ndx]); 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = gls::DrawTestSpec::primitiveToString(primitive[ndx]); 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new AttributeGroup(m_context, name.c_str(), desc.c_str(), m_method, primitive[ndx], gls::DrawTestSpec::INDEXTYPE_SHORT, gls::DrawTestSpec::STORAGE_BUFFER)); 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomGroup : public TestCaseGroup 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomGroup (Context& context, const char* name, const char* descr); 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RandomGroup (void); 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int SIZE> 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UniformWeightArray 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float weights[SIZE]; 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UniformWeightArray (void) 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i=0; i<SIZE; ++i) 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry weights[i] = 1.0f; 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomGroup::RandomGroup (Context& context, const char* name, const char* descr) 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomGroup::~RandomGroup (void) 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomGroup::init (void) 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numAttempts = 100; 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int attribCounts[] = { 1, 2, 5 }; 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float attribWeights[] = { 30, 10, 1 }; 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int primitiveCounts[] = { 1, 5, 64 }; 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float primitiveCountWeights[] = { 20, 10, 1 }; 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int indexOffsets[] = { 0, 7, 13 }; 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float indexOffsetWeights[] = { 20, 20, 1 }; 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int firsts[] = { 0, 7, 13 }; 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float firstWeights[] = { 20, 20, 1 }; 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int offsets[] = { 0, 1, 5, 12 }; 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float offsetWeights[] = { 50, 10, 10, 10 }; 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int strides[] = { 0, 7, 16, 17 }; 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float strideWeights[] = { 50, 10, 10, 10 }; 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::Primitive primitives[] = 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_POINTS, 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLES, 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP, 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINES, 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_STRIP, 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_LOOP 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(primitives)> primitiveWeights; 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::DrawMethod drawMethods[] = 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS, 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS, 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(drawMethods)> drawMethodWeights; 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::IndexType indexTypes[] = 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_BYTE, 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_SHORT, 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(indexTypes)> indexTypeWeights; 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::Storage storages[] = 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::STORAGE_USER, 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::STORAGE_BUFFER, 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(storages)> storageWeights; 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::InputType inputTypes[] = 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_FLOAT, 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_FIXED, 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_BYTE, 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_SHORT, 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_BYTE, 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_SHORT 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(inputTypes)> inputTypeWeights; 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::OutputType outputTypes[] = 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_FLOAT, 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC2, 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC3, 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC4, 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(outputTypes)> outputTypeWeights; 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::Usage usages[] = 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_DRAW, 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_DRAW, 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_DRAW, 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(usages)> usageWeights; 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const deUint32 blacklistedCases[]= 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153, //!< extremely narrow triangle, results depend on sample positions 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::set<deUint32> insertedHashes; 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t insertedCount = 0; 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numAttempts; ++ndx) 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random random(0xc551393 + ndx); // random does not depend on previous cases 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int attributeCount = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(attribCounts), DE_ARRAY_END(attribCounts), attribWeights); 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(2,0); 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = random.chooseWeighted<gls::DrawTestSpec::Primitive> (DE_ARRAY_BEGIN(primitives), DE_ARRAY_END(primitives), primitiveWeights.weights); 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(primitiveCounts), DE_ARRAY_END(primitiveCounts), primitiveCountWeights); 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = random.chooseWeighted<gls::DrawTestSpec::DrawMethod> (DE_ARRAY_BEGIN(drawMethods), DE_ARRAY_END(drawMethods), drawMethodWeights.weights); 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = random.chooseWeighted<gls::DrawTestSpec::IndexType> (DE_ARRAY_BEGIN(indexTypes), DE_ARRAY_END(indexTypes), indexTypeWeights.weights); 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexOffsets), DE_ARRAY_END(indexOffsets), indexOffsetWeights); 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = random.chooseWeighted<gls::DrawTestSpec::Storage> (DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights); 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(firsts), DE_ARRAY_END(firsts), firstWeights); 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 0; 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check spec is legal 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!spec.valid()) 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int attrNdx = 0; attrNdx < attributeCount;) 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool valid; 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::AttributeSpec attribSpec; 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.inputType = random.chooseWeighted<gls::DrawTestSpec::InputType> (DE_ARRAY_BEGIN(inputTypes), DE_ARRAY_END(inputTypes), inputTypeWeights.weights); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.outputType = random.chooseWeighted<gls::DrawTestSpec::OutputType> (DE_ARRAY_BEGIN(outputTypes), DE_ARRAY_END(outputTypes), outputTypeWeights.weights); 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.storage = random.chooseWeighted<gls::DrawTestSpec::Storage> (DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights); 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.usage = random.chooseWeighted<gls::DrawTestSpec::Usage> (DE_ARRAY_BEGIN(usages), DE_ARRAY_END(usages), usageWeights.weights); 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.componentCount = random.getInt(1, 4); 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.offset = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(offsets), DE_ARRAY_END(offsets), offsetWeights); 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.stride = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(strides), DE_ARRAY_END(strides), strideWeights); 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.normalize = random.getBool(); 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.instanceDivisor = 0; 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.useDefaultAttribute = random.getBool(); 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check spec is legal 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry valid = attribSpec.valid(spec.apiType); 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // we do not want interleaved elements. (Might result in some weird floating point values) 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (attribSpec.stride && attribSpec.componentCount * gls::DrawTestSpec::inputTypeSize(attribSpec.inputType) > attribSpec.stride) 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry valid = false; 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // try again if not valid 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (valid) 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.push_back(attribSpec); 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++attrNdx; 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do not collapse all vertex positions to a single positions 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Is render result meaningful? 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only one vertex 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED && spec.indexMin == spec.indexMax && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].useDefaultAttribute && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Triangle only on one axis 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLES || spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN || spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP) 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].componentCount == 1) 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_FLOAT || spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_INT || spec.attribs[0].outputType == gls::DrawTestSpec::OUTPUTTYPE_UINT) 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED && (spec.indexMax - spec.indexMin) < 2) 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Add case 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 hash = spec.hash(); 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int attrNdx = 0; attrNdx < attributeCount; ++attrNdx) 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry hash = (hash << 2) ^ (deUint32)spec.attribs[attrNdx].hash(); 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (insertedHashes.find(hash) == insertedHashes.end() && 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry !de::contains(DE_ARRAY_BEGIN(blacklistedCases), DE_ARRAY_END(blacklistedCases), hash)) 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only aligned cases 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET && 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE) 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new gls::DrawTest(m_testCtx, m_context.getRenderContext(), spec, de::toString(insertedCount).c_str(), spec.getDesc().c_str())); 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry insertedHashes.insert(hash); 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++insertedCount; 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDrawTests::DrawTests (Context& context) 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "draw", "Drawing tests") 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDrawTests::~DrawTests (void) 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DrawTests::init (void) 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Basic 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const gls::DrawTestSpec::DrawMethod basicMethods[] = 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS, 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS, 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(basicMethods); ++ndx) 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string name = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]); 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string desc = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]); 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new MethodGroup(m_context, name.c_str(), desc.c_str(), basicMethods[ndx])); 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Random 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new RandomGroup(m_context, "random", "random draw commands.")); 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 729