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 Occlusion query stress tests 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3sOcclusionQueryTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deClock.h" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Stress 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const tcu::Vec4 OCCLUDER_COLOR = tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f); 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const tcu::Vec4 TARGET_COLOR = tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f); 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int NUM_CASE_ITERATIONS = 3; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int NUM_GENERATED_VERTICES = 100; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int WATCHDOG_INTERVAL = 50; // Touch watchdog every N iterations. 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass OcclusionQueryStressCase : public TestCase 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OcclusionQueryStressCase (Context& ctx, const char* name, const char* desc, int m_numOccluderDraws, int m_numOccludersPerDraw, int m_numTargetDraws, int m_numTargetsPerDraw, int m_numQueries, deUint32 m_queryMode); 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~OcclusionQueryStressCase (void); 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OcclusionQueryStressCase (const OcclusionQueryStressCase&); 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OcclusionQueryStressCase& operator= (const OcclusionQueryStressCase&); 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numOccluderDraws; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numOccludersPerDraw; 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numTargetDraws; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numTargetsPerDraw; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numQueries; 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_queryMode; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& m_renderCtx; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iterNdx; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random m_rnd; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko PoyryOcclusionQueryStressCase::OcclusionQueryStressCase (Context& ctx, const char* name, const char* desc, int numOccluderDraws, int numOccludersPerDraw, int numTargetDraws, int numTargetsPerDraw, int numQueries, deUint32 queryMode) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (ctx, name, desc) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numOccluderDraws (numOccluderDraws) 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numOccludersPerDraw (numOccludersPerDraw) 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numTargetDraws (numTargetDraws) 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numTargetsPerDraw (numTargetsPerDraw) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numQueries (numQueries) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_queryMode (queryMode) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (ctx.getRenderContext()) 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_program (DE_NULL) 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterNdx (0) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rnd (deStringHash(name)) 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 983c827367444ee418f129b2c238299f49d3264554Jarkko PoyryOcclusionQueryStressCase::~OcclusionQueryStressCase (void) 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry OcclusionQueryStressCase::deinit(); 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid OcclusionQueryStressCase::init (void) 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* vertShaderSource = 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n" 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) in mediump vec4 a_position;\n" 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\n" 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* fragShaderSource = 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n" 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 dEQP_FragColor;\n" 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "uniform mediump vec4 u_color;\n" 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\n" 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " mediump float depth_gradient = gl_FragCoord.z;\n" 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " mediump float bias = 0.1;\n" 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " dEQP_FragColor = vec4(u_color.xyz * (depth_gradient + bias), 1.0);\n" 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_program); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(vertShaderSource, fragShaderSource)); 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_program->isOk()) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *m_program; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Failed to compile shader program"); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // Initialize test result to pass. 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG ("Case initialization finished"); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid OcclusionQueryStressCase::deinit (void) 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_program; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = DE_NULL; 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryOcclusionQueryStressCase::IterateResult OcclusionQueryStressCase::iterate (void) 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorUnif = glGetUniformLocation(m_program->getProgram(), "u_color"); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> vertices; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> occluderVertices; 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> targetVertices; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> queryIds (m_numQueries, 0); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> queryResultReady (m_numQueries, 0); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> queryResult (m_numQueries, 0); 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string sectionName ("Case iteration " + de::toString(m_iterNdx+1) + "/" + de::toString(NUM_CASE_ITERATIONS)); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::ScopedLogSection section (log, sectionName.c_str(), sectionName.c_str()); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Message << "Parameters:\n" 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "- Number of occlusion queries: " << m_numQueries << ".\n" 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "- Number of occluder draws per query: " << m_numOccluderDraws << ", primitives per draw: " << m_numOccludersPerDraw << ".\n" 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "- Number of target draws per query: " << m_numTargetDraws << ", primitives per draw: " << m_numTargetsPerDraw << ".\n" 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numOccluderIndicesPerDraw = 3*m_numOccludersPerDraw; 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numTargetIndicesPerDraw = 3*m_numTargetsPerDraw; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Generate vertex data 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertices.resize(4*NUM_GENERATED_VERTICES); 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < NUM_GENERATED_VERTICES; i++) 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertices[4*i ] = m_rnd.getFloat(-1.0f, 1.0f); 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertices[4*i + 1] = m_rnd.getFloat(-1.0f, 1.0f); 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertices[4*i + 2] = m_rnd.getFloat(0.0f, 1.0f); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertices[4*i + 3] = 1.0f; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Generate primitives 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry occluderVertices.resize(4*numOccluderIndicesPerDraw * m_numOccluderDraws); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < numOccluderIndicesPerDraw * m_numOccluderDraws; i++) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int vtxNdx = m_rnd.getInt(0, NUM_GENERATED_VERTICES-1); 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry occluderVertices[4*i ] = vertices[4*vtxNdx]; 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry occluderVertices[4*i + 1] = vertices[4*vtxNdx + 1]; 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry occluderVertices[4*i + 2] = vertices[4*vtxNdx + 2]; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry occluderVertices[4*i + 3] = vertices[4*vtxNdx + 3]; 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetVertices.resize(4*numTargetIndicesPerDraw * m_numTargetDraws); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < numTargetIndicesPerDraw * m_numTargetDraws; i++) 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int vtxNdx = m_rnd.getInt(0, NUM_GENERATED_VERTICES-1); 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetVertices[4*i ] = vertices[4*vtxNdx]; 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetVertices[4*i + 1] = vertices[4*vtxNdx + 1]; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetVertices[4*i + 2] = vertices[4*vtxNdx + 2]; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetVertices[4*i + 3] = vertices[4*vtxNdx + 3]; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_CHECK(m_program); 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearColor (0.0f, 0.0f, 0.0f, 1.0f); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearDepthf (1.0f); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnable (GL_DEPTH_TEST); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glUseProgram (m_program->getProgram()); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnableVertexAttribArray (0); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 time = deGetMicroseconds(); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int queryIter = 0; queryIter < m_numQueries; queryIter++) 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw occluders 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glUniform4f (colorUnif, OCCLUDER_COLOR.x(), OCCLUDER_COLOR.y(), OCCLUDER_COLOR.z(), OCCLUDER_COLOR.w()); 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int drawIter = 0; drawIter < m_numOccluderDraws; drawIter++) 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glVertexAttribPointer (0, 4, GL_FLOAT, GL_FALSE, 0, &occluderVertices[drawIter * numOccluderIndicesPerDraw]); 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDrawArrays (GL_TRIANGLES, 0, numOccluderIndicesPerDraw); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Begin occlusion query 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenQueries (1, &queryIds[queryIter]); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBeginQuery (m_queryMode, queryIds[queryIter]); 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw targets 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glUniform4f (colorUnif, TARGET_COLOR.x(), TARGET_COLOR.y(), TARGET_COLOR.z(), TARGET_COLOR.w()); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int drawIter = 0; drawIter < m_numTargetDraws; drawIter++) 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glVertexAttribPointer (0, 4, GL_FLOAT, GL_FALSE, 0, &targetVertices[drawIter * numTargetIndicesPerDraw]); 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDrawArrays (GL_TRIANGLES, 0, numTargetIndicesPerDraw); 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // End occlusion query 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEndQuery (m_queryMode); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((queryIter % WATCHDOG_INTERVAL) == 0 && m_testCtx.getWatchDog()) 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry qpWatchDog_touch(m_testCtx.getWatchDog()); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFinish(); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDisable(GL_DEPTH_TEST); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 dTime = deGetMicroseconds() - time; 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Message << "Total duration: " << dTime/1000 << " ms" << tcu::TestLog::EndMessage; 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Get results 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int queryIter = 0; queryIter < m_numQueries; queryIter++) 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGetQueryObjectuiv(queryIds[queryIter], GL_QUERY_RESULT_AVAILABLE, &queryResultReady[queryIter]); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (queryResultReady[queryIter] == GL_TRUE) 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGetQueryObjectuiv(queryIds[queryIter], GL_QUERY_RESULT, &queryResult[queryIter]); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Occlusion query failed to return a result after glFinish()"); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((queryIter % WATCHDOG_INTERVAL) == 0 && m_testCtx.getWatchDog()) 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry qpWatchDog_touch(m_testCtx.getWatchDog()); 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteQueries (m_numQueries, &queryIds[0]); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG ("Occlusion queries finished"); 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Message << "Case passed!" << tcu::TestLog::EndMessage; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (++m_iterNdx < NUM_CASE_ITERATIONS) ? CONTINUE : STOP; 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2843c827367444ee418f129b2c238299f49d3264554Jarkko PoyryOcclusionQueryTests::OcclusionQueryTests (Context& testCtx) 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(testCtx, "occlusion_query", "Occlusion query stress tests") 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2893c827367444ee418f129b2c238299f49d3264554Jarkko PoyryOcclusionQueryTests::~OcclusionQueryTests(void) 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid OcclusionQueryTests::init (void) 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new OcclusionQueryStressCase(m_context, "10_queries_2500_triangles_per_query", "10_queries_2500_triangles_per_query", 49, 50, 1, 50, 10, GL_ANY_SAMPLES_PASSED)); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new OcclusionQueryStressCase(m_context, "100_queries_2500_triangles_per_query", "100_queries_2500_triangles_per_query", 49, 50, 1, 50, 100, GL_ANY_SAMPLES_PASSED)); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new OcclusionQueryStressCase(m_context, "1000_queries_500_triangles_per_query", "1000_queries_500_triangles_per_query", 49, 10, 1, 10, 1000, GL_ANY_SAMPLES_PASSED)); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new OcclusionQueryStressCase(m_context, "10000_queries_20_triangles_per_query", "10000_queries_20_triangles_per_query", 1, 19, 1, 1, 10000, GL_ANY_SAMPLES_PASSED)); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Stress 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 304