13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 Module 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Drawing stress tests. 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31sDrawTests.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsDrawTest.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deUniquePtr.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <set> 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Stress 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* s_colorVertexShaderSource = "#version 310 es\n" 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_position;\n" 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_color;\n" 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "out highp vec4 v_color;\n" 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " v_color = a_color;\n" 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* s_colorFragmentShaderSource = "#version 310 es\n" 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out highp vec4 fragColor;\n" 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 v_color;\n" 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " fragColor = v_color;\n" 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DrawElementsCommand 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 count; 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 primCount; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 firstIndex; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 baseVertex; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 reservedMustBeZero; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 713c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_STATIC_ASSERT(5 * sizeof(deUint32) == sizeof(DrawElementsCommand)); // tight packing 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DrawArraysCommand 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 count; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 primCount; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 first; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 reservedMustBeZero; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 803c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDE_STATIC_ASSERT(4 * sizeof(deUint32) == sizeof(DrawArraysCommand)); // tight packing 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass InvalidDrawCase : public TestCase 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum DrawType 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAW_ARRAYS, 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAW_ELEMENTS, 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAW_LAST 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum InvalidOperation 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_DATA_COUNT = 0, 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_DATA_FIRST, 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_DATA_INSTANCED, 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_INDEX_COUNT, 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_INDEX_FIRST, 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_RESERVED, 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_INDEX, 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INVALID_LAST 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry InvalidDrawCase (Context& context, const char* name, const char* desc, DrawType type, InvalidOperation op); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~InvalidDrawCase (void); 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const DrawType m_drawType; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const InvalidOperation m_op; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_dataBufferID; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_indexBufferID; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_cmdBufferID; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_colorBufferID; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_vao; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInvalidDrawCase::InvalidDrawCase (Context& context, const char* name, const char* desc, DrawType type, InvalidOperation op) 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, desc) 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_drawType (type) 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_op (op) 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dataBufferID (0) 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexBufferID (0) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_cmdBufferID (0) 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_colorBufferID (0) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_vao (0) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(type < DRAW_LAST); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(op < INVALID_LAST); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1363c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInvalidDrawCase::~InvalidDrawCase (void) 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid InvalidDrawCase::init (void) 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid InvalidDrawCase::deinit (void) 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_dataBufferID) 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_dataBufferID); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dataBufferID = 0; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_indexBufferID) 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_indexBufferID); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBufferID = 0; 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_cmdBufferID) 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_cmdBufferID); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_cmdBufferID = 0; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_colorBufferID) 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_colorBufferID); 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_colorBufferID = 0; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_vao) 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteVertexArrays(1, &m_vao); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vao = 0; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko PoyryInvalidDrawCase::IterateResult InvalidDrawCase::iterate (void) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int drawCount = 10; //!< number of elements safe to draw (all buffers have this) 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int overBoundDrawCount = 10000; //!< number of elements in all other buffers than our target buffer 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int drawInstances = 1; 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int overBoundInstances = 1000; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram program (m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(s_colorVertexShaderSource) << glu::FragmentSource(s_colorFragmentShaderSource)); 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 programID = program.getProgram(); 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt32 posLocation = gl.glGetAttribLocation(programID, "a_position"); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt32 colorLocation = gl.glGetAttribLocation(programID, "a_color"); 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableLogging(true); 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGenVertexArrays(1, &m_vao); 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexArray(m_vao); 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(gl.glGetError(), "gen vao", __FILE__, __LINE__); 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // indices 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawType == DRAW_ELEMENTS) 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int indexBufferSize = (m_op == INVALID_INDEX_COUNT) ? (drawCount) : (overBoundDrawCount); 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint16> indices (indexBufferSize); 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)indices.size(); ++ndx) 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indices[ndx] = (m_op == INVALID_INDEX) ? (overBoundDrawCount + ndx) : (ndx); 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGenBuffers(1, &m_indexBufferID); 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferID); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBufferData(GL_ELEMENT_ARRAY_BUFFER, (int)(indices.size() * sizeof(deUint16)), &indices[0], GL_STATIC_DRAW); 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(gl.glGetError(), "", __FILE__, __LINE__); 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // data 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int dataSize = (m_op == INVALID_DATA_COUNT) ? (drawCount) : (overBoundDrawCount); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // any data is ok 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGenBuffers(1, &m_dataBufferID); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindBuffer(GL_ARRAY_BUFFER, m_dataBufferID); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBufferData(GL_ARRAY_BUFFER, dataSize * sizeof(float[4]), DE_NULL, GL_STATIC_DRAW); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribPointer(posLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glEnableVertexAttribArray(posLocation); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(gl.glGetError(), "", __FILE__, __LINE__); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // potentially instanced data 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int dataSize = drawInstances; 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGenBuffers(1, &m_colorBufferID); 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindBuffer(GL_ARRAY_BUFFER, m_colorBufferID); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBufferData(GL_ARRAY_BUFFER, dataSize * sizeof(float[4]), DE_NULL, GL_STATIC_DRAW); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glEnableVertexAttribArray(colorLocation); 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribDivisor(colorLocation, 1); 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(gl.glGetError(), "", __FILE__, __LINE__); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // command 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawType == DRAW_ARRAYS) 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawArraysCommand drawCommand; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.count = overBoundDrawCount; 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.primCount = (m_op == INVALID_DATA_INSTANCED) ? (overBoundInstances) : (drawInstances); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.first = (m_op == INVALID_DATA_FIRST) ? (overBoundDrawCount) : (0); 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.reservedMustBeZero = (m_op == INVALID_RESERVED) ? (5) : (0); 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "drawCommand:" 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tcount:\t" << drawCommand.count 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tprimCount\t" << drawCommand.primCount 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tfirst\t" << drawCommand.first 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\treservedMustBeZero\t" << drawCommand.reservedMustBeZero 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGenBuffers(1, &m_cmdBufferID); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_cmdBufferID); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(drawCommand), &drawCommand, GL_STATIC_DRAW); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(gl.glGetError(), "", __FILE__, __LINE__); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawType == DRAW_ELEMENTS) 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawElementsCommand drawCommand; 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.count = overBoundDrawCount; 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.primCount = (m_op == INVALID_DATA_INSTANCED) ? (overBoundInstances) : (drawInstances); 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.firstIndex = (m_op == INVALID_INDEX_FIRST) ? (overBoundDrawCount) : (0); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.baseVertex = (m_op == INVALID_DATA_FIRST) ? (overBoundDrawCount) : (0); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommand.reservedMustBeZero = (m_op == INVALID_RESERVED) ? (5) : (0); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "drawCommand:" 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tcount:\t" << drawCommand.count 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tprimCount\t" << drawCommand.primCount 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tfirstIndex\t" << drawCommand.firstIndex 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\tbaseVertex\t" << drawCommand.baseVertex 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\treservedMustBeZero\t" << drawCommand.reservedMustBeZero 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGenBuffers(1, &m_cmdBufferID); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindBuffer(GL_DRAW_INDIRECT_BUFFER, m_cmdBufferID); 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(drawCommand), &drawCommand, GL_STATIC_DRAW); 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::checkError(gl.glGetError(), "", __FILE__, __LINE__); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glViewport(0, 0, 1, 1); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glUseProgram(programID); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawType == DRAW_ELEMENTS) 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, DE_NULL); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawType == DRAW_ARRAYS) 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glDrawArraysIndirect(GL_TRIANGLES, DE_NULL); 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glUseProgram(0); 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glFinish(); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomGroup : public TestCaseGroup 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomGroup (Context& context, const char* name, const char* descr); 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RandomGroup (void); 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <int SIZE> 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UniformWeightArray 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float weights[SIZE]; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UniformWeightArray (void) 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i=0; i<SIZE; ++i) 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry weights[i] = 1.0f; 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomGroup::RandomGroup (Context& context, const char* name, const char* descr) 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup (context, name, descr) 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomGroup::~RandomGroup (void) 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomGroup::init (void) 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numAttempts = 100; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int attribCounts[] = { 1, 2, 5 }; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float attribWeights[] = { 30, 10, 1 }; 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int primitiveCounts[] = { 1, 5, 64 }; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float primitiveCountWeights[] = { 20, 10, 1 }; 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int indexOffsets[] = { 0, 7, 13 }; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float indexOffsetWeights[] = { 20, 20, 1 }; 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int firsts[] = { 0, 7, 13 }; 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float firstWeights[] = { 20, 20, 1 }; 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int instanceCounts[] = { 1, 2, 16, 17 }; 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float instanceWeights[] = { 20, 10, 5, 1 }; 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int indexMins[] = { 0, 1, 3, 8 }; 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int indexMaxs[] = { 4, 8, 128, 257 }; 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float indexWeights[] = { 50, 50, 50, 50 }; 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int offsets[] = { 0, 1, 5, 12 }; 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float offsetWeights[] = { 50, 10, 10, 10 }; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int strides[] = { 0, 7, 16, 17 }; 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float strideWeights[] = { 50, 10, 10, 10 }; 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int instanceDivisors[] = { 0, 1, 3, 129 }; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float instanceDivisorWeights[]= { 70, 30, 10, 10 }; 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int indirectOffsets[] = { 0, 1, 2 }; 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float indirectOffsetWeigths[] = { 2, 1, 1 }; 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int baseVertices[] = { 0, 1, -2, 4, 3 }; 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float baseVertexWeigths[] = { 4, 1, 1, 1, 1 }; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Primitive primitives[] = 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_POINTS, 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLES, 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN, 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP, 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINES, 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_STRIP, 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::PRIMITIVE_LINE_LOOP 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(primitives)> primitiveWeights; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DrawMethod drawMethods[] = 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INDIRECT, 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INDIRECT, 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(drawMethods)> drawMethodWeights; 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::IndexType indexTypes[] = 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_BYTE, 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_SHORT, 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INDEXTYPE_INT, 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(indexTypes)> indexTypeWeights; 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::InputType inputTypes[] = 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_FLOAT, 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_FIXED, 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_BYTE, 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_SHORT, 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_BYTE, 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_SHORT, 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_INT, 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT, 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_HALF, 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_UNSIGNED_INT_2_10_10_10, 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::INPUTTYPE_INT_2_10_10_10, 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(inputTypes)> inputTypeWeights; 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OutputType outputTypes[] = 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_FLOAT, 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC2, 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC3, 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_VEC4, 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_INT, 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UINT, 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_IVEC2, 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_IVEC3, 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_IVEC4, 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UVEC2, 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UVEC3, 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::OUTPUTTYPE_UVEC4, 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(outputTypes)> outputTypeWeights; 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::Usage usages[] = 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_DRAW, 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_DRAW, 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_DRAW, 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_READ, 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STREAM_COPY, 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_READ, 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_STATIC_COPY, 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_READ, 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::USAGE_DYNAMIC_COPY, 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UniformWeightArray<DE_LENGTH_OF_ARRAY(usages)> usageWeights; 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::set<deUint32> insertedHashes; 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t insertedCount = 0; 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numAttempts; ++ndx) 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random random(0xc551393 + ndx); // random does not depend on previous cases 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int attributeCount = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(attribCounts), DE_ARRAY_END(attribCounts), attribWeights); 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int drawCommandSize; 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec spec; 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.apiType = glu::ApiType::es(3,1); 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitive = random.chooseWeighted<gls::DrawTestSpec::Primitive> (DE_ARRAY_BEGIN(primitives), DE_ARRAY_END(primitives), primitiveWeights.weights); 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.primitiveCount = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(primitiveCounts), DE_ARRAY_END(primitiveCounts), primitiveCountWeights); 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.drawMethod = random.chooseWeighted<gls::DrawTestSpec::DrawMethod> (DE_ARRAY_BEGIN(drawMethods), DE_ARRAY_END(drawMethods), drawMethodWeights.weights); 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWARRAYS_INDIRECT) 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommandSize = sizeof(deUint32[4]); 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_INDIRECT) 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawCommandSize = sizeof(deUint32[5]); 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexType = random.chooseWeighted<gls::DrawTestSpec::IndexType> (DE_ARRAY_BEGIN(indexTypes), DE_ARRAY_END(indexTypes), indexTypeWeights.weights); 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexPointerOffset = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexOffsets), DE_ARRAY_END(indexOffsets), indexOffsetWeights); 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexStorage = gls::DrawTestSpec::STORAGE_BUFFER; 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.first = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(firsts), DE_ARRAY_END(firsts), firstWeights); 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMin = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexMins), DE_ARRAY_END(indexMins), indexWeights); 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indexMax = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indexMaxs), DE_ARRAY_END(indexMaxs), indexWeights); 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.instanceCount = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(instanceCounts), DE_ARRAY_END(instanceCounts), instanceWeights); 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.indirectOffset = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(indirectOffsets), DE_ARRAY_END(indirectOffsets), indirectOffsetWeigths) * drawCommandSize; 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.baseVertex = random.chooseWeighted<int, const int*, const float*> (DE_ARRAY_BEGIN(baseVertices), DE_ARRAY_END(baseVertices), baseVertexWeigths); 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check spec is legal 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!spec.valid()) 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int attrNdx = 0; attrNdx < attributeCount;) 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool valid; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::DrawTestSpec::AttributeSpec attribSpec; 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.inputType = random.chooseWeighted<gls::DrawTestSpec::InputType> (DE_ARRAY_BEGIN(inputTypes), DE_ARRAY_END(inputTypes), inputTypeWeights.weights); 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.outputType = random.chooseWeighted<gls::DrawTestSpec::OutputType> (DE_ARRAY_BEGIN(outputTypes), DE_ARRAY_END(outputTypes), outputTypeWeights.weights); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.storage = gls::DrawTestSpec::STORAGE_BUFFER; 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.usage = random.chooseWeighted<gls::DrawTestSpec::Usage> (DE_ARRAY_BEGIN(usages), DE_ARRAY_END(usages), usageWeights.weights); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.componentCount = random.getInt(1, 4); 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.offset = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(offsets), DE_ARRAY_END(offsets), offsetWeights); 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.stride = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(strides), DE_ARRAY_END(strides), strideWeights); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.normalize = random.getBool(); 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.instanceDivisor = random.chooseWeighted<int, const int*, const float*>(DE_ARRAY_BEGIN(instanceDivisors), DE_ARRAY_END(instanceDivisors), instanceDivisorWeights); 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attribSpec.useDefaultAttribute = random.getBool(); 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check spec is legal 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry valid = attribSpec.valid(spec.apiType); 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // we do not want interleaved elements. (Might result in some weird floating point values) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (attribSpec.stride && attribSpec.componentCount * gls::DrawTestSpec::inputTypeSize(attribSpec.inputType) > attribSpec.stride) 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry valid = false; 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // try again if not valid 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (valid) 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs.push_back(attribSpec); 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++attrNdx; 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do not collapse all vertex positions to a single positions 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.attribs[0].instanceDivisor = 0; 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Is render result meaningful? 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only one vertex 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED && spec.indexMin == spec.indexMax && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].useDefaultAttribute && spec.primitive != gls::DrawTestSpec::PRIMITIVE_POINTS) 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Triangle only on one axis 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLES || spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_FAN || spec.primitive == gls::DrawTestSpec::PRIMITIVE_TRIANGLE_STRIP) 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.attribs[0].componentCount == 1) 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 5233c827367444ee418f129b2c238299f49d3264554Jarkko 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) 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.drawMethod == gls::DrawTestSpec::DRAWMETHOD_DRAWELEMENTS_RANGED && (spec.indexMax - spec.indexMin) < 2) 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Add case 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 hash = spec.hash(); 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int attrNdx = 0; attrNdx < attributeCount; ++attrNdx) 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry hash = (hash << 2) ^ (deUint32)spec.attribs[attrNdx].hash(); 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (insertedHashes.find(hash) == insertedHashes.end()) 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Only unaligned cases 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_OFFSET || 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.isCompatibilityTest() == gls::DrawTestSpec::COMPATIBILITY_UNALIGNED_STRIDE) 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry this->addChild(new gls::DrawTest(m_testCtx, m_context.getRenderContext(), spec, de::toString(insertedCount).c_str(), spec.getDesc().c_str())); 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry insertedHashes.insert(hash); 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++insertedCount; 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5523c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDrawTests::DrawTests (Context& context) 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "draw_indirect", "Indirect drawing tests") 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5573c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDrawTests::~DrawTests (void) 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DrawTests::init (void) 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const unalignedGroup = new tcu::TestCaseGroup(m_testCtx, "unaligned_data", "Test with unaligned data"); 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const drawArraysGroup = new tcu::TestCaseGroup(m_testCtx, "drawarrays", "draw arrays"); 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const drawElementsGroup = new tcu::TestCaseGroup(m_testCtx, "drawelements", "draw elements"); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(unalignedGroup); 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(drawArraysGroup); 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(drawElementsGroup); 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .unaligned_data 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new RandomGroup(m_context, "random", "random draw commands.")); 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .drawarrays 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawArraysGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_count", "Draw arrays vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_DATA_COUNT)); 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawArraysGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_first", "Draw arrays vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_DATA_FIRST)); 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawArraysGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_primcount", "Draw arrays vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_DATA_INSTANCED)); 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawArraysGroup->addChild(new InvalidDrawCase(m_context, "reserved_non_zero", "reservedMustBeZero is set to non-zero value", InvalidDrawCase::DRAW_ARRAYS, InvalidDrawCase::INVALID_RESERVED)); 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .drawelements 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_count", "Draw elements vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_DATA_COUNT)); 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_basevertex", "Draw elements vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_DATA_FIRST)); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_indices", "Draw elements vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_INDEX)); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "data_over_bounds_with_primcount", "Draw elements vertex elements beyond the array end are accessed", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_DATA_INSTANCED)); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "index_over_bounds_with_count", "Draw elements index elements beyond the array end are accessed", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_INDEX_COUNT)); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "index_over_bounds_with_firstindex", "Draw elements index elements beyond the array end are accessed", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_INDEX_FIRST)); 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawElementsGroup->addChild(new InvalidDrawCase(m_context, "reserved_non_zero", "reservedMustBeZero is set to non-zero value", InvalidDrawCase::DRAW_ELEMENTS, InvalidDrawCase::INVALID_RESERVED)); 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Stress 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp