13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.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 "es3fDrawTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsDrawTest.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deSTLUtil.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <set> 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 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 TYPE_INSTANCE_COUNT, // !< test with 1, 4, and 11 instances 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_INDEX_RANGE, // !< test with index range of [0, 23], [23, 40], and [5, 5] 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TYPE_LAST 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void addTestIterations (gls::DrawTest* test, const gls::DrawTestSpec& baseSpec, TestIterationType type) 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec(baseSpec); 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (type == TYPE_DRAW_COUNT) 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 1; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "draw count = 1"); 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "draw count = 5"); 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 25; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "draw count = 25"); 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (type == TYPE_INSTANCE_COUNT) 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "instance count = 1"); 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 4; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "instance count = 4"); 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 11; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "instance count = 11"); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (type == TYPE_INDEX_RANGE) 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 23; 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "index range = [0, 23]"); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 23; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 40; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "index range = [23, 40]"); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only makes sense with points 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_POINTS) 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 5; 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 5; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, "index range = [5, 5]"); 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void genBasicSpec (gls::DrawTestSpec& spec, gls::DrawTestSpec::DrawMethod method) 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,0); 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = gls::DrawTestSpec::PRIMITIVE_TRIANGLES; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = method; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = gls::DrawTestSpec::INDEXTYPE_LAST; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = gls::DrawTestSpec::STORAGE_LAST; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(2); 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 4; 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = 2; 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 0; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = false; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass AttributeGroup : public TestCaseGroup 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1443c827367444ee418f129b2c238299f49d3264554Jarkko 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); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~AttributeGroup (void); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Primitive m_primitive; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::IndexType m_indexType; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Storage m_indexStorage; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1563c827367444ee418f129b2c238299f49d3264554Jarkko 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) 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitive (primitive) 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexType (indexType) 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexStorage (indexStorage) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryAttributeGroup::~AttributeGroup (void) 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid AttributeGroup::init (void) 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // select test type 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool instanced = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED) || 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool ranged = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestIterationType testType = (instanced) ? (TYPE_INSTANCE_COUNT) : ((ranged) ? (TYPE_INDEX_RANGE) : (TYPE_DRAW_COUNT)); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Single attribute 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "single_attribute", "Single attribute array."); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,0); 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(1); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 2; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, testType); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Multiple attribute 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "multiple_attributes", "Multiple attribute arrays."); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,0); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(2); 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 4; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = 2; 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 0; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = false; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, testType); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Multiple attribute, second one divided 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "instanced_attributes", "Instanced attribute array."); 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,0); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 0; 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(3); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 4; 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Add another position component so the instances wont be drawn on each other 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = 2; 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 1; 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = false; 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].additionalPositionAttribute = true; 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Instanced color 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].storage = gls::DrawTestSpec::STORAGE_BUFFER; 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].componentCount = 3; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].offset = 0; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].stride = 0; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].normalize = false; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].instanceDivisor = 1; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[2].useDefaultAttribute = false; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, testType); 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Multiple attribute, second one default 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), "default_attribute", "Attribute specified with glVertexAttrib*."); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,0); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = m_primitive; 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = 5; 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = m_method; 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = m_indexType; 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = 0; 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = m_indexStorage; 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = 0; 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = 0; 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = 20; // \note addTestIterations is not called for the spec, so we must ensure [indexMin, indexMax] is a good range 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = 1; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.resize(2); 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].inputType = gls::DrawTestSpec::INPUTTYPE_FLOAT; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].outputType = gls::DrawTestSpec::OUTPUTTYPE_VEC2; 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].storage = gls::DrawTestSpec::STORAGE_BUFFER; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].componentCount = 2; 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].offset = 0; 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].stride = 0; 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].normalize = false; 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].useDefaultAttribute = false; 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct IOPair 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::InputType input; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OutputType output; 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int componentCount; 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } iopairs[] = 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC2, 4 }, 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::INPUTTYPE_FLOAT, gls::DrawTestSpec::OUTPUTTYPE_VEC4, 2 }, 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::INPUTTYPE_INT, gls::DrawTestSpec::OUTPUTTYPE_IVEC3, 4 }, 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT, gls::DrawTestSpec::OUTPUTTYPE_UVEC2, 4 }, 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ioNdx = 0; ioNdx < DE_LENGTH_OF_ARRAY(iopairs); ++ioNdx) 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = gls::DrawTestSpec::inputTypeToString(iopairs[ioNdx].input) + de::toString(iopairs[ioNdx].componentCount) + " to " + gls::DrawTestSpec::outputTypeToString(iopairs[ioNdx].output); 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].inputType = iopairs[ioNdx].input; 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].outputType = iopairs[ioNdx].output; 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].storage = gls::DrawTestSpec::STORAGE_BUFFER; 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].usage = gls::DrawTestSpec::USAGE_STATIC_DRAW; 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].componentCount = iopairs[ioNdx].componentCount; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].offset = 0; 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].stride = 0; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].normalize = false; 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].instanceDivisor = 0; 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[1].useDefaultAttribute = true; 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, desc.c_str()); 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass IndexGroup : public TestCaseGroup 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IndexGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod); 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~IndexGroup (void); 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3953c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIndexGroup::IndexGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod) 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko PoyryIndexGroup::~IndexGroup (void) 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid IndexGroup::init (void) 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct IndexTest 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Storage storage; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::IndexType type; 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool aligned; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int offsets[3]; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexTest tests[] = 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_BYTE, true, { 0, 1, -1 } }, 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_SHORT, true, { 0, 2, -1 } }, 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_INT, true, { 0, 4, -1 } }, 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_SHORT, false, { 1, 3, -1 } }, 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_USER, gls::DrawTestSpec::INDEXTYPE_INT, false, { 2, 3, -1 } }, 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_BYTE, true, { 0, 1, -1 } }, 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_SHORT, true, { 0, 2, -1 } }, 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_INT, true, { 0, 4, -1 } }, 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_SHORT, false, { 1, 3, -1 } }, 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { gls::DrawTestSpec::STORAGE_BUFFER, gls::DrawTestSpec::INDEXTYPE_INT, false, { 2, 3, -1 } }, 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* userPtrGroup = new tcu::TestCaseGroup(m_testCtx, "user_ptr", "user pointer"); 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* unalignedUserPtrGroup = new tcu::TestCaseGroup(m_testCtx, "unaligned_user_ptr", "unaligned user pointer"); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* bufferGroup = new tcu::TestCaseGroup(m_testCtx, "buffer", "buffer"); 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* unalignedBufferGroup = new tcu::TestCaseGroup(m_testCtx, "unaligned_buffer", "unaligned buffer"); 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genBasicSpec(spec, m_method); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(userPtrGroup); 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(unalignedUserPtrGroup); 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(bufferGroup); 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(unalignedBufferGroup); 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int testNdx = 0; testNdx < DE_LENGTH_OF_ARRAY(tests); ++testNdx) 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const IndexTest& indexTest = tests[testNdx]; 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* group = (indexTest.storage == gls::DrawTestSpec::STORAGE_USER) ? ((indexTest.aligned) ? (userPtrGroup) : (unalignedUserPtrGroup)) : ((indexTest.aligned) ? (bufferGroup) : (unalignedBufferGroup)); 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("index_") + gls::DrawTestSpec::indexTypeToString(indexTest.type); 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string("index ") + gls::DrawTestSpec::indexTypeToString(indexTest.type) + " in " + gls::DrawTestSpec::storageToString(indexTest.storage); 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::MovePtr<gls::DrawTest> test (new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str())); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = indexTest.type; 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = indexTest.storage; 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int iterationNdx = 0; iterationNdx < DE_LENGTH_OF_ARRAY(indexTest.offsets) && indexTest.offsets[iterationNdx] != -1; ++iterationNdx) 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDesc = std::string("offset ") + de::toString(indexTest.offsets[iterationNdx]); 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = indexTest.offsets[iterationNdx]; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry test->addIteration(spec, iterationDesc.c_str()); 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET && 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE) 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(test.release()); 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FirstGroup : public TestCaseGroup 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FirstGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~FirstGroup (void); 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4843c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFirstGroup::FirstGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod) 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4903c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFirstGroup::~FirstGroup (void) 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FirstGroup::init (void) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int firsts[] = 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1, 3, 17 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genBasicSpec(spec, m_method); 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int firstNdx = 0; firstNdx < DE_LENGTH_OF_ARRAY(firsts); ++firstNdx) 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("first_") + de::toString(firsts[firstNdx]); 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string("first ") + de::toString(firsts[firstNdx]); 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTest* test = new gls::DrawTest(m_testCtx, m_context.getRenderContext(), name.c_str(), desc.c_str()); 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = firsts[firstNdx]; 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addTestIterations(test, spec, TYPE_DRAW_COUNT); 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(test); 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MethodGroup : public TestCaseGroup 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MethodGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod); 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~MethodGroup (void); 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod m_method; 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMethodGroup::MethodGroup (Context& context, const char* name, const char* descr, gls::DrawTestSpec::DrawMethod drawMethod) 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_method (drawMethod) 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMethodGroup::~MethodGroup (void) 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MethodGroup::init (void) 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool indexed = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS) || (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED) || (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED); 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool hasFirst = (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS) || (m_method == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED); 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const gls::DrawTestSpec::Primitive primitive[] = 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_POINTS, 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLES, 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP, 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINES, 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_STRIP, 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_LOOP 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (hasFirst) 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // First-tests 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new FirstGroup(m_context, "first", "First tests", m_method)); 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (indexed) 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Index-tests 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_method != gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED) 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new IndexGroup(m_context, "indices", "Index tests", m_method)); 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(primitive); ++ndx) 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = gls::DrawTestSpec::primitiveToString(primitive[ndx]); 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = gls::DrawTestSpec::primitiveToString(primitive[ndx]); 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5743c827367444ee418f129b2c238299f49d3264554Jarkko 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)); 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GridProgram : public sglr::ShaderProgram 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GridProgram (void); 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const; 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const; 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGridProgram::GridProgram (void) 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : sglr::ShaderProgram(sglr::pdec::ShaderProgramDeclaration() 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT) 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_offset", rr::GENERICVECTYPE_FLOAT) 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_color", rr::GENERICVECTYPE_FLOAT) 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexToFragmentVarying(rr::GENERICVECTYPE_FLOAT) 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT) 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexSource("#version 300 es\n" 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_position;\n" 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_offset;\n" 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_color;\n" 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "out mediump vec4 v_color;\n" 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main(void)\n" 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position + a_offset;\n" 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " v_color = a_color;\n" 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n") 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::FragmentSource( 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n" 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 dEQP_FragColor;\n" 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in mediump vec4 v_color;\n" 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main(void)\n" 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " dEQP_FragColor = v_color;\n" 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n")) 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GridProgram::shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numPackets; ++ndx) 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry packets[ndx]->position = rr::readVertexAttribFloat(inputs[0], packets[ndx]->instanceNdx, packets[ndx]->vertexNdx) + rr::readVertexAttribFloat(inputs[1], packets[ndx]->instanceNdx, packets[ndx]->vertexNdx); 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry packets[ndx]->outputs[0] = rr::readVertexAttribFloat(inputs[2], packets[ndx]->instanceNdx, packets[ndx]->vertexNdx); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GridProgram::shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx) 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fragNdx = 0; fragNdx < 4; ++fragNdx) 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, rr::readTriangleVarying<float>(packets[packetNdx], context, 0, fragNdx)); 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass InstancedGridRenderTest : public TestCase 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry InstancedGridRenderTest (Context& context, const char* name, const char* desc, int gridSide, bool useIndices); 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~InstancedGridRenderTest (void); 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void renderTo (sglr::Context& ctx, sglr::ShaderProgram& program, tcu::Surface& dst); 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool verifyImage (const tcu::Surface& image); 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_gridSide; 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_useIndices; 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6473c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInstancedGridRenderTest::InstancedGridRenderTest (Context& context, const char* name, const char* desc, int gridSide, bool useIndices) 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, desc) 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_gridSide (gridSide) 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useIndices (useIndices) 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6543c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInstancedGridRenderTest::~InstancedGridRenderTest (void) 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6583c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInstancedGridRenderTest::IterateResult InstancedGridRenderTest::iterate (void) 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int renderTargetWidth = de::min(1024, m_context.getRenderTarget().getWidth()); 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int renderTargetHeight = de::min(1024, m_context.getRenderTarget().getHeight()); 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext ctx (m_context.getRenderContext(), m_testCtx.getLog(), sglr::GLCONTEXT_LOG_CALLS | sglr::GLCONTEXT_LOG_PROGRAMS, tcu::IVec4(0, 0, renderTargetWidth, renderTargetHeight)); 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface surface (renderTargetWidth, renderTargetHeight); 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GridProgram program; 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // render 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderTo(ctx, program, surface); 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // verify image 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (verifyImage(surface)) 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect rendering result"); 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid InstancedGridRenderTest::renderTo (sglr::Context& ctx, sglr::ShaderProgram& program, tcu::Surface& dst) 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 green (0, 1, 0, 1); 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 yellow (1, 1, 0, 1); 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 positionBuf = 0; 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 offsetBuf = 0; 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorBuf = 0; 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 indexBuf = 0; 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 programID = ctx.createProgram(&program); 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 posLocation = ctx.getAttribLocation(programID, "a_position"); 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 offsetLocation = ctx.getAttribLocation(programID, "a_offset"); 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 colorLocation = ctx.getAttribLocation(programID, "a_color"); 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float cellW = 2.0f / m_gridSide; 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float cellH = 2.0f / m_gridSide; 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 vertexPositions[] = 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0, 0, 0, 1), 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(cellW, 0, 0, 1), 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0, cellH, 0, 1), 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0, cellH, 0, 1), 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(cellW, 0, 0, 1), 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(cellW, cellH, 0, 1), 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint16 indices[] = 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 0, 4, 3, 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2, 1, 5 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> offsets; 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < m_gridSide; ++x) 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < m_gridSide; ++y) 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offsets.push_back(tcu::Vec4(x * cellW - 1.0f, y * cellW - 1.0f, 0, 0)); 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> colors; 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < m_gridSide; ++x) 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < m_gridSide; ++y) 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry colors.push_back(((x + y) % 2 == 0) ? (green) : (yellow)); 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.genBuffers(1, &positionBuf); 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindBuffer(GL_ARRAY_BUFFER, positionBuf); 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bufferData(GL_ARRAY_BUFFER, sizeof(vertexPositions), vertexPositions, GL_STATIC_DRAW); 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribDivisor(posLocation, 0); 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray(posLocation); 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.genBuffers(1, &offsetBuf); 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindBuffer(GL_ARRAY_BUFFER, offsetBuf); 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bufferData(GL_ARRAY_BUFFER, offsets.size() * sizeof(tcu::Vec4), &offsets[0], GL_STATIC_DRAW); 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer(offsetLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribDivisor(offsetLocation, 1); 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray(offsetLocation); 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.genBuffers(1, &colorBuf); 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindBuffer(GL_ARRAY_BUFFER, colorBuf); 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bufferData(GL_ARRAY_BUFFER, colors.size() * sizeof(tcu::Vec4), &colors[0], GL_STATIC_DRAW); 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.vertexAttribDivisor(colorLocation, 1); 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.enableVertexAttribArray(colorLocation); 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useIndices) 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.genBuffers(1, &indexBuf); 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuf); 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clearColor(0, 0, 0, 1); 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.clear(GL_COLOR_BUFFER_BIT); 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.viewport(0, 0, dst.getWidth(), dst.getHeight()); 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram(programID); 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useIndices) 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.drawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, DE_NULL, m_gridSide * m_gridSide); 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.drawArraysInstanced(GL_TRIANGLES, 0, 6, m_gridSide * m_gridSide); 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram(0); 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useIndices) 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteBuffers(1, &indexBuf); 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteBuffers(1, &colorBuf); 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteBuffers(1, &offsetBuf); 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteBuffers(1, &positionBuf); 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.deleteProgram(programID); 7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.finish(); 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.readPixels(dst, 0, 0, dst.getWidth(), dst.getHeight()); 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(ctx.getError(), "", __FILE__, __LINE__); 7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool InstancedGridRenderTest::verifyImage (const tcu::Surface& image) 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note the green/yellow pattern is only for clarity. The test will only verify that all instances were drawn by looking for anything non-green/yellow. 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA green (0, 255, 0, 255); 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA yellow (255, 255, 0, 255); 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int colorThreshold = 20; 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface error (image.getWidth(), image.getHeight()); 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = true; 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 1; y < image.getHeight()-1; y++) 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 1; x < image.getWidth()-1; x++) 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA pixel = image.getPixel(x, y); 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool pixelOk = true; 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Any pixel with !(G ~= 255) is faulty (not a linear combinations of green and yellow) 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (de::abs(pixel.getGreen() - 255) > colorThreshold) 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixelOk = false; 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Any pixel with !(B ~= 0) is faulty (not a linear combinations of green and yellow) 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (de::abs(pixel.getBlue() - 0) > colorThreshold) 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixelOk = false; 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry error.setPixel(x, y, (pixelOk) ? (tcu::RGBA(0, 255, 0, 255)) : (tcu::RGBA(255, 0, 0, 255))); 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk = isOk && pixelOk; 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isOk) 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Image verification failed." << TestLog::EndMessage; 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Verfication result", "Result of rendering") 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Result", image) 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ErrorMask", "Error mask", error) 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Verfication result", "Result of rendering") 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Result", image) 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isOk; 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass InstancingGroup : public TestCaseGroup 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry InstancingGroup (Context& context, const char* name, const char* descr); 8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~InstancingGroup (void); 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInstancingGroup::InstancingGroup (Context& context, const char* name, const char* descr) 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInstancingGroup::~InstancingGroup (void) 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid InstancingGroup::init (void) 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int gridWidths[] = 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2, 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5, 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10, 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32, 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 100, 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // drawArrays 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(gridWidths); ++ndx) 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("draw_arrays_instanced_grid_") + de::toString(gridWidths[ndx]) + "x" + de::toString(gridWidths[ndx]); 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string("DrawArraysInstanced, Grid size ") + de::toString(gridWidths[ndx]) + "x" + de::toString(gridWidths[ndx]); 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new InstancedGridRenderTest(m_context, name.c_str(), desc.c_str(), gridWidths[ndx], false)); 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // drawElements 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(gridWidths); ++ndx) 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string("draw_elements_instanced_grid_") + de::toString(gridWidths[ndx]) + "x" + de::toString(gridWidths[ndx]); 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string("DrawElementsInstanced, Grid size ") + de::toString(gridWidths[ndx]) + "x" + de::toString(gridWidths[ndx]); 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new InstancedGridRenderTest(m_context, name.c_str(), desc.c_str(), gridWidths[ndx], true)); 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomGroup : public TestCaseGroup 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomGroup (Context& context, const char* name, const char* descr); 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RandomGroup (void); 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int SIZE> 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UniformWeightArray 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float weights[SIZE]; 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UniformWeightArray (void) 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i=0; i<SIZE; ++i) 8933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry weights[i] = 1.0f; 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomGroup::RandomGroup (Context& context, const char* name, const char* descr) 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomGroup::~RandomGroup (void) 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomGroup::init (void) 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numAttempts = 300; 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int attribCounts[] = { 1, 2, 5 }; 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float attribWeights[] = { 30, 10, 1 }; 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int primitiveCounts[] = { 1, 5, 64 }; 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float primitiveCountWeights[] = { 20, 10, 1 }; 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int indexOffsets[] = { 0, 7, 13 }; 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float indexOffsetWeights[] = { 20, 20, 1 }; 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int firsts[] = { 0, 7, 13 }; 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float firstWeights[] = { 20, 20, 1 }; 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int instanceCounts[] = { 1, 2, 16, 17 }; 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float instanceWeights[] = { 20, 10, 5, 1 }; 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int indexMins[] = { 0, 1, 3, 8 }; 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int indexMaxs[] = { 4, 8, 128, 257 }; 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float indexWeights[] = { 50, 50, 50, 50 }; 9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int offsets[] = { 0, 1, 5, 12 }; 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float offsetWeights[] = { 50, 10, 10, 10 }; 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int strides[] = { 0, 7, 16, 17 }; 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float strideWeights[] = { 50, 10, 10, 10 }; 9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const int instanceDivisors[] = { 0, 1, 3, 129 }; 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float instanceDivisorWeights[]= { 70, 30, 10, 10 }; 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::Primitive primitives[] = 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_POINTS, 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLES, 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP, 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINES, 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_STRIP, 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_LOOP 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(primitives)> primitiveWeights; 9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::DrawMethod drawMethods[] = 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS, 9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED, 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS, 9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED, 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(drawMethods)> drawMethodWeights; 9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::IndexType indexTypes[] = 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_BYTE, 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_SHORT, 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_INT, 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(indexTypes)> indexTypeWeights; 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::Storage storages[] = 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::STORAGE_USER, 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::STORAGE_BUFFER, 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(storages)> storageWeights; 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::InputType inputTypes[] = 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_FLOAT, 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_FIXED, 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_BYTE, 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_SHORT, 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_BYTE, 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_SHORT, 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_INT, 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT, 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_HALF, 9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT_2_10_10_10, 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_INT_2_10_10_10, 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(inputTypes)> inputTypeWeights; 9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::OutputType outputTypes[] = 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_FLOAT, 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC2, 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC3, 9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC4, 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_INT, 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UINT, 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_IVEC2, 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_IVEC3, 9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_IVEC4, 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UVEC2, 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UVEC3, 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UVEC4, 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(outputTypes)> outputTypeWeights; 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const gls::DrawTestSpec::Usage usages[] = 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_DRAW, 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_DRAW, 10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_DRAW, 10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_READ, 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_COPY, 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_READ, 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_COPY, 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_READ, 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_COPY, 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(usages)> usageWeights; 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const deUint32 blacklistedCases[]= 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 544, //!< extremely narrow triangle 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::set<deUint32> insertedHashes; 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t insertedCount = 0; 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numAttempts; ++ndx) 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random random(0xc551393 + ndx); // random does not depend on previous cases 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int attributeCount = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(attribCounts), DE_ARRAY_END(attribCounts), attribWeights); 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,0); 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = random.chooseWeighted<gls::DrawTestSpec::Primitive> (DE_ARRAY_BEGIN(primitives), DE_ARRAY_END(primitives), primitiveWeights.weights); 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(primitiveCounts), DE_ARRAY_END(primitiveCounts), primitiveCountWeights); 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = random.chooseWeighted<gls::DrawTestSpec::DrawMethod> (DE_ARRAY_BEGIN(drawMethods), DE_ARRAY_END(drawMethods), drawMethodWeights.weights); 10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = random.chooseWeighted<gls::DrawTestSpec::IndexType> (DE_ARRAY_BEGIN(indexTypes), DE_ARRAY_END(indexTypes), indexTypeWeights.weights); 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexOffsets), DE_ARRAY_END(indexOffsets), indexOffsetWeights); 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = random.chooseWeighted<gls::DrawTestSpec::Storage> (DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights); 10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(firsts), DE_ARRAY_END(firsts), firstWeights); 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexMins), DE_ARRAY_END(indexMins), indexWeights); 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexMaxs), DE_ARRAY_END(indexMaxs), indexWeights); 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(instanceCounts), DE_ARRAY_END(instanceCounts), instanceWeights); 10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check spec is legal 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!spec.valid()) 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int attrNdx = 0; attrNdx < attributeCount;) 10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool valid; 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::AttributeSpec attribSpec; 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.inputType = random.chooseWeighted<gls::DrawTestSpec::InputType> (DE_ARRAY_BEGIN(inputTypes), DE_ARRAY_END(inputTypes), inputTypeWeights.weights); 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.outputType = random.chooseWeighted<gls::DrawTestSpec::OutputType> (DE_ARRAY_BEGIN(outputTypes), DE_ARRAY_END(outputTypes), outputTypeWeights.weights); 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.storage = random.chooseWeighted<gls::DrawTestSpec::Storage> (DE_ARRAY_BEGIN(storages), DE_ARRAY_END(storages), storageWeights.weights); 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.usage = random.chooseWeighted<gls::DrawTestSpec::Usage> (DE_ARRAY_BEGIN(usages), DE_ARRAY_END(usages), usageWeights.weights); 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.componentCount = random.getInt(1, 4); 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.offset = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(offsets), DE_ARRAY_END(offsets), offsetWeights); 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.stride = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(strides), DE_ARRAY_END(strides), strideWeights); 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.normalize = random.getBool(); 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.instanceDivisor = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(instanceDivisors), DE_ARRAY_END(instanceDivisors), instanceDivisorWeights); 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.useDefaultAttribute = random.getBool(); 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check spec is legal 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry valid = attribSpec.valid(spec.apiType); 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // we do not want interleaved elements. (Might result in some weird floating point values) 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (attribSpec.stride && attribSpec.componentCount * gls::DrawTestSpec::inputTypeSize(attribSpec.inputType) > attribSpec.stride) 10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry valid = false; 10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // try again if not valid 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (valid) 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.push_back(attribSpec); 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++attrNdx; 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do not collapse all vertex positions to a single positions 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Is render result meaningful? 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only one vertex 10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED && spec.indexMin == spec.indexMax && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].useDefaultAttribute && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Triangle only on one axis 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLES || spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN || spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP) 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].componentCount == 1) 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 10933c827367444ee418f129b2c238299f49d3264554Jarkko 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) 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED && (spec.indexMax - spec.indexMin) < 2) 10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Add case 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 hash = spec.hash(); 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int attrNdx = 0; attrNdx < attributeCount; ++attrNdx) 11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry hash = (hash << 2) ^ (deUint32)spec.attribs[attrNdx].hash(); 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (insertedHashes.find(hash) == insertedHashes.end()) 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only properly aligned and not blacklisted cases 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET && 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.isCompatibilityTest() != gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE && 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry !de::contains(DE_ARRAY_BEGIN(blacklistedCases), DE_ARRAY_END(blacklistedCases), hash)) 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new gls::DrawTest(m_testCtx, m_context.getRenderContext(), spec, de::toString(insertedCount).c_str(), spec.getDesc().c_str())); 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry insertedHashes.insert(hash); 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++insertedCount; 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDrawTests::DrawTests (Context& context) 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "draw", "Drawing tests") 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDrawTests::~DrawTests (void) 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DrawTests::init (void) 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Basic 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const gls::DrawTestSpec::DrawMethod basicMethods[] = 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS, 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS, 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INSTANCED, 11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INSTANCED, 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED, 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(basicMethods); ++ndx) 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]); 11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = gls::DrawTestSpec::drawMethodToString(basicMethods[ndx]); 11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new MethodGroup(m_context, name.c_str(), desc.c_str(), basicMethods[ndx])); 11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // extreme instancing 11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new InstancingGroup(m_context, "instancing", "draw tests with a large instance count.")); 11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Random 11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new RandomGroup(m_context, "random", "random draw commands.")); 11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1168