13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL (ES) 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 State change performance tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsStateChangePerfTestCases.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluDefs.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deClock.h" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm> 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::string; 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gls 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ResultStats 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double median; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double mean; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double variance; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 min; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 max; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 653c827367444ee418f129b2c238299f49d3264554Jarkko PoyryResultStats calculateStats (const vector<deUint64>& values) 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ResultStats result = { 0.0, 0.0, 0.0, 0xFFFFFFFFFFFFFFFFu, 0 }; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 sum = 0; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < (int)values.size(); i++) 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sum += values[i]; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.mean = ((double)sum) / values.size(); 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < (int)values.size(); i++) 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const double val = (double)values[i]; 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.variance += (val - result.mean) * (val - result.mean); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.variance /= values.size(); 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int n = (int)(values.size()/2); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<deUint64> sortedValues = values; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(sortedValues.begin(), sortedValues.end()); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.median = (double)sortedValues[n]; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < (int)values.size(); i++) 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.min = std::min(result.min, values[i]); 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.max = std::max(result.max, values[i]); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return result; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid genIndices (vector<GLushort>& indices, int triangleCount) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indices.reserve(triangleCount*3); 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int triangleNdx = 0; triangleNdx < triangleCount; triangleNdx++) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indices.push_back((GLushort)triangleNdx*3); 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indices.push_back((GLushort)triangleNdx*3+1); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indices.push_back((GLushort)triangleNdx*3+2); 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid genCoords (vector<GLfloat>& coords, int triangleCount) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.reserve(triangleCount * 3 * 2); 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int triangleNdx = 0; triangleNdx < triangleCount; triangleNdx++) 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((triangleNdx % 2) == 0) 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // CW 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back(-1.0f); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back(-1.0f); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back( 1.0f); 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back(-1.0f); 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back( 1.0f); 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back( 1.0f); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // CCW 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back(-1.0f); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back(-1.0f); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back(-1.0f); 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back( 1.0f); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back( 1.0f); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry coords.push_back( 1.0f); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid genTextureData (vector<deUint8>& data, int width, int height) 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data.clear(); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data.reserve(width*height*4); 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < width; x++) 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < height; y++) 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data.push_back((deUint8)((255*x)/width)); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data.push_back((deUint8)((255*y)/width)); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data.push_back((deUint8)((255*x*y)/(width*height))); 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry data.push_back(255); 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydouble calculateVariance (const vector<deUint64>& values, double avg) 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double sum = 0.0; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int valueNdx = 0; valueNdx < (int)values.size(); valueNdx++) 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double value = (double)values[valueNdx]; 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sum += (value - avg) * (value - avg); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sum / values.size(); 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1793c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint64 findMin (const vector<deUint64>& values) 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 min = ~0ull; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int valueNdx = 0; valueNdx < (int)values.size(); valueNdx++) 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry min = std::min(values[valueNdx], min); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return min; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1893c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint64 findMax (const vector<deUint64>& values) 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 max = 0; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int valueNdx = 0; valueNdx < (int)values.size(); valueNdx++) 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry max = std::max(values[valueNdx], max); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return max; 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1993c827367444ee418f129b2c238299f49d3264554Jarkko PoyrydeUint64 findMedian (const vector<deUint64>& v) 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<deUint64> values = v; 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size_t n = values.size() / 2; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::nth_element(values.begin(), values.begin() + n, values.end()); 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return values[n]; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStateChangePerformanceCase::StateChangePerformanceCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description, DrawType drawType, int drawCallCount, int triangleCount) 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : tcu::TestCase (testCtx, tcu::NODETYPE_PERFORMANCE, name, description) 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_drawType (drawType) 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (100) 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_callCount (drawCallCount) 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_triangleCount (triangleCount) 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStateChangePerformanceCase::~StateChangePerformanceCase (void) 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StateChangePerformanceCase::deinit(); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::init (void) 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawType == DRAWTYPE_INDEXED_USER_PTR) 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genIndices(m_indices, m_triangleCount); 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireIndexBuffers (int count) 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_indexBuffers.size() >= count) 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBuffers.reserve(count); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<GLushort> indices; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genIndices(indices, m_triangleCount); 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_indexBuffers.size() < count) 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint buffer; 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &buffer); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers()"); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer); 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)(indices.size() * sizeof(GLushort)), &(indices[0]), GL_STATIC_DRAW); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData()"); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBuffers.push_back(buffer); 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireCoordBuffers (int count) 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_coordBuffers.size() >= count) 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_coordBuffers.reserve(count); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<GLfloat> coords; 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genCoords(coords, m_triangleCount); 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_coordBuffers.size() < count) 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint buffer; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &buffer); 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenBuffers()"); 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, buffer); 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (GLsizeiptr)(coords.size() * sizeof(GLfloat)), &(coords[0]), GL_STATIC_DRAW); 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBufferData()"); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, 0); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindBuffer()"); 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_coordBuffers.push_back(buffer); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requirePrograms (int count) 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_programs.size() >= count) 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_programs.reserve(count); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_programs.size() < count) 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string vertexShaderSource = 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "attribute mediump vec2 a_coord;\n" 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "varying mediump vec2 v_texCoord;\n" 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\tv_texCoord = vec2(0.5) + 0.5" + de::toString(m_programs.size()) + " * a_coord.xy;\n" 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\tgl_Position = vec4(a_coord, 0.5, 1.0);\n" 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}"; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry string fragmentShaderSource = 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "uniform sampler2D u_sampler;\n" 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "varying mediump vec2 v_texCoord;\n" 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\tgl_FragColor = vec4(1.0" + de::toString(m_programs.size()) + " * texture2D(u_sampler, v_texCoord).xyz, 1.0);\n" 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}"; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* program = new glu::ShaderProgram(m_renderCtx, glu::ProgramSources() << glu::VertexSource(vertexShaderSource) << glu::FragmentSource(fragmentShaderSource)); 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!program->isOk()) 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *program; 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete program; 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Compile failed"); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_programs.push_back(program); 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireTextures (int count) 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int textureWidth = 64; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int textureHeight = 64; 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_textures.size() >= count) 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_textures.reserve(count); 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<deUint8> textureData; 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry genTextureData(textureData, textureWidth, textureHeight); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(textureData.size() == textureWidth * textureHeight * 4); 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_textures.size() < count) 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint texture; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genTextures(1, &texture); 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenTextures()"); 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, texture); 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, &(textureData[0])); 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glTexImage2D()"); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri()"); 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri()"); 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri()"); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glTexParameteri()"); 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, 0); 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindTexture()"); 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_textures.push_back(texture); 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireFramebuffers (int count) 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_framebuffers.size() >= count) 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_framebuffers.reserve(count); 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry requireRenderbuffers(count); 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_framebuffers.size() < count) 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint framebuffer; 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genFramebuffers(1, &framebuffer); 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenFramebuffers()"); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindFramebuffer(GL_FRAMEBUFFER, framebuffer); 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer()"); 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindRenderbuffer(GL_RENDERBUFFER, m_renderbuffers[m_framebuffers.size()]); 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer()"); 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_renderbuffers[m_framebuffers.size()]); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glFramebufferRenderbuffer()"); 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindRenderbuffer(GL_RENDERBUFFER, 0); 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer()"); 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindFramebuffer(GL_FRAMEBUFFER, 0); 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindFramebuffer()"); 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_framebuffers.push_back(framebuffer); 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireRenderbuffers (int count) 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_renderbuffers.size() >= count) 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderbuffers.reserve(count); 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_renderbuffers.size() < count) 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint renderbuffer; 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genRenderbuffers(1, &renderbuffer); 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenRenderbuffers()"); 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindRenderbuffer(GL_RENDERBUFFER, renderbuffer); 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer()"); 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGB565, 24, 24); 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glRenderbufferStorage()"); 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindRenderbuffer(GL_RENDERBUFFER, 0); 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glBindRenderbuffer()"); 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderbuffers.push_back(renderbuffer); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireSamplers (int count) 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_samplers.size() >= count) 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_samplers.reserve(count); 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_samplers.size() < count) 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint sampler; 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genSamplers(1, &sampler); 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenSamplers()"); 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_samplers.push_back(sampler); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::requireVertexArrays (int count) 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_vertexArrays.size() >= count) 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vertexArrays.reserve(count); 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while ((int)m_vertexArrays.size() < count) 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint vertexArray; 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genVertexArrays(1, &vertexArray); 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glGenVertexArrays()"); 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vertexArrays.push_back(vertexArray); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::deinit (void) 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indices.clear(); 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_interleavedResults.clear(); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_batchedResults.clear(); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_indexBuffers.empty()) 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers((GLsizei)m_indexBuffers.size(), &(m_indexBuffers[0])); 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBuffers.clear(); 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_coordBuffers.empty()) 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers((GLsizei)m_coordBuffers.size(), &(m_coordBuffers[0])); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_coordBuffers.clear(); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_textures.empty()) 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteTextures((GLsizei)m_textures.size(), &(m_textures[0])); 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_textures.clear(); 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_framebuffers.empty()) 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteFramebuffers((GLsizei)m_framebuffers.size(), &(m_framebuffers[0])); 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_framebuffers.clear(); 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_renderbuffers.empty()) 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteRenderbuffers((GLsizei)m_renderbuffers.size(), &(m_renderbuffers[0])); 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderbuffers.clear(); 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_samplers.empty()) 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteSamplers((GLsizei)m_samplers.size(), &m_samplers[0]); 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_samplers.clear(); 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_vertexArrays.empty()) 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteVertexArrays((GLsizei)m_vertexArrays.size(), &m_vertexArrays[0]); 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vertexArrays.clear(); 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int programNdx = 0; programNdx < (int)m_programs.size(); programNdx++) 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_programs[programNdx]; 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_programs[programNdx] = NULL; 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_programs.clear(); 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::logAndSetTestResult (void) 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ResultStats interleaved = calculateStats(m_interleavedResults); 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ResultStats batched = calculateStats(m_batchedResults); 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Interleaved mean: " << interleaved.mean << TestLog::EndMessage; 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Interleaved median: " << interleaved.median << TestLog::EndMessage; 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Interleaved variance: " << interleaved.variance << TestLog::EndMessage; 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Interleaved min: " << interleaved.min << TestLog::EndMessage; 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Interleaved max: " << interleaved.max << TestLog::EndMessage; 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched mean: " << batched.mean << TestLog::EndMessage; 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched median: " << batched.median << TestLog::EndMessage; 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched variance: " << batched.variance << TestLog::EndMessage; 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched min: " << batched.min << TestLog::EndMessage; 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched max: " << batched.max << TestLog::EndMessage; 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched/Interleaved mean ratio: " << (interleaved.mean/batched.mean) << TestLog::EndMessage; 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Batched/Interleaved median ratio: " << (interleaved.median/batched.median) << TestLog::EndMessage; 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString((float)(((double)interleaved.median) / batched.median), 2).c_str()); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::TestCase::IterateResult StateChangePerformanceCase::iterate (void) 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_interleavedResults.empty() && m_batchedResults.empty()) 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Draw call count: " << m_callCount << TestLog::EndMessage; 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Per call triangle count: " << m_triangleCount << TestLog::EndMessage; 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note [mika] Interleave sampling to balance effects of powerstate etc. 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_interleavedResults.size() < m_iterationCount && m_batchedResults.size() >= m_interleavedResults.size()) 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 resBeginUs = 0; 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 resEndUs = 0; 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupInitialState(gl); 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.finish(); 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish()"); 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render result 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resBeginUs = deGetMicroseconds(); 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderTest(gl); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.finish(); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry resEndUs = deGetMicroseconds(); 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish()"); 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_interleavedResults.push_back(resEndUs - resBeginUs); 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if ((int)m_batchedResults.size() < m_iterationCount) 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 refBeginUs = 0; 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 refEndUs = 0; 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupInitialState(gl); 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.finish(); 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish()"); 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refBeginUs = deGetMicroseconds(); 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderReference(gl); 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.finish(); 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refEndUs = deGetMicroseconds(); 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "glFinish()"); 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_batchedResults.push_back(refEndUs - refBeginUs); 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAndSetTestResult(); 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangePerformanceCase::callDraw (const glw::Functions& gl) 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_drawType) 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case DRAWTYPE_NOT_INDEXED: gl.drawArrays(GL_TRIANGLES, 0, m_triangleCount * 3); break; 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case DRAWTYPE_INDEXED_USER_PTR: gl.drawElements(GL_TRIANGLES, m_triangleCount * 3, GL_UNSIGNED_SHORT, &m_indices[0]); break; 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case DRAWTYPE_INDEXED_BUFFER: gl.drawElements(GL_TRIANGLES, m_triangleCount * 3, GL_UNSIGNED_SHORT, NULL); break; 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// StateChangeCallPerformanceCase 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStateChangeCallPerformanceCase::StateChangeCallPerformanceCase (tcu::TestContext& testCtx, glu::RenderContext& renderCtx, const char* name, const char* description) 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : tcu::TestCase (testCtx, tcu::NODETYPE_PERFORMANCE, name, description) 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderCtx (renderCtx) 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (100) 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_callCount (1000) 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6503c827367444ee418f129b2c238299f49d3264554Jarkko PoyryStateChangeCallPerformanceCase::~StateChangeCallPerformanceCase (void) 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangeCallPerformanceCase::executeTest (void) 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 beginTimeUs = 0; 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTimeUs = 0; 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry beginTimeUs = deGetMicroseconds(); 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry execCalls(gl, (int)m_results.size(), m_callCount); 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTimeUs = deGetMicroseconds(); 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.push_back(endTimeUs - beginTimeUs); 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangeCallPerformanceCase::logTestCase (void) 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Iteration count: " << m_iterationCount << TestLog::EndMessage; 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Per iteration call count: " << m_callCount << TestLog::EndMessage; 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrydouble calculateAverage (const vector<deUint64>& values) 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 sum = 0; 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int valueNdx = 0; valueNdx < (int)values.size(); valueNdx++) 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sum += values[valueNdx]; 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ((double)sum) / values.size(); 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid StateChangeCallPerformanceCase::logAndSetTestResult (void) 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 minUs = findMin(m_results); 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 maxUs = findMax(m_results); 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 medianUs = findMedian(m_results); 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double avgIterationUs = calculateAverage(m_results); 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double avgCallUs = avgIterationUs / m_callCount; 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double varIteration = calculateVariance(m_results, avgIterationUs); 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry double avgMedianCallUs = ((double)medianUs)/m_callCount; 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Min iteration time: " << minUs << "us" << TestLog::EndMessage; 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Max iteration time: " << maxUs << "us" << TestLog::EndMessage; 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Average iteration time: " << avgIterationUs << "us" << TestLog::EndMessage; 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Iteration variance time: " << varIteration << TestLog::EndMessage; 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Median iteration time: " << medianUs << "us" << TestLog::EndMessage; 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Average call time: " << avgCallUs << "us" << TestLog::EndMessage; 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Average call time for median iteration: " << avgMedianCallUs << "us" << TestLog::EndMessage; 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString((float)avgMedianCallUs, 3).c_str()); 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::TestCase::IterateResult StateChangeCallPerformanceCase::iterate (void) 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_results.empty()) 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logTestCase(); 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((int)m_results.size() < m_iterationCount) 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry executeTest(); 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(m_renderCtx.getFunctions().getError(), "Unexpected error"); 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAndSetTestResult(); 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gls 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 730