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 Buffer data upload performance tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3pBufferDataUploadTests.hpp" 258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "glsCalibration.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCPUWarmup.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluObjectWrapper.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deClock.h" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMemory.h" 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deThread.h" 446b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyry#include "deMeta.hpp" 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm> 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <iomanip> 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <limits> 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Performance 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing gls::theilSenSiegelLinearRegression; 608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing gls::LineParametersWithConfidence; 616b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyryusing de::meta::EnableIf; 626b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyryusing de::meta::Not; 638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_dummyVertexShader = "#version 300 es\n" 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_position;\n" 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_dummyFragnentShader = "#version 300 es\n" 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 dEQP_FragColor;\n" 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " dEQP_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n" 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_colorVertexShader = "#version 300 es\n" 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_position;\n" 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_color;\n" 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "out highp vec4 v_color;\n" 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " v_color = a_color;\n" 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_colorFragmentShader = "#version 300 es\n" 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 dEQP_FragColor;\n" 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in mediump vec4 v_color;\n" 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " dEQP_FragColor = v_color;\n" 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SingleOperationDuration 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; // used for fitting 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct MapBufferRangeDuration 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 mapDuration; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 unmapDuration; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 writeDuration; 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 allocDuration; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct MapBufferRangeDurationNoAlloc 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 mapDuration; 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 unmapDuration; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 writeDuration; 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct MapBufferRangeFlushDuration 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 mapDuration; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 unmapDuration; 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 writeDuration; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 flushDuration; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 allocDuration; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct MapBufferRangeFlushDurationNoAlloc 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 mapDuration; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 unmapDuration; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 writeDuration; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 flushDuration; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderReadDuration 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderDuration; 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 readDuration; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderReadDuration; 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UnrelatedUploadRenderReadDuration 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderDuration; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 readDuration; 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderReadDuration; 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UploadRenderReadDuration 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 uploadDuration; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderDuration; 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 readDuration; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderReadDuration; 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UploadRenderReadDurationWithUnrelatedUploadSize 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 uploadDuration; 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderDuration; 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 readDuration; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderReadDuration; 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderUploadRenderReadDuration 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 firstRenderDuration; 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 uploadDuration; 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 secondRenderDuration; 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 readDuration; 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalDuration; 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderReadDuration; 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 fitResponseDuration; 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleT> 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UploadSampleResult 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef SampleT SampleType; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bufferSize; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int allocatedSize; 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int writtenSize; 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SampleType duration; 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleT> 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderSampleResult 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef SampleT SampleType; 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int uploadedDataSize; 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int renderDataSize; 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int unrelatedDataSize; 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numVertices; 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SampleT duration; 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SingleOperationStatistics 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float minTime; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxTime; 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianTime; 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float min2DecileTime; // !< minimum value in the 2nd decile 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileTime; // !< maximum value in the 9th decile 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SingleCallStatistics 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics result; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRate; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiffTime; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiff9DecileTime; 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianDiffTime; 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxRelDiffTime; 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileRelDiffTime; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRelDiffTime; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct MapCallStatistics 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics map; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics unmap; 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics write; 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics alloc; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics result; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRate; 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiffTime; 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiff9DecileTime; 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianDiffTime; 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxRelDiffTime; 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileRelDiffTime; 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRelDiffTime; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct MapFlushCallStatistics 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics map; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics unmap; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics write; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics flush; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics alloc; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics result; 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRate; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiffTime; 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiff9DecileTime; 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianDiffTime; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxRelDiffTime; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileRelDiffTime; 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRelDiffTime; 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderReadStatistics 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics render; 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics read; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics result; 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics total; 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRate; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiffTime; 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiff9DecileTime; 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianDiffTime; 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxRelDiffTime; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileRelDiffTime; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRelDiffTime; 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UploadRenderReadStatistics 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics upload; 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics render; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics read; 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics result; 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics total; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRate; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiffTime; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiff9DecileTime; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianDiffTime; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxRelDiffTime; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileRelDiffTime; 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRelDiffTime; 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderUploadRenderReadStatistics 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics firstRender; 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics upload; 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics secondRender; 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics read; 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics result; 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics total; 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRate; 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiffTime; 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxDiff9DecileTime; 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianDiffTime; 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float maxRelDiffTime; 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float max9DecileRelDiffTime; 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float medianRelDiffTime; 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<SingleOperationDuration> 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef SingleCallStatistics StatsType; 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_MAP_STATS = 0 }; 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UNMAP_STATS = 0 }; 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_WRITE_STATS = 0 }; 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FLUSH_STATS = 0 }; 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_ALLOC_STATS = 0 }; 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 0 }; 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<MapBufferRangeDuration> 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef MapCallStatistics StatsType; 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_MAP_STATS = 1 }; 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UNMAP_STATS = 1 }; 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_WRITE_STATS = 1 }; 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FLUSH_STATS = 0 }; 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_ALLOC_STATS = 1 }; 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<MapBufferRangeDurationNoAlloc> 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef MapCallStatistics StatsType; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_MAP_STATS = 1 }; 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UNMAP_STATS = 1 }; 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_WRITE_STATS = 1 }; 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FLUSH_STATS = 0 }; 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_ALLOC_STATS = 0 }; 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<MapBufferRangeFlushDuration> 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef MapFlushCallStatistics StatsType; 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_MAP_STATS = 1 }; 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UNMAP_STATS = 1 }; 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_WRITE_STATS = 1 }; 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FLUSH_STATS = 1 }; 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_ALLOC_STATS = 1 }; 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<MapBufferRangeFlushDurationNoAlloc> 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef MapFlushCallStatistics StatsType; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_MAP_STATS = 1 }; 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UNMAP_STATS = 1 }; 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_WRITE_STATS = 1 }; 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FLUSH_STATS = 1 }; 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_ALLOC_STATS = 0 }; 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<RenderReadDuration> 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef RenderReadStatistics StatsType; 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_RENDER_STATS = 1 }; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_READ_STATS = 1 }; 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UPLOAD_STATS = 0 }; 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_TOTAL_STATS = 1 }; 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FIRST_RENDER_STATS = 0 }; 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_SECOND_RENDER_STATS = 0 }; 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<UnrelatedUploadRenderReadDuration> 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef RenderReadStatistics StatsType; 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_RENDER_STATS = 1 }; 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_READ_STATS = 1 }; 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UPLOAD_STATS = 0 }; 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_TOTAL_STATS = 1 }; 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FIRST_RENDER_STATS = 0 }; 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_SECOND_RENDER_STATS = 0 }; 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<UploadRenderReadDuration> 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef UploadRenderReadStatistics StatsType; 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_RENDER_STATS = 1 }; 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_READ_STATS = 1 }; 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UPLOAD_STATS = 1 }; 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_TOTAL_STATS = 1 }; 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FIRST_RENDER_STATS = 0 }; 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_SECOND_RENDER_STATS = 0 }; 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_UNRELATED_UPLOAD_SIZE = 0 }; 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<UploadRenderReadDurationWithUnrelatedUploadSize> 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef UploadRenderReadStatistics StatsType; 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_RENDER_STATS = 1 }; 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_READ_STATS = 1 }; 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UPLOAD_STATS = 1 }; 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_TOTAL_STATS = 1 }; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FIRST_RENDER_STATS = 0 }; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_SECOND_RENDER_STATS = 0 }; 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_UNRELATED_UPLOAD_SIZE = 1 }; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <> 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct SampleTypeTraits<RenderUploadRenderReadDuration> 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef RenderUploadRenderReadStatistics StatsType; 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_RENDER_STATS = 0 }; 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_READ_STATS = 1 }; 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_UPLOAD_STATS = 1 }; 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_TOTAL_STATS = 1 }; 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_FIRST_RENDER_STATS = 1 }; 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { HAS_SECOND_RENDER_STATS = 1 }; 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_CONTRIBUTIONS = 1 }; 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum { LOG_UNRELATED_UPLOAD_SIZE = 1 }; 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct UploadSampleAnalyzeResult 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float transferRateMedian; 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float transferRateAtRange; 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float transferRateAtInfinity; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct RenderSampleAnalyzeResult 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float renderRateMedian; 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float renderRateAtRange; 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float renderRateAtInfinity; 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UnmapFailureError : public std::exception 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UnmapFailureError (void) : std::exception() {} 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic std::string getHumanReadableByteSize (int numBytes) 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream buf; 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (numBytes < 1024) 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << numBytes << " byte(s)"; 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (numBytes < 1024 * 1024) 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << de::floatToString(numBytes/1024.0f, 1) << " KiB"; 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << de::floatToString(numBytes/1024.0f/1024.0f, 1) << " MiB"; 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return buf.str(); 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic deUint64 medianTimeMemcpy (void* dst, const void* src, int numBytes) 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Time used by memcpy is assumed to be asymptotically linear 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // With large numBytes, the probability of context switch or other random 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // event is high. Apply memcpy in parts and report how much time would 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // memcpy have used with the median transfer rate. 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Less than 1MiB, no need to do anything special 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (numBytes < 1048576) 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy(dst, src, numBytes); 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return endTime - startTime; 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do memcpy in multiple parts 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numSections = 5; 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int sectionAlign = 16; 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int sectionStarts[numSections+1]; 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int sectionLens[numSections]; 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 sectionTimes[numSections]; 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 medianTime; 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 bestTime = 0; 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sectionNdx = 0; sectionNdx < numSections; ++sectionNdx) 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sectionStarts[sectionNdx] = deAlign32((numBytes * sectionNdx / numSections), sectionAlign); 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sectionStarts[numSections] = numBytes; 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sectionNdx = 0; sectionNdx < numSections; ++sectionNdx) 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sectionLens[sectionNdx] = sectionStarts[sectionNdx+1] - sectionStarts[sectionNdx]; 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Memcpy is usually called after mapbuffer range which may take 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // a lot of time. To prevent power management from kicking in during 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // copy, warm up more. 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sectionNdx = 0; sectionNdx < numSections; ++sectionNdx) 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy((deUint8*)dst + sectionStarts[sectionNdx], (const deUint8*)src + sectionStarts[sectionNdx], sectionLens[sectionNdx]); 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sectionTimes[sectionNdx] = endTime - startTime; 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!bestTime || sectionTimes[sectionNdx] < bestTime) 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bestTime = sectionTimes[sectionNdx]; 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Detect if write takes 50% longer than it should, and warm up if that happened 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (sectionNdx != numSections-1 && (float)sectionTimes[sectionNdx] > 1.5f * bestTime) 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(sectionTimes, sectionTimes + numSections); 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((numSections % 2) == 0) 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry medianTime = (sectionTimes[numSections / 2 - 1] + sectionTimes[numSections / 2]) / 2; 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry medianTime = sectionTimes[numSections / 2]; 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return medianTime*numSections; 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float dummyCalculation (float initial, int workSize) 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float a = initial; 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int b = 123; 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < workSize; ++ndx) 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry a = deFloatCos(a + (float)b); 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry b = (b + 63) % 107 + de::abs((int)(a*10.0f)); 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return a + (float)b; 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void busyWait (int microseconds) 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 maxSingleWaitTime = 1000; // 1ms 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 endTime = deGetMicroseconds() + microseconds; 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float dummy = *tcu::warmupCPUInternal::g_dummy.m_v; 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int workSize = 500; 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // exponentially increase work, cap to 1ms 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (deGetMicroseconds() < endTime) 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 startTime = deGetMicroseconds(); 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 totalTime; 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dummy = dummyCalculation(dummy, workSize); 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry totalTime = deGetMicroseconds() - startTime; 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (totalTime >= maxSingleWaitTime) 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry workSize *= 2; 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // "wait" 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry while (deGetMicroseconds() < endTime) 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dummy = dummyCalculation(dummy, workSize); 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *tcu::warmupCPUInternal::g_dummy.m_v = dummy; 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Sample from given values using linear interpolation at a given position as if values were laid to range [0, 1] 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float linearSample (const std::vector<T>& values, float position) 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(position >= 0.0f); 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(position <= 1.0f); 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float floatNdx = ((int)values.size() - 1) * position; 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int lowerNdx = (int)deFloatFloor(floatNdx); 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int higherNdx = lowerNdx + 1; 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float interpolationFactor = floatNdx - (float)lowerNdx; 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(lowerNdx >= 0 && lowerNdx < (int)values.size()); 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(higherNdx >= 0 && higherNdx < (int)values.size()); 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(interpolationFactor >= 0 && interpolationFactor < 1.0f); 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return tcu::mix((float)values[lowerNdx], (float)values[higherNdx], interpolationFactor); 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 6683c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleOperationStatistics calculateSingleOperationStatistics (const std::vector<T>& samples, deUint64 T::SampleType::*target) 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleOperationStatistics stats; 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint64> values(samples.size()); 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)samples.size(); ++ndx) 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry values[ndx] = samples[ndx].duration.*target; 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(values.begin(), values.end()); 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.minTime = (float)values.front(); 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.maxTime = (float)values.back(); 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.medianTime = linearSample(values, 0.5f); 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.min2DecileTime = linearSample(values, 0.1f); 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.max9DecileTime = linearSample(values, 0.9f); 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename StatisticsType, typename SampleType> 6888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid calculateBasicStatistics (StatisticsType& stats, const LineParametersWithConfidence& fit, const std::vector<SampleType>& samples, int SampleType::*predictor) 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint64> values(samples.size()); 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)samples.size(); ++ndx) 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry values[ndx] = samples[ndx].duration.fitResponseDuration; 6943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // median rate 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> processingRates(samples.size()); 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)samples.size(); ++ndx) 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float timeInSeconds = values[ndx] / 1000.0f / 1000.0f; 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry processingRates[ndx] = samples[ndx].*predictor / timeInSeconds; 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(processingRates.begin(), processingRates.end()); 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.medianRate = linearSample(processingRates, 0.5f); 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // results compared to the approximation 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> timeDiffs(samples.size()); 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)samples.size(); ++ndx) 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float prediction = samples[ndx].*predictor * fit.coefficient + fit.offset; 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float actual = (float)values[ndx]; 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry timeDiffs[ndx] = actual - prediction; 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(timeDiffs.begin(), timeDiffs.end()); 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.maxDiffTime = timeDiffs.back(); 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.maxDiff9DecileTime = linearSample(timeDiffs, 0.9f); 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.medianDiffTime = linearSample(timeDiffs, 0.5f); 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // relative comparison to the approximation 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> relativeDiffs(samples.size()); 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)samples.size(); ++ndx) 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float prediction = samples[ndx].*predictor * fit.coefficient + fit.offset; 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float actual = (float)values[ndx]; 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Ignore cases where we predict negative times, or if 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ratio would be (nearly) infinite: ignore if predicted 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // time is less than 1 microsecond 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (prediction < 1.0f) 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry relativeDiffs[ndx] = 0.0f; 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry relativeDiffs[ndx] = (actual - prediction) / prediction; 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(relativeDiffs.begin(), relativeDiffs.end()); 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.maxRelDiffTime = relativeDiffs.back(); 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.max9DecileRelDiffTime = linearSample(relativeDiffs, 0.9f); 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.medianRelDiffTime = linearSample(relativeDiffs, 0.5f); 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // values calculated using sorted timings 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(values.begin(), values.end()); 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.result.minTime = (float)values.front(); 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.result.maxTime = (float)values.back(); 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.result.medianTime = linearSample(values, 0.5f); 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.result.min2DecileTime = linearSample(values, 0.1f); 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.result.max9DecileTime = linearSample(values, 0.9f); 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename StatisticsType, typename SampleType> 7638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid calculateBasicTransferStatistics (StatisticsType& stats, const LineParametersWithConfidence& fit, const std::vector<SampleType>& samples) 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicStatistics(stats, fit, samples, &SampleType::writtenSize); 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename StatisticsType, typename SampleType> 7698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid calculateBasicRenderStatistics (StatisticsType& stats, const LineParametersWithConfidence& fit, const std::vector<SampleType>& samples) 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicStatistics(stats, fit, samples, &SampleType::renderDataSize); 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic SingleCallStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<UploadSampleResult<SingleOperationDuration> >& samples) 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleCallStatistics stats; 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicTransferStatistics(stats, fit, samples); 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic MapCallStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<UploadSampleResult<MapBufferRangeDuration> >& samples) 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapCallStatistics stats; 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicTransferStatistics(stats, fit, samples); 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.map = calculateSingleOperationStatistics(samples, &MapBufferRangeDuration::mapDuration); 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.unmap = calculateSingleOperationStatistics(samples, &MapBufferRangeDuration::unmapDuration); 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.write = calculateSingleOperationStatistics(samples, &MapBufferRangeDuration::writeDuration); 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.alloc = calculateSingleOperationStatistics(samples, &MapBufferRangeDuration::allocDuration); 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic MapFlushCallStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<UploadSampleResult<MapBufferRangeFlushDuration> >& samples) 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapFlushCallStatistics stats; 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicTransferStatistics(stats, fit, samples); 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.map = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDuration::mapDuration); 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.unmap = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDuration::unmapDuration); 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.write = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDuration::writeDuration); 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.flush = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDuration::flushDuration); 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.alloc = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDuration::allocDuration); 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic MapCallStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<UploadSampleResult<MapBufferRangeDurationNoAlloc> >& samples) 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapCallStatistics stats; 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicTransferStatistics(stats, fit, samples); 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.map = calculateSingleOperationStatistics(samples, &MapBufferRangeDurationNoAlloc::mapDuration); 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.unmap = calculateSingleOperationStatistics(samples, &MapBufferRangeDurationNoAlloc::unmapDuration); 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.write = calculateSingleOperationStatistics(samples, &MapBufferRangeDurationNoAlloc::writeDuration); 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic MapFlushCallStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<UploadSampleResult<MapBufferRangeFlushDurationNoAlloc> >& samples) 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapFlushCallStatistics stats; 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicTransferStatistics(stats, fit, samples); 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.map = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDurationNoAlloc::mapDuration); 8323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.unmap = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDurationNoAlloc::unmapDuration); 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.write = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDurationNoAlloc::writeDuration); 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.flush = calculateSingleOperationStatistics(samples, &MapBufferRangeFlushDurationNoAlloc::flushDuration); 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic RenderReadStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<RenderSampleResult<RenderReadDuration> >& samples) 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderReadStatistics stats; 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicRenderStatistics(stats, fit, samples); 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.render = calculateSingleOperationStatistics(samples, &RenderReadDuration::renderDuration); 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.read = calculateSingleOperationStatistics(samples, &RenderReadDuration::readDuration); 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.total = calculateSingleOperationStatistics(samples, &RenderReadDuration::totalDuration); 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic RenderReadStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<RenderSampleResult<UnrelatedUploadRenderReadDuration> >& samples) 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderReadStatistics stats; 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicRenderStatistics(stats, fit, samples); 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.render = calculateSingleOperationStatistics(samples, &UnrelatedUploadRenderReadDuration::renderDuration); 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.read = calculateSingleOperationStatistics(samples, &UnrelatedUploadRenderReadDuration::readDuration); 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.total = calculateSingleOperationStatistics(samples, &UnrelatedUploadRenderReadDuration::totalDuration); 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic UploadRenderReadStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<RenderSampleResult<UploadRenderReadDuration> >& samples) 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadRenderReadStatistics stats; 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicRenderStatistics(stats, fit, samples); 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.upload = calculateSingleOperationStatistics(samples, &UploadRenderReadDuration::uploadDuration); 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.render = calculateSingleOperationStatistics(samples, &UploadRenderReadDuration::renderDuration); 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.read = calculateSingleOperationStatistics(samples, &UploadRenderReadDuration::readDuration); 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.total = calculateSingleOperationStatistics(samples, &UploadRenderReadDuration::totalDuration); 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic UploadRenderReadStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<RenderSampleResult<UploadRenderReadDurationWithUnrelatedUploadSize> >& samples) 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadRenderReadStatistics stats; 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicRenderStatistics(stats, fit, samples); 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.upload = calculateSingleOperationStatistics(samples, &UploadRenderReadDurationWithUnrelatedUploadSize::uploadDuration); 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.render = calculateSingleOperationStatistics(samples, &UploadRenderReadDurationWithUnrelatedUploadSize::renderDuration); 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.read = calculateSingleOperationStatistics(samples, &UploadRenderReadDurationWithUnrelatedUploadSize::readDuration); 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.total = calculateSingleOperationStatistics(samples, &UploadRenderReadDurationWithUnrelatedUploadSize::totalDuration); 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic RenderUploadRenderReadStatistics calculateSampleStatistics (const LineParametersWithConfidence& fit, const std::vector<RenderSampleResult<RenderUploadRenderReadDuration> >& samples) 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderUploadRenderReadStatistics stats; 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry calculateBasicRenderStatistics(stats, fit, samples); 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.firstRender = calculateSingleOperationStatistics(samples, &RenderUploadRenderReadDuration::firstRenderDuration); 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.upload = calculateSingleOperationStatistics(samples, &RenderUploadRenderReadDuration::uploadDuration); 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.secondRender = calculateSingleOperationStatistics(samples, &RenderUploadRenderReadDuration::secondRenderDuration); 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.read = calculateSingleOperationStatistics(samples, &RenderUploadRenderReadDuration::readDuration); 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry stats.total = calculateSingleOperationStatistics(samples, &RenderUploadRenderReadDuration::totalDuration); 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return stats; 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 9098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic LineParametersWithConfidence fitLineToSamples (const std::vector<UploadSampleResult<DurationType> >& samples, int beginNdx, int endNdx, int step, deUint64 DurationType::*target = &DurationType::fitResponseDuration) 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec2> samplePoints; 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = beginNdx; sampleNdx < endNdx; sampleNdx += step) 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec2 point; 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry point.x() = (float)(samples[sampleNdx].writtenSize); 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry point.y() = (float)(samples[sampleNdx].duration.*target); 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry samplePoints.push_back(point); 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return theilSenSiegelLinearRegression(samplePoints, 0.6f); 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 9278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic LineParametersWithConfidence fitLineToSamples (const std::vector<RenderSampleResult<DurationType> >& samples, int beginNdx, int endNdx, int step, deUint64 DurationType::*target = &DurationType::fitResponseDuration) 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec2> samplePoints; 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = beginNdx; sampleNdx < endNdx; sampleNdx += step) 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec2 point; 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry point.x() = (float)(samples[sampleNdx].renderDataSize); 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry point.y() = (float)(samples[sampleNdx].duration.*target); 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry samplePoints.push_back(point); 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return theilSenSiegelLinearRegression(samplePoints, 0.6f); 9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 9458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic LineParametersWithConfidence fitLineToSamples (const std::vector<T>& samples, int beginNdx, int endNdx, deUint64 T::SampleType::*target = &T::SampleType::fitResponseDuration) 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return fitLineToSamples(samples, beginNdx, endNdx, 1, target); 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 9518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystatic LineParametersWithConfidence fitLineToSamples (const std::vector<T>& samples, deUint64 T::SampleType::*target = &T::SampleType::fitResponseDuration) 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return fitLineToSamples(samples, 0, (int)samples.size(), target); 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float getAreaBetweenLines (float xmin, float xmax, float lineAOffset, float lineACoefficient, float lineBOffset, float lineBCoefficient) 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float lineAMin = lineAOffset + lineACoefficient * xmin; 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float lineAMax = lineAOffset + lineACoefficient * xmax; 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float lineBMin = lineBOffset + lineBCoefficient * xmin; 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float lineBMax = lineBOffset + lineBCoefficient * xmax; 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool aOverBAtBegin = (lineAMin > lineBMin); 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool aOverBAtEnd = (lineAMax > lineBMax); 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (aOverBAtBegin == aOverBAtEnd) 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // lines do not intersect 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float midpoint = (xmin + xmax) / 2.0f; 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float width = (xmax - xmin); 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float lineAHeight = lineAOffset + lineACoefficient * midpoint; 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float lineBHeight = lineBOffset + lineBCoefficient * midpoint; 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return width * de::abs(lineAHeight - lineBHeight); 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 9783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // lines intersect 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float approachCoeffient = de::abs(lineACoefficient - lineBCoefficient); 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float epsilon = 0.0001f; 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float leftHeight = de::abs(lineAMin - lineBMin); 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float rightHeight = de::abs(lineAMax - lineBMax); 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (approachCoeffient < epsilon) 9883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return 0.0f; 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (0.5f * leftHeight * (leftHeight / approachCoeffient)) + (0.5f * rightHeight * (rightHeight / approachCoeffient)); 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float calculateSampleFitLinearity (const std::vector<T>& samples, int T::*predictor) 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare the fitted line of first half of the samples to the fitted line of 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // the second half of the samples. Calculate a AABB that fully contains every 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // sample's x component and both fit lines in this range. Calculate the ratio 10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // of the area between the lines and the AABB. 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float epsilon = 1.e-6f; 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int midPoint = (int)samples.size() / 2; 10048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence startApproximation = fitLineToSamples(samples, 0, midPoint, &T::SampleType::fitResponseDuration); 10058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence endApproximation = fitLineToSamples(samples, midPoint, (int)samples.size(), &T::SampleType::fitResponseDuration); 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMinX = (float)(samples.front().*predictor); 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMinY = de::min(startApproximation.offset + startApproximation.coefficient*aabbMinX, endApproximation.offset + endApproximation.coefficient*aabbMinX); 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMaxX = (float)(samples.back().*predictor); 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMaxY = de::max(startApproximation.offset + startApproximation.coefficient*aabbMaxX, endApproximation.offset + endApproximation.coefficient*aabbMaxX); 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbArea = (aabbMaxX - aabbMinX) * (aabbMaxY - aabbMinY); 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float areaBetweenLines = getAreaBetweenLines(aabbMinX, aabbMaxX, startApproximation.offset, startApproximation.coefficient, endApproximation.offset, endApproximation.coefficient); 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float errorAreaRatio = (aabbArea < epsilon) ? (1.0f) : (areaBetweenLines / aabbArea); 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return de::clamp(1.0f - errorAreaRatio, 0.0f, 1.0f); 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float calculateSampleFitLinearity (const std::vector<UploadSampleResult<DurationType> >& samples) 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return calculateSampleFitLinearity(samples, &UploadSampleResult<DurationType>::writtenSize); 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float calculateSampleFitLinearity (const std::vector<RenderSampleResult<DurationType> >& samples) 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return calculateSampleFitLinearity(samples, &RenderSampleResult<DurationType>::renderDataSize); 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float calculateSampleTemporalStability (const std::vector<T>& samples, int T::*predictor) 10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Samples are sampled in the following order: 1) even samples (in random order) 2) odd samples (in random order) 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare the fitted line of even samples to the fitted line of the odd samples. Calculate a AABB that fully 10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // contains every sample's x component and both fit lines in this range. Calculate the ratio of the area between 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // the lines and the AABB. 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float epsilon = 1.e-6f; 10408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence evenApproximation = fitLineToSamples(samples, 0, (int)samples.size(), 2, &T::SampleType::fitResponseDuration); 10418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence oddApproximation = fitLineToSamples(samples, 1, (int)samples.size(), 2, &T::SampleType::fitResponseDuration); 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMinX = (float)(samples.front().*predictor); 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMinY = de::min(evenApproximation.offset + evenApproximation.coefficient*aabbMinX, oddApproximation.offset + oddApproximation.coefficient*aabbMinX); 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMaxX = (float)(samples.back().*predictor); 10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbMaxY = de::max(evenApproximation.offset + evenApproximation.coefficient*aabbMaxX, oddApproximation.offset + oddApproximation.coefficient*aabbMaxX); 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float aabbArea = (aabbMaxX - aabbMinX) * (aabbMaxY - aabbMinY); 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float areaBetweenLines = getAreaBetweenLines(aabbMinX, aabbMaxX, evenApproximation.offset, evenApproximation.coefficient, oddApproximation.offset, oddApproximation.coefficient); 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float errorAreaRatio = (aabbArea < epsilon) ? (1.0f) : (areaBetweenLines / aabbArea); 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return de::clamp(1.0f - errorAreaRatio, 0.0f, 1.0f); 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float calculateSampleTemporalStability (const std::vector<UploadSampleResult<DurationType> >& samples) 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return calculateSampleTemporalStability(samples, &UploadSampleResult<DurationType>::writtenSize); 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float calculateSampleTemporalStability (const std::vector<RenderSampleResult<DurationType> >& samples) 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return calculateSampleTemporalStability(samples, &RenderSampleResult<DurationType>::renderDataSize); 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename DurationType> 10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void bucketizeSamplesUniformly (const std::vector<UploadSampleResult<DurationType> >& samples, std::vector<UploadSampleResult<DurationType> >* buckets, int numBuckets, int& minBufferSize, int& maxBufferSize) 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minBufferSize = 0; 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry maxBufferSize = 0; 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(samples[sampleNdx].allocatedSize != 0); 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!minBufferSize || samples[sampleNdx].allocatedSize < minBufferSize) 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minBufferSize = samples[sampleNdx].allocatedSize; 10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!maxBufferSize || samples[sampleNdx].allocatedSize > maxBufferSize) 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry maxBufferSize = samples[sampleNdx].allocatedSize; 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float bucketNdxFloat = (samples[sampleNdx].allocatedSize - minBufferSize) / (float)(maxBufferSize - minBufferSize) * numBuckets; 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bucketNdx = de::clamp((int)deFloatFloor(bucketNdxFloat), 0, numBuckets-1); 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buckets[bucketNdx].push_back(samples[sampleNdx]); 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Type logMapRangeStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("MapRangeMin", "MapRange: Min time", "us", QP_KEY_TAG_TIME, stats.map.minTime) 10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MapRangeMax", "MapRange: Max time", "us", QP_KEY_TAG_TIME, stats.map.maxTime) 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MapRangeMin90", "MapRange: 90%-Min time", "us", QP_KEY_TAG_TIME, stats.map.min2DecileTime) 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MapRangeMax90", "MapRange: 90%-Max time", "us", QP_KEY_TAG_TIME, stats.map.max9DecileTime) 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MapRangeMedian", "MapRange: Median time", "us", QP_KEY_TAG_TIME, stats.map.medianTime); 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Type logUnmapStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("UnmapMin", "Unmap: Min time", "us", QP_KEY_TAG_TIME, stats.unmap.minTime) 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UnmapMax", "Unmap: Max time", "us", QP_KEY_TAG_TIME, stats.unmap.maxTime) 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UnmapMin90", "Unmap: 90%-Min time", "us", QP_KEY_TAG_TIME, stats.unmap.min2DecileTime) 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UnmapMax90", "Unmap: 90%-Max time", "us", QP_KEY_TAG_TIME, stats.unmap.max9DecileTime) 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UnmapMedian", "Unmap: Median time", "us", QP_KEY_TAG_TIME, stats.unmap.medianTime); 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Type logWriteStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("WriteMin", "Write: Min time", "us", QP_KEY_TAG_TIME, stats.write.minTime) 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("WriteMax", "Write: Max time", "us", QP_KEY_TAG_TIME, stats.write.maxTime) 11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("WriteMin90", "Write: 90%-Min time", "us", QP_KEY_TAG_TIME, stats.write.min2DecileTime) 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("WriteMax90", "Write: 90%-Max time", "us", QP_KEY_TAG_TIME, stats.write.max9DecileTime) 11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("WriteMedian", "Write: Median time", "us", QP_KEY_TAG_TIME, stats.write.medianTime); 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Type logFlushStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("FlushMin", "Flush: Min time", "us", QP_KEY_TAG_TIME, stats.flush.minTime) 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FlushMax", "Flush: Max time", "us", QP_KEY_TAG_TIME, stats.flush.maxTime) 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FlushMin90", "Flush: 90%-Min time", "us", QP_KEY_TAG_TIME, stats.flush.min2DecileTime) 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FlushMax90", "Flush: 90%-Max time", "us", QP_KEY_TAG_TIME, stats.flush.max9DecileTime) 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FlushMedian", "Flush: Median time", "us", QP_KEY_TAG_TIME, stats.flush.medianTime); 11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Type logAllocStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("AllocMin", "Alloc: Min time", "us", QP_KEY_TAG_TIME, stats.alloc.minTime) 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("AllocMax", "Alloc: Max time", "us", QP_KEY_TAG_TIME, stats.alloc.maxTime) 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("AllocMin90", "Alloc: 90%-Min time", "us", QP_KEY_TAG_TIME, stats.alloc.min2DecileTime) 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("AllocMax90", "Alloc: 90%-Max time", "us", QP_KEY_TAG_TIME, stats.alloc.max9DecileTime) 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("AllocMedian", "Alloc: Median time", "us", QP_KEY_TAG_TIME, stats.alloc.medianTime); 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11436b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Value>::Type logMapRangeStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11506b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Value>::Type logUnmapStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11576b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Value>::Type logWriteStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11646b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Value>::Type logFlushStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11716b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Value>::Type logAllocStats (tcu::TestLog& log, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Type logMapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::mapDuration); 11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("MapConstantCost", "Map: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MapLinearCost", "Map: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MapMedianCost", "Map: Median cost", "us", QP_KEY_TAG_TIME, stats.map.medianTime); 11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Type logUnmapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::unmapDuration); 11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("UnmapConstantCost", "Unmap: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UnmapLinearCost", "Unmap: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UnmapMedianCost", "Unmap: Median cost", "us", QP_KEY_TAG_TIME, stats.unmap.medianTime); 11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Type logWriteContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::writeDuration); 11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("WriteConstantCost", "Write: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("WriteLinearCost", "Write: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("WriteMedianCost", "Write: Median cost", "us", QP_KEY_TAG_TIME, stats.write.medianTime); 12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Type logFlushContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::flushDuration); 12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("FlushConstantCost", "Flush: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FlushLinearCost", "Flush: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FlushMedianCost", "Flush: Median cost", "us", QP_KEY_TAG_TIME, stats.flush.medianTime); 12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Type logAllocContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::allocDuration); 12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("AllocConstantCost", "Alloc: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("AllocLinearCost", "Alloc: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("AllocMedianCost", "Alloc: Median cost", "us", QP_KEY_TAG_TIME, stats.alloc.medianTime); 12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_RENDER_STATS>::Type logRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::renderDuration); 12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("DrawCallConstantCost", "DrawCall: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("DrawCallLinearCost", "DrawCall: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("DrawCallMedianCost", "DrawCall: Median cost", "us", QP_KEY_TAG_TIME, stats.render.medianTime); 12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_READ_STATS>::Type logReadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::readDuration); 12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("ReadConstantCost", "Read: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ReadLinearCost", "Read: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ReadMedianCost", "Read: Median cost", "us", QP_KEY_TAG_TIME, stats.read.medianTime); 12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_UPLOAD_STATS>::Type logUploadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::uploadDuration); 12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("UploadConstantCost", "Upload: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UploadLinearCost", "Upload: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("UploadMedianCost", "Upload: Median cost", "us", QP_KEY_TAG_TIME, stats.upload.medianTime); 12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_TOTAL_STATS>::Type logTotalContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::totalDuration); 12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("TotalConstantCost", "Total: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("TotalLinearCost", "Total: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("TotalMedianCost", "Total: Median cost", "us", QP_KEY_TAG_TIME, stats.total.medianTime); 12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_FIRST_RENDER_STATS>::Type logFirstRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::firstRenderDuration); 12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("FirstDrawCallConstantCost", "First DrawCall: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FirstDrawCallLinearCost", "First DrawCall: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("FirstDrawCallMedianCost", "First DrawCall: Median cost", "us", QP_KEY_TAG_TIME, stats.firstRender.medianTime); 12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic typename EnableIf<void, SampleTypeTraits<SampleType>::HAS_SECOND_RENDER_STATS>::Type logSecondRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence contributionFitting = fitLineToSamples(samples, &SampleType::secondRenderDuration); 12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("SecondDrawCallConstantCost", "Second DrawCall: Approximated contant cost", "us", QP_KEY_TAG_TIME, contributionFitting.offset) 12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SecondDrawCallLinearCost", "Second DrawCall: Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, contributionFitting.coefficient * 1024.0f * 1024.0f) 12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SecondDrawCallMedianCost", "Second DrawCall: Median cost", "us", QP_KEY_TAG_TIME, stats.secondRender.medianTime); 12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12776b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_MAP_STATS>::Value>::Type logMapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12856b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_UNMAP_STATS>::Value>::Type logUnmapContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 12936b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_WRITE_STATS>::Value>::Type logWriteContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13016b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_FLUSH_STATS>::Value>::Type logFlushContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13096b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_ALLOC_STATS>::Value>::Type logAllocContribution (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13176b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_RENDER_STATS>::Value>::Type logRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13256b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_READ_STATS>::Value>::Type logReadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13336b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_UPLOAD_STATS>::Value>::Type logUploadContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13416b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_TOTAL_STATS>::Value>::Type logTotalContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13496b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_FIRST_RENDER_STATS>::Value>::Type logFirstRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 13576b66fa81a4085f9d660393fc8c43653fb7f14990Jarkko Pöyrystatic typename EnableIf<void, Not<SampleTypeTraits<SampleType>::HAS_SECOND_RENDER_STATS>::Value>::Type logSecondRenderContribution (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples, const typename SampleTypeTraits<SampleType>::StatsType& stats) 13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(log); 13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(samples); 13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(stats); 13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<UploadSampleResult<SingleOperationDuration> >& samples) 13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WrittenSize", "Written size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("BufferSize", "Buffer size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UploadTime", "Upload time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].writtenSize); 13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].writtenSize 13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].bufferSize 13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<UploadSampleResult<MapBufferRangeDuration> >& samples) 13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WrittenSize", "Written size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("BufferSize", "Buffer size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("AllocTime", "Alloc time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("MapTime", "Map time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UnmapTime", "Unmap time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WriteTime", "Write time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].writtenSize); 14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].writtenSize 14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].bufferSize 14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.allocDuration 14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.mapDuration 14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.unmapDuration 14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.writeDuration 14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<UploadSampleResult<MapBufferRangeDurationNoAlloc> >& samples) 14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WrittenSize", "Written size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("BufferSize", "Buffer size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("MapTime", "Map time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UnmapTime", "Unmap time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WriteTime", "Write time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 14323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].writtenSize); 14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].writtenSize 14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].bufferSize 14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.mapDuration 14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.unmapDuration 14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.writeDuration 14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<UploadSampleResult<MapBufferRangeFlushDuration> >& samples) 14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WrittenSize", "Written size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("BufferSize", "Buffer size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("AllocTime", "Alloc time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("MapTime", "Map time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UnmapTime", "Unmap time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WriteTime", "Write time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FlushTime", "Flush time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].writtenSize); 14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].writtenSize 14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].bufferSize 14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.allocDuration 14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.mapDuration 14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.unmapDuration 14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.writeDuration 14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.flushDuration 14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<UploadSampleResult<MapBufferRangeFlushDurationNoAlloc> >& samples) 14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WrittenSize", "Written size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("BufferSize", "Buffer size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("MapTime", "Map time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UnmapTime", "Unmap time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("WriteTime", "Write time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FlushTime", "Flush time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].writtenSize); 15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].writtenSize 15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].bufferSize 15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.mapDuration 15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.unmapDuration 15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.writeDuration 15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.flushDuration 15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<RenderSampleResult<RenderReadDuration> >& samples) 15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DataSize", "Data processed", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("VertexCount", "Number of vertices", "vertices", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawCallTime", "Draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].renderDataSize); 15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].renderDataSize 15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].numVertices 15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderReadDuration 15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderDuration 15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.readDuration 15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<RenderSampleResult<UnrelatedUploadRenderReadDuration> >& samples) 15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DataSize", "Data processed", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("VertexCount", "Number of vertices", "vertices", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UnrelatedUploadSize", "Unrelated upload size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawCallTime", "Draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].renderDataSize); 15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].renderDataSize 15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].numVertices 15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].unrelatedDataSize 15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderReadDuration 15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderDuration 15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.readDuration 15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<RenderSampleResult<UploadRenderReadDuration> >& samples) 15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DataSize", "Data processed", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UploadSize", "Data uploaded", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("VertexCount", "Number of vertices", "vertices", QP_SAMPLE_VALUE_TAG_PREDICTOR) 15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawReadTime", "Draw call and ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("Upload time", "Upload time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawCallTime", "Draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].renderDataSize); 15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].renderDataSize 15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].uploadedDataSize 15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].numVertices 15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderReadDuration 15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 15983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.uploadDuration 15993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderDuration 16003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.readDuration 16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 16033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 16063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 16073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<RenderSampleResult<UploadRenderReadDurationWithUnrelatedUploadSize> >& samples) 16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 16103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 16113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DataSize", "Data processed", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UploadSize", "Data uploaded", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("VertexCount", "Number of vertices", "vertices", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UnrelatedUploadSize", "Unrelated upload size", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawReadTime", "Draw call and ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("Upload time", "Upload time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawCallTime", "Draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].renderDataSize); 16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].renderDataSize 16293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].uploadedDataSize 16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].numVertices 16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].unrelatedDataSize 16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderReadDuration 16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.uploadDuration 16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderDuration 16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.readDuration 16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid logSampleList (tcu::TestLog& log, const LineParametersWithConfidence& theilSenFitting, const std::vector<RenderSampleResult<RenderUploadRenderReadDuration> >& samples) 16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::SampleList("Samples", "Samples") 16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DataSize", "Data processed", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("UploadSize", "Data uploaded", "bytes", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("VertexCount", "Number of vertices", "vertices", QP_SAMPLE_VALUE_TAG_PREDICTOR) 16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawReadTime", "Second draw call and ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FirstDrawCallTime", "First draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("Upload time", "Upload time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("SecondDrawCallTime", "Second draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("FitResidual", "Fit residual", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)samples.size(); ++sampleNdx) 16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float fitResidual = samples[sampleNdx].duration.fitResponseDuration - (theilSenFitting.offset + theilSenFitting.coefficient * samples[sampleNdx].renderDataSize); 16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Sample 16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].renderDataSize 16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].uploadedDataSize 16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << samples[sampleNdx].numVertices 16673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.renderReadDuration 16683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.totalDuration 16693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.firstRenderDuration 16703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.uploadDuration 16713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.secondRenderDuration 16723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)samples[sampleNdx].duration.readDuration 16733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << fitResidual 16743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 16753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::EndSampleList; 16783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 16793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16803c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 16813c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic UploadSampleAnalyzeResult analyzeSampleResults (tcu::TestLog& log, const std::vector<UploadSampleResult<SampleType> >& samples, bool logBucketPerformance) 16823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 16833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Assume data is linear with some outliers, fit a line 16848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence theilSenFitting = fitLineToSamples(samples); 16853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename SampleTypeTraits<SampleType>::StatsType resultStats = calculateSampleStatistics(theilSenFitting, samples); 16863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float approximatedTransferRate; 16873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float approximatedTransferRateNoConstant; 16883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Output raw samples 16903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(log, "Samples", "Samples"); 16923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logSampleList(log, theilSenFitting, samples); 16933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Calculate results for different ranges 16963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (logBucketPerformance) 16973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numBuckets = 4; 16993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int minBufferSize = 0; 17003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int maxBufferSize = 0; 17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<UploadSampleResult<SampleType> > buckets[numBuckets]; 17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bucketizeSamplesUniformly(samples, &buckets[0], numBuckets, minBufferSize, maxBufferSize); 17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int bucketNdx = 0; bucketNdx < numBuckets; ++bucketNdx) 17063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (buckets[bucketNdx].empty()) 17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Print a nice result summary 17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bucketRangeMin = minBufferSize + (int)(( bucketNdx / (float)numBuckets) * (maxBufferSize - minBufferSize)); 17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bucketRangeMax = minBufferSize + (int)(((bucketNdx+1) / (float)numBuckets) * (maxBufferSize - minBufferSize)); 17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename SampleTypeTraits<SampleType>::StatsType stats = calculateSampleStatistics(theilSenFitting, buckets[bucketNdx]); 17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (log, "BufferSizeRange", std::string("Transfer performance with buffer size in range [").append(getHumanReadableByteSize(bucketRangeMin).append(", ").append(getHumanReadableByteSize(bucketRangeMax).append("]")))); 17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logMapRangeStats<SampleType>(log, stats); 17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logUnmapStats<SampleType>(log, stats); 17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logWriteStats<SampleType>(log, stats); 17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logFlushStats<SampleType>(log, stats); 17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAllocStats<SampleType>(log, stats); 17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("Min", "Total: Min time", "us", QP_KEY_TAG_TIME, stats.result.minTime) 17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Max", "Total: Max time", "us", QP_KEY_TAG_TIME, stats.result.maxTime) 17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Min90", "Total: 90%-Min time", "us", QP_KEY_TAG_TIME, stats.result.min2DecileTime) 17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Max90", "Total: 90%-Max time", "us", QP_KEY_TAG_TIME, stats.result.max9DecileTime) 17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Median", "Total: Median time", "us", QP_KEY_TAG_TIME, stats.result.medianTime) 17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MedianTransfer", "Median transfer rate", "MB / s", QP_KEY_TAG_PERFORMANCE, stats.medianRate / 1024.0f / 1024.0f) 17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MaxDiff", "Max difference to approximated", "us", QP_KEY_TAG_TIME, stats.maxDiffTime) 17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Max90Diff", "90%-Max difference to approximated", "us", QP_KEY_TAG_TIME, stats.maxDiff9DecileTime) 17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MedianDiff", "Median difference to approximated", "us", QP_KEY_TAG_TIME, stats.medianDiffTime) 17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MaxRelDiff", "Max relative difference to approximated", "%", QP_KEY_TAG_NONE, stats.maxRelDiffTime * 100.0f) 17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Max90RelDiff", "90%-Max relative difference to approximated", "%", QP_KEY_TAG_NONE, stats.max9DecileRelDiffTime * 100.0f) 17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("MedianRelDiff", "Median relative difference to approximated", "%", QP_KEY_TAG_NONE, stats.medianRelDiffTime * 100.0f); 17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Contributions 17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (SampleTypeTraits<SampleType>::LOG_CONTRIBUTIONS) 17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(log, "Contribution", "Contributions"); 17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logMapContribution(log, samples, resultStats); 17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logUnmapContribution(log, samples, resultStats); 17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logWriteContribution(log, samples, resultStats); 17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logFlushContribution(log, samples, resultStats); 17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAllocContribution(log, samples, resultStats); 17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Print results 17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(log, "Results", "Results"); 17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int medianBufferSize = (samples.front().bufferSize + samples.back().bufferSize) / 2; 17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float approximatedTransferTime = (theilSenFitting.offset + theilSenFitting.coefficient * medianBufferSize) / 1000.0f / 1000.0f; 17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float approximatedTransferTimeNoConstant = (theilSenFitting.coefficient * medianBufferSize) / 1000.0f / 1000.0f; 17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float sampleLinearity = calculateSampleFitLinearity(samples); 17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float sampleTemporalStability = calculateSampleTemporalStability(samples); 17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry approximatedTransferRateNoConstant = medianBufferSize / approximatedTransferTimeNoConstant; 17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry approximatedTransferRate = medianBufferSize / approximatedTransferTime; 17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("ResultLinearity", "Sample linearity", "%", QP_KEY_TAG_QUALITY, sampleLinearity * 100.0f) 17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SampleTemporalStability", "Sample temporal stability", "%", QP_KEY_TAG_QUALITY, sampleTemporalStability * 100.0f) 17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedConstantCost", "Approximated contant cost", "us", QP_KEY_TAG_TIME, theilSenFitting.offset) 17668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedConstantCostConfidence60Lower", "Approximated contant cost 60% confidence lower limit", "us", QP_KEY_TAG_TIME, theilSenFitting.offsetConfidenceLower) 17678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedConstantCostConfidence60Upper", "Approximated contant cost 60% confidence upper limit", "us", QP_KEY_TAG_TIME, theilSenFitting.offsetConfidenceUpper) 17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedLinearCost", "Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, theilSenFitting.coefficient * 1024.0f * 1024.0f) 17698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedLinearCostConfidence60Lower", "Approximated linear cost 60% confidence lower limit", "us / MB", QP_KEY_TAG_TIME, theilSenFitting.coefficientConfidenceLower * 1024.0f * 1024.0f) 17708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedLinearCostConfidence60Upper", "Approximated linear cost 60% confidence upper limit", "us / MB", QP_KEY_TAG_TIME, theilSenFitting.coefficientConfidenceUpper * 1024.0f * 1024.0f) 17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedTransferRate", "Approximated transfer rate", "MB / s", QP_KEY_TAG_PERFORMANCE, approximatedTransferRate / 1024.0f / 1024.0f) 17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedTransferRateNoConstant", "Approximated transfer rate without constant cost", "MB / s", QP_KEY_TAG_PERFORMANCE, approximatedTransferRateNoConstant / 1024.0f / 1024.0f) 17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SampleMedianTime", "Median sample time", "us", QP_KEY_TAG_TIME, resultStats.result.medianTime) 17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SampleMedianTransfer", "Median transfer rate", "MB / s", QP_KEY_TAG_PERFORMANCE, resultStats.medianRate / 1024.0f / 1024.0f); 17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // return approximated transfer rate 17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadSampleAnalyzeResult result; 17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.transferRateMedian = resultStats.medianRate; 17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.transferRateAtRange = approximatedTransferRate; 17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.transferRateAtInfinity = approximatedTransferRateNoConstant; 17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return result; 17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic RenderSampleAnalyzeResult analyzeSampleResults (tcu::TestLog& log, const std::vector<RenderSampleResult<SampleType> >& samples) 17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Assume data is linear with some outliers, fit a line 17938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence theilSenFitting = fitLineToSamples(samples); 17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const typename SampleTypeTraits<SampleType>::StatsType resultStats = calculateSampleStatistics(theilSenFitting, samples); 17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float approximatedProcessingRate; 17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float approximatedProcessingRateNoConstant; 17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // output raw samples 17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(log, "Samples", "Samples"); 18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logSampleList(log, theilSenFitting, samples); 18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Contributions 18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (SampleTypeTraits<SampleType>::LOG_CONTRIBUTIONS) 18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(log, "Contribution", "Contributions"); 18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logFirstRenderContribution(log, samples, resultStats); 18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logUploadContribution(log, samples, resultStats); 18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logRenderContribution(log, samples, resultStats); 18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logSecondRenderContribution(log, samples, resultStats); 18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logReadContribution(log, samples, resultStats); 18143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logTotalContribution(log, samples, resultStats); 18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // print results 18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(log, "Results", "Results"); 18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int medianDataSize = (samples.front().renderDataSize + samples.back().renderDataSize) / 2; 18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float approximatedRenderTime = (theilSenFitting.offset + theilSenFitting.coefficient * medianDataSize) / 1000.0f / 1000.0f; 18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float approximatedRenderTimeNoConstant = (theilSenFitting.coefficient * medianDataSize) / 1000.0f / 1000.0f; 18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float sampleLinearity = calculateSampleFitLinearity(samples); 18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float sampleTemporalStability = calculateSampleTemporalStability(samples); 18263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry approximatedProcessingRateNoConstant = medianDataSize / approximatedRenderTimeNoConstant; 18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry approximatedProcessingRate = medianDataSize / approximatedRenderTime; 18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Float("ResultLinearity", "Sample linearity", "%", QP_KEY_TAG_QUALITY, sampleLinearity * 100.0f) 18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SampleTemporalStability", "Sample temporal stability", "%", QP_KEY_TAG_QUALITY, sampleTemporalStability * 100.0f) 18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedConstantCost", "Approximated contant cost", "us", QP_KEY_TAG_TIME, theilSenFitting.offset) 18338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedConstantCostConfidence60Lower", "Approximated contant cost 60% confidence lower limit", "us", QP_KEY_TAG_TIME, theilSenFitting.offsetConfidenceLower) 18348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedConstantCostConfidence60Upper", "Approximated contant cost 60% confidence upper limit", "us", QP_KEY_TAG_TIME, theilSenFitting.offsetConfidenceUpper) 18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedLinearCost", "Approximated linear cost", "us / MB", QP_KEY_TAG_TIME, theilSenFitting.coefficient * 1024.0f * 1024.0f) 18368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedLinearCostConfidence60Lower", "Approximated linear cost 60% confidence lower limit", "us / MB", QP_KEY_TAG_TIME, theilSenFitting.coefficientConfidenceLower * 1024.0f * 1024.0f) 18378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << tcu::TestLog::Float("ApproximatedLinearCostConfidence60Upper", "Approximated linear cost 60% confidence upper limit", "us / MB", QP_KEY_TAG_TIME, theilSenFitting.coefficientConfidenceUpper * 1024.0f * 1024.0f) 18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedProcessRate", "Approximated processing rate", "MB / s", QP_KEY_TAG_PERFORMANCE, approximatedProcessingRate / 1024.0f / 1024.0f) 18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("ApproximatedProcessRateNoConstant", "Approximated processing rate without constant cost", "MB / s", QP_KEY_TAG_PERFORMANCE, approximatedProcessingRateNoConstant / 1024.0f / 1024.0f) 18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SampleMedianTime", "Median sample time", "us", QP_KEY_TAG_TIME, resultStats.result.medianTime) 18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("SampleMedianProcess", "Median processing rate", "MB / s", QP_KEY_TAG_PERFORMANCE, resultStats.medianRate / 1024.0f / 1024.0f); 18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // return approximated render rate 18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderSampleAnalyzeResult result; 18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.renderRateMedian = resultStats.medianRate; 18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.renderRateAtRange = approximatedProcessingRate; 18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.renderRateAtInfinity = approximatedProcessingRateNoConstant; 18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return result; 18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return RenderSampleAnalyzeResult(); 18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void generateTwoPassRandomIterationOrder (std::vector<int>& iterationOrder, int numSamples) 18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (0xabc); 18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int midPoint = (numSamples+1) / 2; // !< ceil(m_numSamples / 2) 18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT((int)iterationOrder.size() == numSamples); 18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Two "passes" over range, randomize order in both passes 18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // This allows to us detect if iterations are not independent 18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // (first run and later run samples differ significantly?) 18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < midPoint; ++sampleNdx) 18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry iterationOrder[sampleNdx] = sampleNdx * 2; 18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = midPoint; sampleNdx < numSamples; ++sampleNdx) 18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry iterationOrder[sampleNdx] = (sampleNdx - midPoint) * 2 + 1; 18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < midPoint; ++ndx) 18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::swap(iterationOrder[ndx], iterationOrder[rnd.getInt(0, midPoint - 1)]); 18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = midPoint; ndx < (int)iterationOrder.size(); ++ndx) 18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::swap(iterationOrder[ndx], iterationOrder[rnd.getInt(midPoint, (int)iterationOrder.size()-1)]); 18773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicBufferCase : public TestCase 18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Flags 18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_ALLOCATE_LARGER_BUFFER = 0x01, 18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, int numSamples, int flags); 18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BasicBufferCase (void); 18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void deinit (void); 18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual bool runSample (int iteration, UploadSampleResult<SampleType>& sample) = 0; 18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void logAndSetTestResult (const std::vector<UploadSampleResult<SampleType> >& results) = 0; 18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void disableGLWarmup (void); 19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void waitGLResults (void); 19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DUMMY_RENDER_AREA_SIZE = 32 19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_dummyProgram; 19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deInt32 m_dummyProgramPosLoc; 19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_bufferID; 19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_numSamples; 19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_bufferSizeMin; 19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_bufferSizeMax; 19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_allocateLargerBuffer; 19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<int> m_iterationOrder; 19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<UploadSampleResult<SampleType> > m_results; 19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_useGL; 19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_bufferRandomizerTimer; 19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 19273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBasicBufferCase<SampleType>::BasicBufferCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, int numSamples, int flags) 19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, tcu::NODETYPE_PERFORMANCE, name, desc) 19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dummyProgram (DE_NULL) 19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dummyProgramPosLoc (-1) 19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferID (0) 19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numSamples (numSamples) 19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferSizeMin (bufferSizeMin) 19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferSizeMax (bufferSizeMax) 19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_allocateLargerBuffer ((flags & FLAG_ALLOCATE_LARGER_BUFFER) != 0) 19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationOrder (numSamples) 19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_results (numSamples) 19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useGL (true) 19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferRandomizerTimer (0) 19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 19423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // "randomize" iteration order. Deterministic, patternless 19433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateTwoPassRandomIterationOrder(m_iterationOrder, m_numSamples); 19443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // choose buffer sizes 19463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < m_numSamples; ++sampleNdx) 19473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int rawBufferSize = (int)deFloatFloor(bufferSizeMin + (bufferSizeMax - bufferSizeMin) * ((float)(sampleNdx + 1) / m_numSamples)); 19493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferSize = deAlign32(rawBufferSize, 16); 19503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int allocatedBufferSize = deAlign32((m_allocateLargerBuffer) ? ((int)(bufferSize * 1.5f)) : (bufferSize), 16); 19513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results[sampleNdx].bufferSize = bufferSize; 19533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results[sampleNdx].allocatedSize = allocatedBufferSize; 19543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results[sampleNdx].writtenSize = -1; 19553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 19573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 19593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBasicBufferCase<SampleType>::~BasicBufferCase (void) 19603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 19613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 19623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 19633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 19653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicBufferCase<SampleType>::init (void) 19663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 19673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 19683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_useGL) 19703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 19713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note Viewport size is not checked, it won't matter if the render target actually is smaller hhan DUMMY_RENDER_AREA_SIZE 19733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // dummy shader 19753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dummyProgram = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(s_dummyVertexShader) << glu::FragmentSource(s_dummyFragnentShader)); 19773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_dummyProgram->isOk()) 19783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *m_dummyProgram; 19803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("failed to build shader program"); 19813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dummyProgramPosLoc = gl.getAttribLocation(m_dummyProgram->getProgram(), "a_position"); 19843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_dummyProgramPosLoc == -1) 19853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("a_position location was -1"); 19863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 19873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 19893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicBufferCase<SampleType>::deinit (void) 19903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 19913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferID) 19923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_bufferID); 19943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_bufferID = 0; 19953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_dummyProgram; 19983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dummyProgram = DE_NULL; 19993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 20003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 20023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult BasicBufferCase<SampleType>::iterate (void) 20033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 20043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 20053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static bool buffersWarmedUp = false; 20063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const deUint32 usages[] = 20083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_STREAM_DRAW, GL_STREAM_READ, GL_STREAM_COPY, 20103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_STATIC_DRAW, GL_STATIC_READ, GL_STATIC_COPY, 20113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_DYNAMIC_DRAW, GL_DYNAMIC_READ, GL_DYNAMIC_COPY, 20123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 20133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Allocate some random sized buffers and remove them to 20153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make sure the first samples too have some buffers removed 20163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // just before their allocation. This is only needed by the 20173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // the first test. 20183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useGL && !buffersWarmedUp) 20203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numRandomBuffers = 6; 20223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numRepeats = 10; 20233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int maxBufferSize = 16777216; 20243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<deUint8> zeroData (maxBufferSize, 0x00); 20253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (0x1234); 20263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bufferIDs[numRandomBuffers] = {0}; 20273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.useProgram(m_dummyProgram->getProgram()); 20293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(0, 0, DUMMY_RENDER_AREA_SIZE, DUMMY_RENDER_AREA_SIZE); 20303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray(m_dummyProgramPosLoc); 20313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < numRepeats; ++ndx) 20333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create buffer and maybe draw from it 20353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int randomBufferNdx = 0; randomBufferNdx < numRandomBuffers; ++randomBufferNdx) 20363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int randomSize = deAlign32(rnd.getInt(1, maxBufferSize), 4*4); 20383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 usage = usages[rnd.getUint32() % (deUint32)DE_LENGTH_OF_ARRAY(usages)]; 20393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &bufferIDs[randomBufferNdx]); 20413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, bufferIDs[randomBufferNdx]); 20423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, randomSize, &zeroData[0], usage); 20433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (rnd.getBool()) 20453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer(m_dummyProgramPosLoc, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 20473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, 0, 1); 20483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, randomSize / (int)sizeof(float[4]) - 1, 1); 20493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int randomBufferNdx = 0; randomBufferNdx < numRandomBuffers; ++randomBufferNdx) 20533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &bufferIDs[randomBufferNdx]); 20543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 20563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Buffer gen"); 20573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.touchWatchdog(); 20593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buffersWarmedUp = true; 20623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 20633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_useGL && m_bufferRandomizerTimer++ % 8 == 0) 20653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do some random buffer operations to every now and then 20673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // to make sure the previous test iterations won't affect 20683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // following test runs. 20693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numRandomBuffers = 3; 20713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int maxBufferSize = 16777216; 20723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<deUint8> zeroData (maxBufferSize, 0x00); 20733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (0x1234 + 0xabc * m_bufferRandomizerTimer); 20743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // BufferData 20763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bufferIDs[numRandomBuffers] = {0}; 20783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int randomBufferNdx = 0; randomBufferNdx < numRandomBuffers; ++randomBufferNdx) 20803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int randomSize = deAlign32(rnd.getInt(1, maxBufferSize), 4*4); 20823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 usage = usages[rnd.getUint32() % (deUint32)DE_LENGTH_OF_ARRAY(usages)]; 20833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &bufferIDs[randomBufferNdx]); 20853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, bufferIDs[randomBufferNdx]); 20863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, randomSize, &zeroData[0], usage); 20873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int randomBufferNdx = 0; randomBufferNdx < numRandomBuffers; ++randomBufferNdx) 20903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &bufferIDs[randomBufferNdx]); 20913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 20923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "buffer ops"); 20943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do some memory mappings 20963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 20973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bufferIDs[numRandomBuffers] = {0}; 20983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 20993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int randomBufferNdx = 0; randomBufferNdx < numRandomBuffers; ++randomBufferNdx) 21003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int randomSize = deAlign32(rnd.getInt(1, maxBufferSize), 4*4); 21023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 usage = usages[rnd.getUint32() % (deUint32)DE_LENGTH_OF_ARRAY(usages)]; 21033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* ptr; 21043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &bufferIDs[randomBufferNdx]); 21063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, bufferIDs[randomBufferNdx]); 21073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, randomSize, &zeroData[0], usage); 21083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer(m_dummyProgramPosLoc, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 21103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, 0, 1); 21113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, randomSize / (int)sizeof(float[4]) - 1, 1); 21123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (rnd.getBool()) 21143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 21153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ptr = gl.mapBufferRange(GL_ARRAY_BUFFER, 0, randomSize, GL_MAP_WRITE_BIT); 21173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ptr) 21183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry medianTimeMemcpy(ptr, &zeroData[0], randomSize); 21203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.unmapBuffer(GL_ARRAY_BUFFER); 21213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 21223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 21233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int randomBufferNdx = 0; randomBufferNdx < numRandomBuffers; ++randomBufferNdx) 21253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &bufferIDs[randomBufferNdx]); 21263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 21283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 21293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "buffer maps"); 21313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 21323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 21333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 21343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int currentIteration = m_iteration; 21363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int sampleNdx = m_iterationOrder[currentIteration]; 21373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool sampleRunSuccessful = runSample(currentIteration, m_results[sampleNdx]); 21383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "post runSample()"); 21403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Retry failed samples 21423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!sampleRunSuccessful) 21433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 21443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration >= m_numSamples) 21463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAndSetTestResult(m_results); 21483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 21493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 21503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 21513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 21523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 21533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 21543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 21563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicBufferCase<SampleType>::disableGLWarmup (void) 21573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 21583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_useGL = false; 21593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 21603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21613c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 21623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicBufferCase<SampleType>::waitGLResults (void) 21633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 21643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface dummySurface(DUMMY_RENDER_AREA_SIZE, DUMMY_RENDER_AREA_SIZE); 21653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, dummySurface.getAccess()); 21663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 21673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 21693c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BasicUploadCase : public BasicBufferCase<SampleType> 21703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 21713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 21723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseType 21733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_NO_BUFFERS = 0, 21753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_NEW_BUFFER, 21763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_UNSPECIFIED_BUFFER, 21773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_SPECIFIED_BUFFER, 21783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_USED_BUFFER, 21793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_USED_LARGER_BUFFER, 21803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_LAST 21823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 21833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseFlags 21853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_DONT_LOG_BUFFER_INFO = 0x01, 21873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_RESULT_BUFFER_UNSPECIFIED_CONTENT = 0x02, 21883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 21893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum ResultType 21913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 21923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RESULT_MEDIAN_TRANSFER_RATE = 0, 21933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RESULT_ASYMPTOTIC_TRANSFER_RATE, 21943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 21953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 21963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase (Context& context, 21973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 21983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* desc, 21993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bufferSizeMin, 22003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bufferSizeMax, 22013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numSamples, 22023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 bufferUsage, 22033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CaseType caseType, 22043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ResultType resultType, 22053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int flags = 0); 22063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BasicUploadCase (void); 22083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 22103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void deinit (void); 22113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 22133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool runSample (int iteration, UploadSampleResult<SampleType>& sample); 22143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void createBuffer (int bufferSize, int iteration); 22153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deleteBuffer (int bufferSize); 22163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void useBuffer (int bufferSize); 22173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void testBufferUpload (UploadSampleResult<SampleType>& result, int writeSize) = 0; 22193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logAndSetTestResult (const std::vector<UploadSampleResult<SampleType> >& results); 22203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_dummyBufferID; 22223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 22243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const CaseType m_caseType; 22253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const ResultType m_resultType; 22263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_bufferUsage; 22273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_logBufferInfo; 22283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_bufferUnspecifiedContent; 22293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint8> m_zeroData; 22303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_testCtx; 22323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_context; 22333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::DUMMY_RENDER_AREA_SIZE; 22353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_dummyProgram; 22363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_dummyProgramPosLoc; 22373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_bufferID; 22383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_numSamples; 22393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_bufferSizeMin; 22403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_bufferSizeMax; 22413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_allocateLargerBuffer; 22423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 22433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 22453c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBasicUploadCase<SampleType>::BasicUploadCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, int numSamples, deUint32 bufferUsage, CaseType caseType, ResultType resultType, int flags) 22463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicBufferCase<SampleType> (context, name, desc, bufferSizeMin, bufferSizeMax, numSamples, (caseType == CASE_USED_LARGER_BUFFER) ? (BasicBufferCase<SampleType>::FLAG_ALLOCATE_LARGER_BUFFER) : (0)) 22473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dummyBufferID (0) 22483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseType (caseType) 22493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_resultType (resultType) 22503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferUsage (bufferUsage) 22513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_logBufferInfo ((flags & FLAG_DONT_LOG_BUFFER_INFO) == 0) 22523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferUnspecifiedContent ((flags & FLAG_RESULT_BUFFER_UNSPECIFIED_CONTENT) != 0) 22533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_zeroData () 22543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 22553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_caseType < CASE_LAST); 22563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 22573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22583c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 22593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBasicUploadCase<SampleType>::~BasicUploadCase (void) 22603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 22613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 22623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 22633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22643c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 22653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicUploadCase<SampleType>::init (void) 22663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 22673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 22683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::init(); 22703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // zero buffer as upload source 22723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_zeroData.resize(m_bufferSizeMax, 0x00); 22733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // dummy buffer 22753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_dummyBufferID); 22773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Gen buf"); 22783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log basic info 22803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 22823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 22833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing performance with " << m_numSamples << " test samples. Sample order is randomized. All samples at even positions (first = 0) are tested before samples at odd positions.\n" 22843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Buffer sizes are in range [" << getHumanReadableByteSize(m_bufferSizeMin) << ", " << getHumanReadableByteSize(m_bufferSizeMax) << "]." 22853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 22863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_logBufferInfo) 22883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 22893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_caseType) 22903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 22913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_NO_BUFFERS: 22923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 22933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_NEW_BUFFER: 22953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Target buffer is generated but not specified (i.e glBufferData() not called)." << tcu::TestLog::EndMessage; 22963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 22973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 22983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_UNSPECIFIED_BUFFER: 22993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Target buffer is allocated with glBufferData(NULL)." << tcu::TestLog::EndMessage; 23003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 23013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_SPECIFIED_BUFFER: 23033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Target buffer contents are specified prior testing with glBufferData(data)." << tcu::TestLog::EndMessage; 23043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 23053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_USED_BUFFER: 23073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Target buffer has been used in drawing before testing." << tcu::TestLog::EndMessage; 23083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 23093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_USED_LARGER_BUFFER: 23113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Target buffer is larger and has been used in drawing before testing." << tcu::TestLog::EndMessage; 23123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 23133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 23153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 23163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 23173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 23183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 23193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_resultType == RESULT_MEDIAN_TRANSFER_RATE) 23213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Test result is the median transfer rate of the test samples." << tcu::TestLog::EndMessage; 23223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_resultType == RESULT_ASYMPTOTIC_TRANSFER_RATE) 23233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Test result is the asymptotic transfer rate as the buffer size approaches infinity." << tcu::TestLog::EndMessage; 23243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 23253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 23263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 23273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 23293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicUploadCase<SampleType>::deinit (void) 23303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 23313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_dummyBufferID) 23323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 23333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_dummyBufferID); 23343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dummyBufferID = 0; 23353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 23363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_zeroData.clear(); 23383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::deinit(); 23403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 23413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 23433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool BasicUploadCase<SampleType>::runSample (int iteration, UploadSampleResult<SampleType>& sample) 23443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 23453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 23463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int allocatedBufferSize = sample.allocatedSize; 23473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferSize = sample.bufferSize; 23483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType != CASE_NO_BUFFERS) 23503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createBuffer(iteration, allocatedBufferSize); 23513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // warmup CPU before the test to make sure the power management governor 23533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // keeps us in the "high performance" mode 23543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 23553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 23563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 23573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 23583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 23593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testBufferUpload(sample, bufferSize); 23613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Buffer upload sample"); 23623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType != CASE_NO_BUFFERS) 23643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deleteBuffer(bufferSize); 23653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 23673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 23683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 23703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicUploadCase<SampleType>::createBuffer (int iteration, int bufferSize) 23713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 23723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_bufferID); 23733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_caseType != CASE_NO_BUFFERS); 23743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 23763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create buffer 23783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == CASE_NO_BUFFERS) 23803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 23813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create empty buffer 23833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_bufferID); 23853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 23863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Buffer gen"); 23873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == CASE_NEW_BUFFER) 23893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 23903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload something else first, this should reduce noise in samples 23913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rng (0xbadc * iteration); 23933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int sizeDelta = rng.getInt(0, 2097140); 23943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int dummyUploadSize = deAlign32(1048576 + sizeDelta, 4*4); // Vary buffer size to make sure it is always reallocated 23953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<deUint8> dummyData (dummyUploadSize, 0x20); 23963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 23973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_dummyBufferID); 23983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, dummyUploadSize, &dummyData[0], m_bufferUsage); 23993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make sure upload won't interfere with the test 24013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry useBuffer(dummyUploadSize); 24023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // don't kill the buffer so that the following upload cannot potentially reuse the buffer 24043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 24063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 24073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // specify it 24093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == CASE_UNSPECIFIED_BUFFER) 24113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, DE_NULL, m_bufferUsage); 24123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 24133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 24143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<deUint8> dummyData(bufferSize, 0x20); 24153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &dummyData[0], m_bufferUsage); 24163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 24173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == CASE_UNSPECIFIED_BUFFER || m_caseType == CASE_SPECIFIED_BUFFER) 24193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 24203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // use it and make sure it is uploaded 24223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry useBuffer(bufferSize); 24243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_caseType == CASE_USED_BUFFER || m_caseType == CASE_USED_LARGER_BUFFER); 24253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 24263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 24283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicUploadCase<SampleType>::deleteBuffer (int bufferSize) 24293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 24303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_bufferID); 24313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_caseType != CASE_NO_BUFFERS); 24323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // render from the buffer to make sure it actually made it to the gpu. This is to 24343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make sure that if the upload actually happens later or is happening right now in 24353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // the background, it will not interfere with further test runs 24363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if buffer contains unspecified content, sourcing data from it results in undefined 24383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // results, possibly including program termination. Specify all data to prevent such 24393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // case from happening 24403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 24423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 24443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferUnspecifiedContent) 24463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 24473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<deUint8> dummyData(bufferSize, 0x20); 24483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &dummyData[0], m_bufferUsage); 24493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "re-specify buffer"); 24513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 24523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry useBuffer(bufferSize); 24543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &m_bufferID); 24563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_bufferID = 0; 24573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 24583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 24603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicUploadCase<SampleType>::useBuffer (int bufferSize) 24613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 24623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 24633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.useProgram(m_dummyProgram->getProgram()); 24653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(0, 0, DUMMY_RENDER_AREA_SIZE, DUMMY_RENDER_AREA_SIZE); 24673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer(m_dummyProgramPosLoc, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 24683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray(m_dummyProgramPosLoc); 24693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // use whole buffer to make sure buffer is uploaded by drawing first and last 24713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(bufferSize % (int)sizeof(float[4]) == 0); 24723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, 0, 1); 24733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, bufferSize / (int)sizeof(float[4]) - 1, 1); 24743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::waitGLResults(); 24763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 24773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24783c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 24793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BasicUploadCase<SampleType>::logAndSetTestResult (const std::vector<UploadSampleResult<SampleType> >& results) 24803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 24813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadSampleAnalyzeResult analysis = analyzeSampleResults(m_testCtx.getLog(), results, true); 24823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // with small buffers, report the median transfer rate of the samples 24843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // with large buffers, report the expected preformance of infinitely large buffers 24853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float rate = (m_resultType == RESULT_ASYMPTOTIC_TRANSFER_RATE) ? (analysis.transferRateAtInfinity) : (analysis.transferRateMedian); 24863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 24873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (rate == std::numeric_limits<float>::infinity()) 24883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 24893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // sample times are 1) invalid or 2) timer resolution too low 24903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // report speed 0 bytes / s since real value cannot be determined 24913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(0.0f, 2).c_str()); 24923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 24933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 24943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 24953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // report transfer rate in MB / s 24963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(rate / 1024.0f / 1024.0f, 2).c_str()); 24973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 24983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 24993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceMemcpyCase : public BasicUploadCase<SingleOperationDuration> 25013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 25033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceMemcpyCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, bool largeBuffersCase); 25043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ReferenceMemcpyCase (void); 25053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 25073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 25083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 25093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testBufferUpload (UploadSampleResult<SingleOperationDuration>& result, int bufferSize); 25103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint8> m_dstBuf; 25123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 25133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReferenceMemcpyCase::ReferenceMemcpyCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, bool largeBuffersCase) 25153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicUploadCase<SingleOperationDuration> (ctx, name, desc, minBufferSize, maxBufferSize, numSamples, 0, CASE_NO_BUFFERS, (largeBuffersCase) ? (RESULT_ASYMPTOTIC_TRANSFER_RATE) : (RESULT_MEDIAN_TRANSFER_RATE)) 25163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_dstBuf () 25173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry disableGLWarmup(); 25193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25213c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReferenceMemcpyCase::~ReferenceMemcpyCase (void) 25223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceMemcpyCase::init (void) 25263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Describe what the test tries to do 25283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Testing performance of memcpy()." << tcu::TestLog::EndMessage; 25293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dstBuf.resize(m_bufferSizeMax, 0x00); 25313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase<SingleOperationDuration>::init(); 25333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25353c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceMemcpyCase::deinit (void) 25363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_dstBuf.clear(); 25383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase<SingleOperationDuration>::deinit(); 25393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25413c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceMemcpyCase::testBufferUpload (UploadSampleResult<SingleOperationDuration>& result, int bufferSize) 25423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // write 25443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = medianTimeMemcpy(&m_dstBuf[0], &m_zeroData[0], bufferSize); 25453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 25463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize; 25483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferDataUploadCase : public BasicUploadCase<SingleOperationDuration> 25513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 25533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferDataUploadCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, CaseType caseType); 25543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BufferDataUploadCase (void); 25553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 25573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 25583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testBufferUpload (UploadSampleResult<SingleOperationDuration>& result, int bufferSize); 25593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 25603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25613c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferDataUploadCase::BufferDataUploadCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, CaseType caseType) 25623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicUploadCase<SingleOperationDuration>(ctx, name, desc, minBufferSize, maxBufferSize, numSamples, bufferUsage, caseType, RESULT_MEDIAN_TRANSFER_RATE) 25633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25663c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferDataUploadCase::~BufferDataUploadCase (void) 25673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25703c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferDataUploadCase::init (void) 25713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Describe what the test tries to do 25733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Testing glBufferData() function." << tcu::TestLog::EndMessage; 25743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase<SingleOperationDuration>::init(); 25763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferDataUploadCase::testBufferUpload (UploadSampleResult<SingleOperationDuration>& result, int bufferSize) 25793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 25803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 25813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 25833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 25853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 25863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 25873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 25883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 25903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &m_zeroData[0], m_bufferUsage); 25913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 25923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = endTime - startTime; 25943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 25953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize; 25963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 25973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 25983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 25993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferSubDataUploadCase : public BasicUploadCase<SingleOperationDuration> 26003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 26013c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 26023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Flags 26033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 26043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_FULL_UPLOAD = 0x01, 26053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_PARTIAL_UPLOAD = 0x02, 26063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_INVALIDATE_BEFORE_USE = 0x04, 26073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 26083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferSubDataUploadCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, CaseType parentCase, int flags); 26103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BufferSubDataUploadCase (void); 26113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 26133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 26143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testBufferUpload (UploadSampleResult<SingleOperationDuration>& result, int bufferSize); 26153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_fullUpload; 26173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_invalidateBeforeUse; 26183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 26193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferSubDataUploadCase::BufferSubDataUploadCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, CaseType parentCase, int flags) 26213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicUploadCase<SingleOperationDuration> (ctx, name, desc, minBufferSize, maxBufferSize, numSamples, bufferUsage, parentCase, RESULT_MEDIAN_TRANSFER_RATE) 26223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_fullUpload ((flags & FLAG_FULL_UPLOAD) != 0) 26233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_invalidateBeforeUse ((flags & FLAG_INVALIDATE_BEFORE_USE) != 0) 26243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 26253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT((flags & (FLAG_FULL_UPLOAD | FLAG_PARTIAL_UPLOAD)) != 0); 26263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT((flags & (FLAG_FULL_UPLOAD | FLAG_PARTIAL_UPLOAD)) != (FLAG_FULL_UPLOAD | FLAG_PARTIAL_UPLOAD)); 26273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 26283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26293c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferSubDataUploadCase::~BufferSubDataUploadCase (void) 26303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 26313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 26323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferSubDataUploadCase::init (void) 26343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 26353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Describe what the test tries to do 26363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 26373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 26383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing glBufferSubData() function call performance. " 26393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_fullUpload) ? ("The whole buffer is updated with glBufferSubData. ") : ("Half of the buffer data is updated with glBufferSubData. ")) 26403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_invalidateBeforeUse) ? ("The buffer is cleared with glBufferData(..., NULL) before glBufferSubData upload.") : ("")) << "\n" 26413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 26423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase<SingleOperationDuration>::init(); 26443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 26453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferSubDataUploadCase::testBufferUpload (UploadSampleResult<SingleOperationDuration>& result, int bufferSize) 26473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 26483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 26493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 26513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // "invalidate", upload null 26533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_invalidateBeforeUse) 26543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, DE_NULL, m_bufferUsage); 26553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 26573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 26583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 26593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 26603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 26623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_fullUpload) 26643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(GL_ARRAY_BUFFER, 0, bufferSize, &m_zeroData[0]); 26653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 26663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 26673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload to buffer center 26683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(GL_ARRAY_BUFFER, bufferSize / 4, bufferSize / 2, &m_zeroData[0]); 26693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 26703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 26723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = endTime - startTime; 26743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 26753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_fullUpload) 26773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize; 26783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 26793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize / 2; 26803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 26813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 26823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MapBufferRangeCase : public BasicUploadCase<MapBufferRangeDuration> 26843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 26853c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 26863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Flags 26873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 26883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_PARTIAL = 0x01, 26893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_MANUAL_INVALIDATION = 0x02, 26903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_USE_UNUSED_UNSPECIFIED_BUFFER = 0x04, 26913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_USE_UNUSED_SPECIFIED_BUFFER = 0x08, 26923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 26933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapBufferRangeCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, deUint32 mapFlags, int caseFlags); 26953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~MapBufferRangeCase (void); 26963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 26973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 26983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 26993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static CaseType getBaseCaseType (int caseFlags); 27003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static int getBaseFlags (deUint32 mapFlags, int caseFlags); 27013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testBufferUpload (UploadSampleResult<MapBufferRangeDuration>& result, int bufferSize); 27033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void attemptBufferMap (UploadSampleResult<MapBufferRangeDuration>& result, int bufferSize); 27043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_manualInvalidation; 27063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_fullUpload; 27073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_useUnusedUnspecifiedBuffer; 27083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_useUnusedSpecifiedBuffer; 27093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_mapFlags; 27103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_unmapFailures; 27113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 27123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27133c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMapBufferRangeCase::MapBufferRangeCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, deUint32 mapFlags, int caseFlags) 27143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicUploadCase<MapBufferRangeDuration> (ctx, name, desc, minBufferSize, maxBufferSize, numSamples, bufferUsage, getBaseCaseType(caseFlags), RESULT_MEDIAN_TRANSFER_RATE, getBaseFlags(mapFlags, caseFlags)) 27153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_manualInvalidation ((caseFlags&FLAG_MANUAL_INVALIDATION) != 0) 27163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_fullUpload ((caseFlags&FLAG_PARTIAL) == 0) 27173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useUnusedUnspecifiedBuffer ((caseFlags&FLAG_USE_UNUSED_UNSPECIFIED_BUFFER) != 0) 27183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useUnusedSpecifiedBuffer ((caseFlags&FLAG_USE_UNUSED_SPECIFIED_BUFFER) != 0) 27193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_mapFlags (mapFlags) 27203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_unmapFailures (0) 27213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 27223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!(m_useUnusedUnspecifiedBuffer && m_useUnusedSpecifiedBuffer)); 27233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!((m_useUnusedUnspecifiedBuffer || m_useUnusedSpecifiedBuffer) && m_manualInvalidation)); 27243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 27253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMapBufferRangeCase::~MapBufferRangeCase (void) 27273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 27283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 27293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MapBufferRangeCase::init (void) 27313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 27323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Describe what the test tries to do 27333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 27343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 27353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing glMapBufferRange() and glUnmapBuffer() function call performance.\n" 27363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_fullUpload) ? ("The whole buffer is mapped.") : ("Half of the buffer is mapped.")) << "\n" 27373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_useUnusedUnspecifiedBuffer) ? ("The buffer has not been used before mapping and is allocated with unspecified contents.\n") : ("")) 27383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_useUnusedSpecifiedBuffer) ? ("The buffer has not been used before mapping and is allocated with specified contents.\n") : ("")) 27393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((!m_useUnusedSpecifiedBuffer && !m_useUnusedUnspecifiedBuffer) ? ("The buffer has previously been used in a drawing operation.\n") : ("")) 27403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_manualInvalidation) ? ("The buffer is cleared with glBufferData(..., NULL) before mapping.\n") : ("")) 27413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Map bits:\n" 27423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_WRITE_BIT) ? ("\tGL_MAP_WRITE_BIT\n") : ("")) 27433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_READ_BIT) ? ("\tGL_MAP_READ_BIT\n") : ("")) 27443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_RANGE_BIT) ? ("\tGL_MAP_INVALIDATE_RANGE_BIT\n") : ("")) 27453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) ? ("\tGL_MAP_INVALIDATE_BUFFER_BIT\n") : ("")) 27463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_UNSYNCHRONIZED_BIT) ? ("\tGL_MAP_UNSYNCHRONIZED_BIT\n") : ("")) 27473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 27483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase<MapBufferRangeDuration>::init(); 27503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 27513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27523c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMapBufferRangeCase::CaseType MapBufferRangeCase::getBaseCaseType (int caseFlags) 27533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 27543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((caseFlags & FLAG_USE_UNUSED_UNSPECIFIED_BUFFER) == 0 && (caseFlags & FLAG_USE_UNUSED_SPECIFIED_BUFFER) == 0) 27553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CASE_USED_BUFFER; 27563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 27573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CASE_NEW_BUFFER; 27583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 27593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint MapBufferRangeCase::getBaseFlags (deUint32 mapFlags, int caseFlags) 27613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 27623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int flags = FLAG_DONT_LOG_BUFFER_INFO; 27633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // If buffer contains unspecified data when it is sourced (i.e drawn) 27653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // results are undefined, and system errors may occur. Signal parent 27663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // class to take this into account 27673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (caseFlags & FLAG_PARTIAL) 27683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 27693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) != 0 || 27703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (caseFlags & FLAG_MANUAL_INVALIDATION) != 0 || 27713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (caseFlags & FLAG_USE_UNUSED_UNSPECIFIED_BUFFER) != 0) 27723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 27733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flags |= FLAG_RESULT_BUFFER_UNSPECIFIED_CONTENT; 27743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 27753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 27763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return flags; 27783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 27793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MapBufferRangeCase::testBufferUpload (UploadSampleResult<MapBufferRangeDuration>& result, int bufferSize) 27813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 27823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int unmapFailureThreshold = 4; 27833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (; m_unmapFailures < unmapFailureThreshold; ++m_unmapFailures) 27853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 27863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 27873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 27883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attemptBufferMap(result, bufferSize); 27893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 27903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 27913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (UnmapFailureError&) 27923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 27933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 27943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 27953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Unmapping failures exceeded limit"); 27973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 27983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 27993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MapBufferRangeCase::attemptBufferMap (UploadSampleResult<MapBufferRangeDuration>& result, int bufferSize) 28003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 28013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 28023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 28043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_fullUpload) 28063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize; 28073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 28083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize / 2; 28093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create unused buffer 28113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_manualInvalidation || m_useUnusedUnspecifiedBuffer) 28133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 28153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 28163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // "invalidate" or allocate, upload null 28183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 28193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, DE_NULL, m_bufferUsage); 28203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 28213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.allocDuration = endTime - startTime; 28233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_useUnusedSpecifiedBuffer) 28253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 28273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 28283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Specify buffer contents 28303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 28313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &m_zeroData[0], m_bufferUsage); 28323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 28333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.allocDuration = endTime - startTime; 28353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 28373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // No alloc, no time 28393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.allocDuration = 0; 28403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 28433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 28453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Map 28473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 28493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 28503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 28523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_fullUpload) 28533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, 0, result.writtenSize, m_mapFlags); 28543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 28553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload to buffer center 28573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, bufferSize / 4, result.writtenSize, m_mapFlags); 28583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 28603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 28623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::Exception("MapBufferRange returned NULL"); 28633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.mapDuration = endTime - startTime; 28653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Write 28683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.writeDuration = medianTimeMemcpy(mapPtr, &m_zeroData[0], result.writtenSize); 28703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Unmap 28733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 28753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 28763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSuccessful; 28773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 28793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSuccessful = gl.unmapBuffer(GL_ARRAY_BUFFER); 28803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 28813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if unmapping fails, just try again later 28833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!unmapSuccessful) 28843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 28853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.unmapDuration = endTime - startTime; 28873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = result.duration.mapDuration + result.duration.writeDuration + result.duration.unmapDuration + result.duration.allocDuration; 28903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 28913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 28923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 28933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 28943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass MapBufferRangeFlushCase : public BasicUploadCase<MapBufferRangeFlushDuration> 28953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 28963c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 28973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum Flags 28983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 28993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_PARTIAL = 0x01, 29003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_FLUSH_IN_PARTS = 0x02, 29013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_USE_UNUSED_UNSPECIFIED_BUFFER = 0x04, 29023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_USE_UNUSED_SPECIFIED_BUFFER = 0x08, 29033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_FLUSH_PARTIAL = 0x10, 29043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 29053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapBufferRangeFlushCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, deUint32 mapFlags, int caseFlags); 29073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~MapBufferRangeFlushCase (void); 29083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 29103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 29113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static CaseType getBaseCaseType (int caseFlags); 29123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static int getBaseFlags (deUint32 mapFlags, int caseFlags); 29133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testBufferUpload (UploadSampleResult<MapBufferRangeFlushDuration>& result, int bufferSize); 29153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void attemptBufferMap (UploadSampleResult<MapBufferRangeFlushDuration>& result, int bufferSize); 29163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_fullUpload; 29183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_flushInParts; 29193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_flushPartial; 29203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_useUnusedUnspecifiedBuffer; 29213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_useUnusedSpecifiedBuffer; 29223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_mapFlags; 29233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_unmapFailures; 29243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 29253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMapBufferRangeFlushCase::MapBufferRangeFlushCase (Context& ctx, const char* name, const char* desc, int minBufferSize, int maxBufferSize, int numSamples, deUint32 bufferUsage, deUint32 mapFlags, int caseFlags) 29273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicUploadCase<MapBufferRangeFlushDuration> (ctx, name, desc, minBufferSize, maxBufferSize, numSamples, bufferUsage, getBaseCaseType(caseFlags), RESULT_MEDIAN_TRANSFER_RATE, getBaseFlags(mapFlags, caseFlags)) 29283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_fullUpload ((caseFlags&FLAG_PARTIAL) == 0) 29293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_flushInParts ((caseFlags&FLAG_FLUSH_IN_PARTS) != 0) 29303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_flushPartial ((caseFlags&FLAG_FLUSH_PARTIAL) != 0) 29313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useUnusedUnspecifiedBuffer ((caseFlags&FLAG_USE_UNUSED_UNSPECIFIED_BUFFER) != 0) 29323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_useUnusedSpecifiedBuffer ((caseFlags&FLAG_USE_UNUSED_SPECIFIED_BUFFER) != 0) 29333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_mapFlags (mapFlags) 29343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_unmapFailures (0) 29353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 29363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!(m_flushPartial && m_flushInParts)); 29373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!(m_flushPartial && !m_fullUpload)); 29383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 29393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29403c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMapBufferRangeFlushCase::~MapBufferRangeFlushCase (void) 29413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 29423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 29433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MapBufferRangeFlushCase::init (void) 29453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 29463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Describe what the test tries to do 29473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 29483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 29493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing glMapBufferRange(), glFlushMappedBufferRange() and glUnmapBuffer() function call performance.\n" 29503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_fullUpload) ? ("The whole buffer is mapped.") : ("Half of the buffer is mapped.")) << "\n" 29513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_flushInParts) ? 29523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("The mapped range is partitioned to 4 subranges and each partition is flushed separately.") : 29533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_flushPartial) ? 29543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Half of the buffer range is flushed.") : 29553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("The whole mapped range is flushed in one flush call.")) << "\n" 29563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_useUnusedUnspecifiedBuffer) ? ("The buffer has not been used before mapping and is allocated with unspecified contents.\n") : ("")) 29573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_useUnusedSpecifiedBuffer) ? ("The buffer has not been used before mapping and is allocated with specified contents.\n") : ("")) 29583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((!m_useUnusedSpecifiedBuffer && !m_useUnusedUnspecifiedBuffer) ? ("The buffer has previously been used in a drawing operation.\n") : ("")) 29593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Map bits:\n" 29603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_WRITE_BIT) ? ("\tGL_MAP_WRITE_BIT\n") : ("")) 29613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_READ_BIT) ? ("\tGL_MAP_READ_BIT\n") : ("")) 29623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_RANGE_BIT) ? ("\tGL_MAP_INVALIDATE_RANGE_BIT\n") : ("")) 29633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) ? ("\tGL_MAP_INVALIDATE_BUFFER_BIT\n") : ("")) 29643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_UNSYNCHRONIZED_BIT) ? ("\tGL_MAP_UNSYNCHRONIZED_BIT\n") : ("")) 29653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_FLUSH_EXPLICIT_BIT) ? ("\tGL_MAP_FLUSH_EXPLICIT_BIT\n") : ("")) 29663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 29673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicUploadCase<MapBufferRangeFlushDuration>::init(); 29693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 29703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29713c827367444ee418f129b2c238299f49d3264554Jarkko PoyryMapBufferRangeFlushCase::CaseType MapBufferRangeFlushCase::getBaseCaseType (int caseFlags) 29723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 29733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((caseFlags & FLAG_USE_UNUSED_UNSPECIFIED_BUFFER) == 0 && (caseFlags & FLAG_USE_UNUSED_SPECIFIED_BUFFER) == 0) 29743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CASE_USED_BUFFER; 29753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 29763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CASE_NEW_BUFFER; 29773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 29783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29793c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint MapBufferRangeFlushCase::getBaseFlags (deUint32 mapFlags, int caseFlags) 29803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 29813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int flags = FLAG_DONT_LOG_BUFFER_INFO; 29823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // If buffer contains unspecified data when it is sourced (i.e drawn) 29843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // results are undefined, and system errors may occur. Signal parent 29853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // class to take this into account 29863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (caseFlags & FLAG_PARTIAL) 29873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 29883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) != 0 || 29893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (caseFlags & FLAG_USE_UNUSED_UNSPECIFIED_BUFFER) != 0 || 29903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (caseFlags & FLAG_FLUSH_PARTIAL) != 0) 29913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 29923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flags |= FLAG_RESULT_BUFFER_UNSPECIFIED_CONTENT; 29933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 29943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 29953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return flags; 29973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 29983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 29993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MapBufferRangeFlushCase::testBufferUpload (UploadSampleResult<MapBufferRangeFlushDuration>& result, int bufferSize) 30003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 30013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int unmapFailureThreshold = 4; 30023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (; m_unmapFailures < unmapFailureThreshold; ++m_unmapFailures) 30043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 30063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry attemptBufferMap(result, bufferSize); 30083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 30093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (UnmapFailureError&) 30113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Unmapping failures exceeded limit"); 30163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 30173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid MapBufferRangeFlushCase::attemptBufferMap (UploadSampleResult<MapBufferRangeFlushDuration>& result, int bufferSize) 30193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 30203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 30213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int mappedSize = (m_fullUpload) ? (bufferSize) : (bufferSize / 2); 30223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_fullUpload && !m_flushPartial) 30243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize; 30253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 30263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = bufferSize / 2; 30273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 30293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create unused buffer 30313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_useUnusedUnspecifiedBuffer) 30333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 30353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 30363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Don't specify contents 30383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 30393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, DE_NULL, m_bufferUsage); 30403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 30413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.allocDuration = endTime - startTime; 30433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_useUnusedSpecifiedBuffer) 30453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 30473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 30483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Specify buffer contents 30503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 30513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &m_zeroData[0], m_bufferUsage); 30523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 30533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.allocDuration = endTime - startTime; 30553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 30573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // No alloc, no time 30593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.allocDuration = 0; 30603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 30633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 30653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Map 30673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 30693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 30703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 30723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_fullUpload) 30733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, 0, mappedSize, m_mapFlags); 30743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 30753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload to buffer center 30773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, bufferSize / 4, mappedSize, m_mapFlags); 30783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 30803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 30823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::Exception("MapBufferRange returned NULL"); 30833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.mapDuration = endTime - startTime; 30853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Write 30883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_flushPartial) 30903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.writeDuration = medianTimeMemcpy(mapPtr, &m_zeroData[0], result.writtenSize); 30913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 30923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.writeDuration = medianTimeMemcpy((deUint8*)mapPtr + bufferSize / 4, &m_zeroData[0], result.writtenSize); 30933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 30943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 30953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Flush 30963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 30973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 30983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 30993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 31013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_flushPartial) 31033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, mappedSize/4, mappedSize/2); 31043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (!m_flushInParts) 31053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, 0, mappedSize); 31063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 31073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 31083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int p1 = 0; 31093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int p2 = mappedSize / 3; 31103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int p3 = mappedSize / 2; 31113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int p4 = mappedSize * 2 / 4; 31123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int p5 = mappedSize; 31133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // flush in mixed order 31153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, p2, p3-p2); 31163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, p1, p2-p1); 31173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, p4, p5-p4); 31183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, p3, p4-p3); 31193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 31203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 31223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.flushDuration = endTime - startTime; 31243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 31253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Unmap 31273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 31283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 31293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 31303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSuccessful; 31313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 31333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSuccessful = gl.unmapBuffer(GL_ARRAY_BUFFER); 31343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 31353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if unmapping fails, just try again later 31373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!unmapSuccessful) 31383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 31393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.unmapDuration = endTime - startTime; 31413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 31423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = result.duration.mapDuration + result.duration.writeDuration + result.duration.flushDuration + result.duration.unmapDuration + result.duration.allocDuration; 31443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 31453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 31463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 31473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 31493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ModifyAfterBasicCase : public BasicBufferCase<SampleType> 31503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 31513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 31523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase (Context& context, const char* name, const char* description, int bufferSizeMin, int bufferSizeMax, deUint32 usage, bool bufferUnspecifiedAfterTest); 31533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ModifyAfterBasicCase (void); 31543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 31563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 31573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 31593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawBufferRange (int begin, int end); 31603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 31623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 31633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 31643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NUM_SAMPLES = 20, 31653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 31663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool runSample (int iteration, UploadSampleResult<SampleType>& sample); 31693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool prepareAndRunTest (int iteration, UploadSampleResult<SampleType>& result, int bufferSize); 31703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logAndSetTestResult (const std::vector<UploadSampleResult<SampleType> >& results); 31713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void testWithBufferSize (UploadSampleResult<SampleType>& result, int bufferSize) = 0; 31733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_unmappingErrors; 31753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 31773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_bufferUnspecifiedAfterTest; 31783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_bufferUsage; 31793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint8> m_zeroData; 31803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_testCtx; 31823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_context; 31833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::DUMMY_RENDER_AREA_SIZE; 31853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_dummyProgram; 31863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_dummyProgramPosLoc; 31873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_bufferID; 31883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_numSamples; 31893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_bufferSizeMin; 31903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_bufferSizeMax; 31913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using BasicBufferCase<SampleType>::m_allocateLargerBuffer; 31923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 31933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 31943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 31953c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterBasicCase<SampleType>::ModifyAfterBasicCase (Context& context, const char* name, const char* description, int bufferSizeMin, int bufferSizeMax, deUint32 usage, bool bufferUnspecifiedAfterTest) 31963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BasicBufferCase<SampleType> (context, name, description, bufferSizeMin, bufferSizeMax, NUM_SAMPLES, 0) 31973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_unmappingErrors (0) 31983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferUnspecifiedAfterTest (bufferUnspecifiedAfterTest) 31993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferUsage (usage) 32003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_zeroData () 32013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 32033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32043c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 32053c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterBasicCase<SampleType>::~ModifyAfterBasicCase (void) 32063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::deinit(); 32083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 32093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 32113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterBasicCase<SampleType>::init (void) 32123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 32143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // init parent 32163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::init(); 32183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload source 32203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_zeroData.resize(m_bufferSizeMax, 0x00); 32213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log basic info 32233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 32253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 32263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing performance with " << (int)NUM_SAMPLES << " test samples. Sample order is randomized. All samples at even positions (first = 0) are tested before samples at odd positions.\n" 32273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Buffer sizes are in range [" << getHumanReadableByteSize(m_bufferSizeMin) << ", " << getHumanReadableByteSize(m_bufferSizeMax) << "]." 32283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 32293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log which transfer rate is the test result and buffer info 32313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 32333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 32343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the median transfer rate of the test samples.\n" 32353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Buffer usage = " << glu::getUsageName(m_bufferUsage) 32363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 32373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set state for drawing so that we don't have to change these during the iteration 32393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 32403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.useProgram(m_dummyProgram->getProgram()); 32413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(0, 0, DUMMY_RENDER_AREA_SIZE, DUMMY_RENDER_AREA_SIZE); 32423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray(m_dummyProgramPosLoc); 32433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 32443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 32453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 32473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterBasicCase<SampleType>::deinit (void) 32483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_zeroData.clear(); 32503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::deinit(); 32523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 32533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 32553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterBasicCase<SampleType>::drawBufferRange (int begin, int end) 32563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(begin % (int)sizeof(float[4]) == 0); 32583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(end % (int)sizeof(float[4]) == 0); 32593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 32613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // use given range 32633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, begin / (int)sizeof(float[4]), 1); 32643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_POINTS, end / (int)sizeof(float[4]) - 1, 1); 32653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 32663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32673c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 32683c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ModifyAfterBasicCase<SampleType>::runSample (int iteration, UploadSampleResult<SampleType>& sample) 32693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 32713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferSize = sample.bufferSize; 32723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool testOk; 32733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testOk = prepareAndRunTest(iteration, sample, bufferSize); 32753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "Buffer upload sample"); 32763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!testOk) 32783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 32793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int unmapFailureThreshold = 4; 32803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // only unmapping error can cause iteration failure 32823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_unmappingErrors >= unmapFailureThreshold) 32833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Too many unmapping errors, cannot continue."); 32843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // just try again 32863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 32873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 32883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 32903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 32913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 32933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ModifyAfterBasicCase<SampleType>::prepareAndRunTest (int iteration, UploadSampleResult<SampleType>& result, int bufferSize) 32943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 32953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(iteration); 32963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 32973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_bufferID); 32983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(deIsAligned32(bufferSize, 4*4)); // aligned to vec4 32993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 33013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool testRunOk = true; 33023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool unmappingFailed = false; 33033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upload initial buffer to the GPU... 33053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_bufferID); 33063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_bufferID); 33073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &m_zeroData[0], m_bufferUsage); 33083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ...use it... 33103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer(m_dummyProgramPosLoc, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 33113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawBufferRange(0, bufferSize); 33123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // ..and make sure it is uploaded 33143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::waitGLResults(); 33153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // warmup CPU before the test to make sure the power management governor 33173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // keeps us in the "high performance" mode 33183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 33203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 33213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 33223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 33233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // test 33253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 33263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // buffer is uploaded to the GPU. Draw from it. 33283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawBufferRange(0, bufferSize); 33293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // and test upload 33313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testWithBufferSize(result, bufferSize); 33323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 33333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (UnmapFailureError&) 33343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testRunOk = false; 33363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmappingFailed = true; 33373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 33383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // clean up: make sure buffer is not in upload queue and delete it 33403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // sourcing unspecified data causes undefined results, possibly program termination 33423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferUnspecifiedAfterTest || unmappingFailed) 33433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, bufferSize, &m_zeroData[0], m_bufferUsage); 33443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawBufferRange(0, bufferSize); 33463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BasicBufferCase<SampleType>::waitGLResults(); 33473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &m_bufferID); 33493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_bufferID = 0; 33503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return testRunOk; 33523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 33533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 33553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterBasicCase<SampleType>::logAndSetTestResult (const std::vector<UploadSampleResult<SampleType> >& results) 33563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 33573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadSampleAnalyzeResult analysis = analyzeSampleResults(m_testCtx.getLog(), results, false); 33583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Return median transfer rate of the samples 33603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (analysis.transferRateMedian == std::numeric_limits<float>::infinity()) 33623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // sample times are 1) invalid or 2) timer resolution too low 33643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // report speed 0 bytes / s since real value cannot be determined 33653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(0.0f, 2).c_str()); 33663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 33673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 33683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // report transfer rate in MB / s 33703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(analysis.transferRateMedian / 1024.0f / 1024.0f, 2).c_str()); 33713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 33723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 33733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ModifyAfterWithBufferDataCase : public ModifyAfterBasicCase<SingleOperationDuration> 33753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 33763c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 33773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseFlags 33793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_RESPECIFY_SIZE = 0x1, 33813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_UPLOAD_REPEATED = 0x2, 33823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 33833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterWithBufferDataCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags); 33853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ModifyAfterWithBufferDataCase (void); 33863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 33883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 33893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 33903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testWithBufferSize (UploadSampleResult<SingleOperationDuration>& result, int bufferSize); 33913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 33933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 33943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NUM_REPEATS = 2 33953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 33963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 33973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_respecifySize; 33983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_repeatedUpload; 33993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float m_sizeDifferenceFactor; 34003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 34013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34023c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithBufferDataCase::ModifyAfterWithBufferDataCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags) 34033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ModifyAfterBasicCase<SingleOperationDuration> (context, name, desc, bufferSizeMin, bufferSizeMax, usage, false) 34043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_respecifySize ((flags & FLAG_RESPECIFY_SIZE) != 0) 34053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_repeatedUpload ((flags & FLAG_UPLOAD_REPEATED) != 0) 34063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_sizeDifferenceFactor (1.3f) 34073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 34083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!(m_repeatedUpload && m_respecifySize)); 34093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 34103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34113c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithBufferDataCase::~ModifyAfterWithBufferDataCase (void) 34123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 34133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 34143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 34153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithBufferDataCase::init (void) 34173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 34183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log the purpose of the test 34193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_repeatedUpload) 34213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Testing performance of BufferData() command after \"specify buffer contents - draw buffer\" command pair is repeated " << (int)NUM_REPEATS << " times." << tcu::TestLog::EndMessage; 34223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 34233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Testing performance of BufferData() command after a draw command that sources data from the target buffer." << tcu::TestLog::EndMessage; 34243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 34263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 34273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_respecifySize) ? 34283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Buffer size is increased and contents are modified with BufferData().\n") : 34293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Buffer contents are modified with BufferData().\n")) 34303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 34313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // init parent 34333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<SingleOperationDuration>::init(); 34343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make sure our zeroBuffer is large enough 34363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_respecifySize) 34373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 34383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int largerBufferSize = deAlign32((int)(m_bufferSizeMax * m_sizeDifferenceFactor), 4*4); 34393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_zeroData.resize(largerBufferSize, 0x00); 34403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 34413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 34423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithBufferDataCase::deinit (void) 34443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 34453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<SingleOperationDuration>::deinit(); 34463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 34473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithBufferDataCase::testWithBufferSize (UploadSampleResult<SingleOperationDuration>& result, int bufferSize) 34493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 34503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // always draw the same amount to make compares between cases sensible 34513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int drawStart = deAlign32(bufferSize / 4, 4*4); 34523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int drawEnd = deAlign32(bufferSize * 3 / 4, 4*4); 34533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 34553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int largerBufferSize = deAlign32((int)(bufferSize * m_sizeDifferenceFactor), 4*4); 34563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int newBufferSize = (m_respecifySize) ? (largerBufferSize) : (bufferSize); 34573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 34583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 34593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // repeat upload-draw 34613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_repeatedUpload) 34623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 34633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int repeatNdx = 0; repeatNdx < NUM_REPEATS; ++repeatNdx) 34643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 34653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, newBufferSize, &m_zeroData[0], m_bufferUsage); 34663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawBufferRange(drawStart, drawEnd); 34673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 34683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 34693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // test upload 34713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 34723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, newBufferSize, &m_zeroData[0], m_bufferUsage); 34733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 34743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = endTime - startTime; 34763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 34773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = newBufferSize; 34783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 34793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ModifyAfterWithBufferSubDataCase : public ModifyAfterBasicCase<SingleOperationDuration> 34813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 34823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 34833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseFlags 34853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 34863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_PARTIAL = 0x1, 34873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_UPLOAD_REPEATED = 0x2, 34883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 34893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterWithBufferSubDataCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags); 34913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ModifyAfterWithBufferSubDataCase (void); 34923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 34943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 34953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 34963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testWithBufferSize (UploadSampleResult<SingleOperationDuration>& result, int bufferSize); 34973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 34983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 34993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 35003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NUM_REPEATS = 2 35013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 35023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_partialUpload; 35043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_repeatedUpload; 35053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 35063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35073c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithBufferSubDataCase::ModifyAfterWithBufferSubDataCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags) 35083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ModifyAfterBasicCase<SingleOperationDuration> (context, name, desc, bufferSizeMin, bufferSizeMax, usage, false) 35093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_partialUpload ((flags & FLAG_PARTIAL) != 0) 35103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_repeatedUpload ((flags & FLAG_UPLOAD_REPEATED) != 0) 35113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 35123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 35133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithBufferSubDataCase::~ModifyAfterWithBufferSubDataCase (void) 35153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 35163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 35173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 35183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35193c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithBufferSubDataCase::init (void) 35203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 35213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log the purpose of the test 35223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_repeatedUpload) 35243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Testing performance of BufferSubData() command after \"specify buffer contents - draw buffer\" command pair is repeated " << (int)NUM_REPEATS << " times." << tcu::TestLog::EndMessage; 35253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 35263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Testing performance of BufferSubData() command after a draw command that sources data from the target buffer." << tcu::TestLog::EndMessage; 35273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 35293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 35303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_partialUpload) ? 35313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Half of the buffer contents are modified.\n") : 35323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Buffer contents are fully respecified.\n")) 35333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 35343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<SingleOperationDuration>::init(); 35363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 35373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithBufferSubDataCase::deinit (void) 35393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 35403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<SingleOperationDuration>::deinit(); 35413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 35423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithBufferSubDataCase::testWithBufferSize (UploadSampleResult<SingleOperationDuration>& result, int bufferSize) 35443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 35453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // always draw the same amount to make compares between cases sensible 35463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int drawStart = deAlign32(bufferSize / 4, 4*4); 35473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int drawEnd = deAlign32(bufferSize * 3 / 4, 4*4); 35483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 35503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int subdataOffset = deAlign32((m_partialUpload) ? (bufferSize / 4) : (0), 4*4); 35513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int subdataSize = deAlign32((m_partialUpload) ? (bufferSize / 2) : (bufferSize), 4*4); 35523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 35533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 35543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make upload-draw stream 35563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_repeatedUpload) 35573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 35583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int repeatNdx = 0; repeatNdx < NUM_REPEATS; ++repeatNdx) 35593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 35603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(GL_ARRAY_BUFFER, subdataOffset, subdataSize, &m_zeroData[0]); 35613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawBufferRange(drawStart, drawEnd); 35623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 35633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 35643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // test upload 35663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 35673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(GL_ARRAY_BUFFER, subdataOffset, subdataSize, &m_zeroData[0]); 35683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 35693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = endTime - startTime; 35713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 35723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = subdataSize; 35733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 35743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ModifyAfterWithMapBufferRangeCase : public ModifyAfterBasicCase<MapBufferRangeDurationNoAlloc> 35763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 35773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 35783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseFlags 35803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 35813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_PARTIAL = 0x1, 35823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 35833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterWithMapBufferRangeCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags, deUint32 glMapFlags); 35853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ModifyAfterWithMapBufferRangeCase (void); 35863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 35883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 35893c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 35903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static bool isBufferUnspecifiedAfterUpload (int flags, deUint32 mapFlags); 35913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testWithBufferSize (UploadSampleResult<MapBufferRangeDurationNoAlloc>& result, int bufferSize); 35923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_partialUpload; 35943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_mapFlags; 35953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 35963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 35973c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithMapBufferRangeCase::ModifyAfterWithMapBufferRangeCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags, deUint32 glMapFlags) 35983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ModifyAfterBasicCase<MapBufferRangeDurationNoAlloc> (context, name, desc, bufferSizeMin, bufferSizeMax, usage, isBufferUnspecifiedAfterUpload(flags, glMapFlags)) 35993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_partialUpload ((flags & FLAG_PARTIAL) != 0) 36003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_mapFlags (glMapFlags) 36013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 36033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36043c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithMapBufferRangeCase::~ModifyAfterWithMapBufferRangeCase (void) 36053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 36073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 36083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36093c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithMapBufferRangeCase::init (void) 36103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log the purpose of the test 36123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 36143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 36153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing performance of MapBufferRange() command after a draw command that sources data from the target buffer.\n" 36163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_partialUpload) ? 36173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Half of the buffer is mapped.\n") : 36183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Whole buffer is mapped.\n")) 36193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Map bits:\n" 36203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_WRITE_BIT) ? ("\tGL_MAP_WRITE_BIT\n") : ("")) 36213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_READ_BIT) ? ("\tGL_MAP_READ_BIT\n") : ("")) 36223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_RANGE_BIT) ? ("\tGL_MAP_INVALIDATE_RANGE_BIT\n") : ("")) 36233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) ? ("\tGL_MAP_INVALIDATE_BUFFER_BIT\n") : ("")) 36243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_UNSYNCHRONIZED_BIT) ? ("\tGL_MAP_UNSYNCHRONIZED_BIT\n") : ("")) 36253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_FLUSH_EXPLICIT_BIT) ? ("\tGL_MAP_FLUSH_EXPLICIT_BIT\n") : ("")) 36263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 36273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<MapBufferRangeDurationNoAlloc>::init(); 36293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 36303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithMapBufferRangeCase::deinit (void) 36323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<MapBufferRangeDurationNoAlloc>::deinit(); 36343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 36353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36363c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ModifyAfterWithMapBufferRangeCase::isBufferUnspecifiedAfterUpload (int flags, deUint32 mapFlags) 36373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((flags & FLAG_PARTIAL) != 0 && ((mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) != 0)) 36393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 36403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 36423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 36433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithMapBufferRangeCase::testWithBufferSize (UploadSampleResult<MapBufferRangeDurationNoAlloc>& result, int bufferSize) 36453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 36473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int subdataOffset = deAlign32((m_partialUpload) ? (bufferSize / 4) : (0), 4*4); 36483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int subdataSize = deAlign32((m_partialUpload) ? (bufferSize / 2) : (bufferSize), 4*4); 36493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 36503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // map 36523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 36533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 36543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 36553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 36573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, subdataOffset, subdataSize, m_mapFlags); 36583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 36593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 36613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("mapBufferRange returned null"); 36623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.mapDuration = endTime - startTime; 36643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 36653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // write 36673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 36683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.writeDuration = medianTimeMemcpy(mapPtr, &m_zeroData[0], subdataSize); 36693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 36703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // unmap 36723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 36733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 36743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 36753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSucceeded; 36763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 36783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSucceeded = gl.unmapBuffer(GL_ARRAY_BUFFER); 36793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 36803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (unmapSucceeded != GL_TRUE) 36823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 36833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.unmapDuration = endTime - startTime; 36853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 36863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = result.duration.mapDuration + result.duration.writeDuration + result.duration.unmapDuration; 36883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 36893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = subdataSize; 36903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 36913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ModifyAfterWithMapBufferFlushCase : public ModifyAfterBasicCase<MapBufferRangeFlushDurationNoAlloc> 36933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 36943c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 36953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 36963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseFlags 36973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 36983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_PARTIAL = 0x1, 36993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 37003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterWithMapBufferFlushCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags, deUint32 glMapFlags); 37023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~ModifyAfterWithMapBufferFlushCase (void); 37033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 37053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 37063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 37073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static bool isBufferUnspecifiedAfterUpload (int flags, deUint32 mapFlags); 37083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void testWithBufferSize (UploadSampleResult<MapBufferRangeFlushDurationNoAlloc>& result, int bufferSize); 37093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_partialUpload; 37113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 m_mapFlags; 37123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 37133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithMapBufferFlushCase::ModifyAfterWithMapBufferFlushCase (Context& context, const char* name, const char* desc, int bufferSizeMin, int bufferSizeMax, deUint32 usage, int flags, deUint32 glMapFlags) 37153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ModifyAfterBasicCase<MapBufferRangeFlushDurationNoAlloc> (context, name, desc, bufferSizeMin, bufferSizeMax, usage, isBufferUnspecifiedAfterUpload(flags, glMapFlags)) 37163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_partialUpload ((flags & FLAG_PARTIAL) != 0) 37173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_mapFlags (glMapFlags) 37183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 37193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 37203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37213c827367444ee418f129b2c238299f49d3264554Jarkko PoyryModifyAfterWithMapBufferFlushCase::~ModifyAfterWithMapBufferFlushCase (void) 37223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 37233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 37243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 37253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37263c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithMapBufferFlushCase::init (void) 37273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 37283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log the purpose of the test 37293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 37313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 37323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Testing performance of MapBufferRange() command after a draw command that sources data from the target buffer.\n" 37333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_partialUpload) ? 37343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Half of the buffer is mapped.\n") : 37353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Whole buffer is mapped.\n")) 37363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Map bits:\n" 37373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_WRITE_BIT) ? ("\tGL_MAP_WRITE_BIT\n") : ("")) 37383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_READ_BIT) ? ("\tGL_MAP_READ_BIT\n") : ("")) 37393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_RANGE_BIT) ? ("\tGL_MAP_INVALIDATE_RANGE_BIT\n") : ("")) 37403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) ? ("\tGL_MAP_INVALIDATE_BUFFER_BIT\n") : ("")) 37413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_UNSYNCHRONIZED_BIT) ? ("\tGL_MAP_UNSYNCHRONIZED_BIT\n") : ("")) 37423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags & GL_MAP_FLUSH_EXPLICIT_BIT) ? ("\tGL_MAP_FLUSH_EXPLICIT_BIT\n") : ("")) 37433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 37443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<MapBufferRangeFlushDurationNoAlloc>::init(); 37463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 37473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithMapBufferFlushCase::deinit (void) 37493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 37503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ModifyAfterBasicCase<MapBufferRangeFlushDurationNoAlloc>::deinit(); 37513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 37523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool ModifyAfterWithMapBufferFlushCase::isBufferUnspecifiedAfterUpload (int flags, deUint32 mapFlags) 37543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 37553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((flags & FLAG_PARTIAL) != 0 && ((mapFlags & GL_MAP_INVALIDATE_BUFFER_BIT) != 0)) 37563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 37573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 37593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 37603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ModifyAfterWithMapBufferFlushCase::testWithBufferSize (UploadSampleResult<MapBufferRangeFlushDurationNoAlloc>& result, int bufferSize) 37623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 37633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 37643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int subdataOffset = deAlign32((m_partialUpload) ? (bufferSize / 4) : (0), 4*4); 37653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int subdataSize = deAlign32((m_partialUpload) ? (bufferSize / 2) : (bufferSize), 4*4); 37663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 37673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // map 37693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 37703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 37713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 37723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 37743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, subdataOffset, subdataSize, m_mapFlags); 37753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 37763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 37783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("mapBufferRange returned null"); 37793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.mapDuration = endTime - startTime; 37813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 37823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // write 37843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 37853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.writeDuration = medianTimeMemcpy(mapPtr, &m_zeroData[0], subdataSize); 37863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 37873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // flush 37893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 37903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 37913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 37923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 37943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flushMappedBufferRange(GL_ARRAY_BUFFER, 0, subdataSize); 37953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 37963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 37973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.flushDuration = endTime - startTime; 37983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 37993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // unmap 38013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 38023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 38033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 38043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSucceeded; 38053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 38073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSucceeded = gl.unmapBuffer(GL_ARRAY_BUFFER); 38083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 38093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (unmapSucceeded != GL_TRUE) 38113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 38123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.unmapDuration = endTime - startTime; 38143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 38153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.totalDuration = result.duration.mapDuration + result.duration.writeDuration + result.duration.unmapDuration + result.duration.flushDuration; 38173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.duration.fitResponseDuration = result.duration.totalDuration; 38183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.writtenSize = subdataSize; 38193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 38203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum DrawMethod 38223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS = 0, 38243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 38253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_LAST 38273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum TargetBuffer 38303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX = 0, 38323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 38333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_LAST 38353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum BufferState 38383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BUFFERSTATE_NEW = 0, 38403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BUFFERSTATE_EXISTING, 38413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BUFFERSTATE_LAST 38433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38453c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum UploadMethod 38463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADMETHOD_BUFFER_DATA = 0, 38483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADMETHOD_BUFFER_SUB_DATA, 38493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADMETHOD_MAP_BUFFER_RANGE, 38503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADMETHOD_LAST 38523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum UnrelatedBufferType 38553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNRELATEDBUFFERTYPE_NONE = 0, 38573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNRELATEDBUFFERTYPE_VERTEX, 38583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UNRELATEDBUFFERTYPE_LAST 38603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum UploadRange 38633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADRANGE_FULL = 0, 38653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADRANGE_PARTIAL, 38663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADRANGE_LAST 38683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct LayeredGridSpec 38713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int gridWidth; 38733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int gridHeight; 38743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int gridLayers; 38753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 38763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic int getLayeredGridNumVertices (const LayeredGridSpec& scene) 38783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return scene.gridWidth * scene.gridHeight * scene.gridLayers * 6; 38803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 38813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38823c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void generateLayeredGridVertexAttribData4C4V (std::vector<tcu::Vec4>& vertexData, const LayeredGridSpec& scene) 38833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 38843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // interleave color & vertex data 38853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 green (0.0f, 1.0f, 0.0f, 0.7f); 38863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 yellow (1.0f, 1.0f, 0.0f, 0.8f); 38873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData.resize(getLayeredGridNumVertices(scene) * 2); 38893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 38903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int cellY = 0; cellY < scene.gridHeight; ++cellY) 38913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int cellX = 0; cellX < scene.gridWidth; ++cellX) 38923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int cellZ = 0; cellZ < scene.gridLayers; ++cellZ) 38933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 38943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 color = (((cellX + cellY + cellZ) % 2) == 0) ? (green) : (yellow); 38953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float cellLeft = (float(cellX ) / scene.gridWidth - 0.5f) * 2.0f; 38963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float cellRight = (float(cellX+1) / scene.gridWidth - 0.5f) * 2.0f; 38973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float cellTop = (float(cellY+1) / scene.gridHeight - 0.5f) * 2.0f; 38983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float cellBottom = (float(cellY ) / scene.gridHeight - 0.5f) * 2.0f; 38993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 0] = color; 39013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 1] = tcu::Vec4(cellLeft, cellTop, 0.0f, 1.0f); 39023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 2] = color; 39043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 3] = tcu::Vec4(cellLeft, cellBottom, 0.0f, 1.0f); 39053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 4] = color; 39073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 5] = tcu::Vec4(cellRight, cellBottom, 0.0f, 1.0f); 39083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 6] = color; 39103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 7] = tcu::Vec4(cellLeft, cellTop, 0.0f, 1.0f); 39113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 8] = color; 39133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 9] = tcu::Vec4(cellRight, cellBottom, 0.0f, 1.0f); 39143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 10] = color; 39163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vertexData[(cellY * scene.gridWidth * scene.gridLayers + cellX * scene.gridLayers + cellZ) * 12 + 11] = tcu::Vec4(cellRight, cellTop, 0.0f, 1.0f); 39173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 39183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 39193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39203c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void generateLayeredGridIndexData (std::vector<deUint32>& indexData, const LayeredGridSpec& scene) 39213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indexData.resize(getLayeredGridNumVertices(scene) * 2); 39233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < scene.gridLayers * scene.gridHeight * scene.gridWidth * 6; ++ndx) 39253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry indexData[ndx] = ndx; 39263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 39273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderPerformanceTestBase : public TestCase 39293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 39313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderPerformanceTestBase (Context& context, const char* name, const char* description); 39323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RenderPerformanceTestBase (void); 39333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 39353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 39363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 39373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void waitGLResults (void) const; 39393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setupVertexAttribs (void) const; 39403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 39423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 39433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RENDER_AREA_SIZE = 128 39443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 39453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 39473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_renderProgram; 39483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_colorLoc; 39493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_positionLoc; 39503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 39513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39523c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderPerformanceTestBase::RenderPerformanceTestBase (Context& context, const char* name, const char* description) 39533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, tcu::NODETYPE_PERFORMANCE, name, description) 39543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderProgram (DE_NULL) 39553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_colorLoc (0) 39563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_positionLoc (0) 39573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 39593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39603c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderPerformanceTestBase::~RenderPerformanceTestBase (void) 39613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 39633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 39643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39653c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderPerformanceTestBase::init (void) 39663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 39683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderProgram = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(s_colorVertexShader) << glu::FragmentSource(s_colorFragmentShader)); 39703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_renderProgram->isOk()) 39713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 39723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *m_renderProgram; 39733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("could not build program"); 39743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 39753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_colorLoc = gl.getAttribLocation(m_renderProgram->getProgram(), "a_color"); 39773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_positionLoc = gl.getAttribLocation(m_renderProgram->getProgram(), "a_position"); 39783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_colorLoc == -1) 39803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Location of attribute a_color was -1"); 39813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_positionLoc == -1) 39823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Location of attribute a_position was -1"); 39833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 39843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderPerformanceTestBase::deinit (void) 39863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_renderProgram; 39883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderProgram = DE_NULL; 39893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 39903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderPerformanceTestBase::setupVertexAttribs (void) const 39923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 39933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 39943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // buffers are bound 39963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 39973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray(m_colorLoc); 39983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray(m_positionLoc); 39993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer(m_colorLoc, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(8 * sizeof(float)), (const tcu::Vec4*)DE_NULL + 0); 40013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer(m_positionLoc, 4, GL_FLOAT, GL_FALSE, (glw::GLsizei)(8 * sizeof(float)), (const tcu::Vec4*)DE_NULL + 1); 40023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.useProgram(m_renderProgram->getProgram()); 40043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "set up rendering"); 40063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 40073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderPerformanceTestBase::waitGLResults (void) const 40093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 40103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface dummySurface(RENDER_AREA_SIZE, RENDER_AREA_SIZE); 40113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, dummySurface.getAccess()); 40123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 40133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 40153c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RenderCase : public RenderPerformanceTestBase 40163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 40173c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 40183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase (Context& context, const char* name, const char* description, DrawMethod drawMethod); 40193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RenderCase (void); 40203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 40223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 40233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 40243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 40263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 40273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40283c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 40293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct SampleResult 40303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 40313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LayeredGridSpec scene; 40323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderSampleResult<SampleType> result; 40333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 40343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMinWorkloadSize (void) const; 40363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMaxWorkloadSize (void) const; 40373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMinWorkloadDataSize (void) const; 40383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getMaxWorkloadDataSize (void) const; 40393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getVertexDataSize (void) const; 40403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumSamples (void) const; 40413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void uploadScene (const LayeredGridSpec& scene); 40423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void runSample (SampleResult& sample) = 0; 40443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void logAndSetTestResult (const std::vector<SampleResult>& results); 40453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void mapResultsToRenderRateFormat (std::vector<RenderSampleResult<SampleType> >& dst, const std::vector<SampleResult>& src) const; 40473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const DrawMethod m_drawMethod; 40493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 40513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_attributeBufferID; 40523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_indexBufferID; 40533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iterationNdx; 40543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<int> m_iterationOrder; 40553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<SampleResult> m_results; 40563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numUnmapFailures; 40573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 40583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40593c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 40603c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderCase<SampleType>::RenderCase (Context& context, const char* name, const char* description, DrawMethod drawMethod) 40613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderPerformanceTestBase (context, name, description) 40623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_drawMethod (drawMethod) 40633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_attributeBufferID (0) 40643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexBufferID (0) 40653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationNdx (0) 40663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numUnmapFailures (0) 40673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 40683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(drawMethod < DRAWMETHOD_LAST); 40693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 40703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 40723c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRenderCase<SampleType>::~RenderCase (void) 40733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 40743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 40753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 40763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40773c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 40783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderCase<SampleType>::init (void) 40793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 40803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 40813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderPerformanceTestBase::init(); 40833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // requirements 40853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_context.getRenderTarget().getWidth() < RENDER_AREA_SIZE || 40873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderTarget().getHeight() < RENDER_AREA_SIZE) 40883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Test case requires " + de::toString<int>(RENDER_AREA_SIZE) + "x" + de::toString<int>(RENDER_AREA_SIZE) + " render target"); 40893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // gl state 40913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(0, 0, RENDER_AREA_SIZE, RENDER_AREA_SIZE); 40933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // enable bleding to prevent grid layers from being discarded 40953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 40963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.blendEquation(GL_FUNC_ADD); 40973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enable(GL_BLEND); 40983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 40993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generate iterations 41003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int gridSizes[] = { 20, 26, 32, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, 104, 110, 116, 122, 128 }; 41033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int gridNdx = 0; gridNdx < DE_LENGTH_OF_ARRAY(gridSizes); ++gridNdx) 41053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.push_back(SampleResult()); 41073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().scene.gridHeight = gridSizes[gridNdx]; 41093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().scene.gridWidth = gridSizes[gridNdx]; 41103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().scene.gridLayers = 5; 41113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().result.numVertices = getLayeredGridNumVertices(m_results.back().scene); 41133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // test cases set these, initialize to dummy values 41153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().result.renderDataSize = -1; 41163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().result.uploadedDataSize = -1; 41173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.back().result.unrelatedDataSize = -1; 41183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // randomize iteration order 41223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iterationOrder.resize(m_results.size()); 41243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateTwoPassRandomIterationOrder(m_iterationOrder, (int)m_iterationOrder.size()); 41253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 41273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 41293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderCase<SampleType>::deinit (void) 41303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 41313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderPerformanceTestBase::deinit(); 41323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_attributeBufferID) 41343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_attributeBufferID); 41363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_attributeBufferID = 0; 41373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_indexBufferID) 41403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_indexBufferID); 41423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBufferID = 0; 41433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 41453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 41473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytypename RenderCase<SampleType>::IterateResult RenderCase<SampleType>::iterate (void) 41483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 41493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int unmapFailureThreshold = 3; 41503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int currentIteration = m_iterationNdx; 41513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int currentConfigNdx = m_iterationOrder[currentIteration]; 41523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SampleResult& currentSample = m_results[currentConfigNdx]; 41533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 41553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry runSample(currentSample); 41573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++m_iterationNdx; 41583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (const UnmapFailureError& ex) 41603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(ex); 41623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++m_numUnmapFailures; 41633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_numUnmapFailures > unmapFailureThreshold) 41663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Got too many unmap errors"); 41673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_iterationNdx < (int)m_iterationOrder.size()) 41693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 41703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAndSetTestResult(m_results); 41723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 41733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 41743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41753c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 41763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint RenderCase<SampleType>::getMinWorkloadSize (void) const 41773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 41783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int result = getLayeredGridNumVertices(m_results[0].scene); 41793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 1; ndx < (int)m_results.size(); ++ndx) 41813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int workloadSize = getLayeredGridNumVertices(m_results[ndx].scene); 41833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = de::min(result, workloadSize); 41843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return result; 41873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 41883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 41903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint RenderCase<SampleType>::getMaxWorkloadSize (void) const 41913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 41923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int result = getLayeredGridNumVertices(m_results[0].scene); 41933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 41943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 1; ndx < (int)m_results.size(); ++ndx) 41953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 41963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int workloadSize = getLayeredGridNumVertices(m_results[ndx].scene); 41973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result = de::max(result, workloadSize); 41983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 41993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return result; 42013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint RenderCase<SampleType>::getMinWorkloadDataSize (void) const 42053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return getMinWorkloadSize() * getVertexDataSize(); 42073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42093c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint RenderCase<SampleType>::getMaxWorkloadDataSize (void) const 42113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return getMaxWorkloadSize() * getVertexDataSize(); 42133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42153c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint RenderCase<SampleType>::getVertexDataSize (void) const 42173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVectors = 2; 42193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int vec4Size = 4 * sizeof(float); 42203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return numVectors * vec4Size; 42223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint RenderCase<SampleType>::getNumSamples (void) const 42263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (int)m_results.size(); 42283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42303c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderCase<SampleType>::uploadScene (const LayeredGridSpec& scene) 42323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 42343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // vertex buffer 42363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 42373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> vertexData; 42383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(vertexData, scene); 42403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_attributeBufferID == 0) 42423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_attributeBufferID); 42433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_attributeBufferID); 42443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (int)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STATIC_DRAW); 42453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 42463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // index buffer 42483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 42493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 42503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> indexData; 42513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridIndexData(indexData, scene); 42533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_indexBufferID == 0) 42553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_indexBufferID); 42563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBufferID); 42573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (int)(indexData.size() * sizeof(deUint32)), &indexData[0], GL_STATIC_DRAW); 42583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 42593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "create buffers"); 42613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42643c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderCase<SampleType>::logAndSetTestResult (const std::vector<SampleResult>& results) 42653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<RenderSampleResult<SampleType> > mappedResults; 42673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapResultsToRenderRateFormat(mappedResults, results); 42693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 42713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const RenderSampleAnalyzeResult analysis = analyzeSampleResults(m_testCtx.getLog(), mappedResults); 42723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float rate = analysis.renderRateAtRange; 42733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (rate == std::numeric_limits<float>::infinity()) 42753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 42763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // sample times are 1) invalid or 2) timer resolution too low 42773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(0.0f, 2).c_str()); 42783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 42793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 42803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 42813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // report transfer rate in millions of MiB/s 42823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(rate / 1024.0f / 1024.0f, 2).c_str()); 42833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 42843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 42853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 42883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RenderCase<SampleType>::mapResultsToRenderRateFormat (std::vector<RenderSampleResult<SampleType> >& dst, const std::vector<SampleResult>& src) const 42893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.resize(src.size()); 42913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)src.size(); ++ndx) 42933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[ndx] = src[ndx].result; 42943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 42953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 42963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceRenderTimeCase : public RenderCase<RenderReadDuration> 42973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 42983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 42993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceRenderTimeCase (Context& context, const char* name, const char* description, DrawMethod drawMethod); 43003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 43023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 43033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void runSample (SampleResult& sample); 43043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 43053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43063c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReferenceRenderTimeCase::ReferenceRenderTimeCase (Context& context, const char* name, const char* description, DrawMethod drawMethod) 43073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderCase<RenderReadDuration> (context, name, description, drawMethod) 43083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 43093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 43103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceRenderTimeCase::init (void) 43123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 43133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* const targetFunctionName = (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) ? ("drawArrays") : ("drawElements"); 43143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // init parent 43163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<RenderReadDuration>::init(); 43173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 43193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 43203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 43213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Measuring the time used in " << targetFunctionName << " and readPixels call with different rendering workloads.\n" 43223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getNumSamples() << " test samples. Sample order is randomized.\n" 43233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "All samples at even positions (first = 0) are tested before samples at odd positions.\n" 43243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Generated workload is multiple viewport-covering grids with varying number of cells, each cell is two separate triangles.\n" 43253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Workload sizes are in the range [" 43263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getMinWorkloadSize() << ", " 43273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getMaxWorkloadSize() << "] vertices ([" 43283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMinWorkloadDataSize()) << "," 43293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMaxWorkloadDataSize()) << "] to be processed).\n" 43303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the approximated total processing rate in MiB / s.\n" 43313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) ? ("Note that index array size is not included in the processed size.\n") : ("")) 43323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Note! Test result should only be used as a baseline reference result for buffer.data_upload.* test group results." 43333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 43343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 43353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43363c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceRenderTimeCase::runSample (SampleResult& sample) 43373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 43383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 43393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultSurface (RENDER_AREA_SIZE, RENDER_AREA_SIZE); 43403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVertices = getLayeredGridNumVertices(sample.scene); 43413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer arrayBuffer (m_context.getRenderContext()); 43423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer indexBuffer (m_context.getRenderContext()); 43433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> vertexData; 43443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> indexData; 43453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 43463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 43473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generate and upload buffers 43493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(vertexData, sample.scene); 43513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *arrayBuffer); 43523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (int)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STATIC_DRAW); 43533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 43553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 43563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridIndexData(indexData, sample.scene); 43573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *indexBuffer); 43583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (int)(indexData.size() * sizeof(deUint32)), &indexData[0], GL_STATIC_DRAW); 43593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 43603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 43623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make sure data is uploaded 43643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 43663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 43673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 43683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 43693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 43703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 43713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 43723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f); 43743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT); 43753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 43763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 43783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Measure both draw and associated readpixels 43803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 43813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 43823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 43843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 43853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 43863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 43873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 43883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 43893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 43913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderDuration = endTime - startTime; 43933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 43943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 43953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 43963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 43973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 43983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 43993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.readDuration = endTime - startTime; 44013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 44023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.renderDataSize = getVertexDataSize() * sample.result.numVertices; 44043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.uploadedDataSize = 0; 44053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.unrelatedDataSize = 0; 44063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderReadDuration = sample.result.duration.renderDuration + sample.result.duration.readDuration; 44073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.totalDuration = sample.result.duration.renderDuration + sample.result.duration.readDuration; 44083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.fitResponseDuration = sample.result.duration.renderReadDuration; 44093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 44103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UnrelatedUploadRenderTimeCase : public RenderCase<UnrelatedUploadRenderReadDuration> 44123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 44133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 44143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UnrelatedUploadRenderTimeCase (Context& context, const char* name, const char* description, DrawMethod drawMethod, UploadMethod unrelatedUploadMethod); 44153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 44173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 44183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void runSample (SampleResult& sample); 44193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadMethod m_unrelatedUploadMethod; 44213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 44223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44233c827367444ee418f129b2c238299f49d3264554Jarkko PoyryUnrelatedUploadRenderTimeCase::UnrelatedUploadRenderTimeCase (Context& context, const char* name, const char* description, DrawMethod drawMethod, UploadMethod unrelatedUploadMethod) 44243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderCase<UnrelatedUploadRenderReadDuration> (context, name, description, drawMethod) 44253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_unrelatedUploadMethod (unrelatedUploadMethod) 44263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 44273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_unrelatedUploadMethod < UPLOADMETHOD_LAST); 44283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 44293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UnrelatedUploadRenderTimeCase::init (void) 44313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 44323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* const targetFunctionName = (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) ? ("drawArrays") : ("drawElements"); 44333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::MessageBuilder message (&m_testCtx.getLog()); 44343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // init parent 44363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<UnrelatedUploadRenderReadDuration>::init(); 44373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 44393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message 44413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Measuring the time used in " << targetFunctionName << " and readPixels call with different rendering workloads.\n" 44423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Uploading an unrelated buffer just before issuing the rendering command with " 44433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_unrelatedUploadMethod != UPLOADMETHOD_BUFFER_DATA) ? ("bufferData") : 44443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_unrelatedUploadMethod != UPLOADMETHOD_BUFFER_SUB_DATA) ? ("bufferSubData") : 44453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_unrelatedUploadMethod != UPLOADMETHOD_MAP_BUFFER_RANGE) ? ("mapBufferRange") : 44463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 44473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ".\n" 44483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getNumSamples() << " test samples. Sample order is randomized.\n" 44493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "All samples at even positions (first = 0) are tested before samples at odd positions.\n" 44503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Generated workload is multiple viewport-covering grids with varying number of cells, each cell is two separate triangles.\n" 44513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Workload sizes are in the range [" 44523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getMinWorkloadSize() << ", " 44533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getMaxWorkloadSize() << "] vertices ([" 44543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMinWorkloadDataSize()) << "," 44553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMaxWorkloadDataSize()) << "] to be processed).\n" 44563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Unrelated upload sizes are in the range [" 44573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMinWorkloadDataSize()) << ", " 44583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMaxWorkloadDataSize()) << "]\n" 44593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the approximated total processing rate in MiB / s.\n" 44603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) ? ("Note that index array size is not included in the processed size.\n") : ("")) 44613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Note that the data size and the time used in the unrelated upload is not included in the results.\n" 44623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Note! Test result may not be useful as is but instead should be compared against the reference.* group and upload_and_draw.*_and_unrelated_upload group results.\n" 44633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 44643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 44653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UnrelatedUploadRenderTimeCase::runSample (SampleResult& sample) 44673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 44683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 44693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultSurface (RENDER_AREA_SIZE, RENDER_AREA_SIZE); 44703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVertices = getLayeredGridNumVertices(sample.scene); 44713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer arrayBuffer (m_context.getRenderContext()); 44723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer indexBuffer (m_context.getRenderContext()); 44733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer unrelatedBuffer (m_context.getRenderContext()); 44743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int unrelatedUploadSize = -1; 44753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int renderUploadSize; 44763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> vertexData; 44773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> indexData; 44783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 44793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 44803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generate and upload buffers 44823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(vertexData, sample.scene); 44843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderUploadSize = (int)(vertexData.size() * sizeof(tcu::Vec4)); 44853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *arrayBuffer); 44873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, renderUploadSize, &vertexData[0], GL_STATIC_DRAW); 44883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 44903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 44913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridIndexData(indexData, sample.scene); 44923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *indexBuffer); 44933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (int)(indexData.size() * sizeof(deUint32)), &indexData[0], GL_STATIC_DRAW); 44943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 44953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 44973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 44983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make sure data is uploaded 44993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 45013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 45023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 45033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 45043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 45053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 45063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 45073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f); 45093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT); 45103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 45113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 45133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Unrelated upload 45153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_unrelatedUploadMethod == UPLOADMETHOD_BUFFER_DATA) 45163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 45173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unrelatedUploadSize = (int)(vertexData.size() * sizeof(tcu::Vec4)); 45183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *unrelatedBuffer); 45203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, unrelatedUploadSize, &vertexData[0], GL_STATIC_DRAW); 45213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 45223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_unrelatedUploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) 45233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 45243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unrelatedUploadSize = (int)(vertexData.size() * sizeof(tcu::Vec4)); 45253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *unrelatedBuffer); 45273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, unrelatedUploadSize, DE_NULL, GL_STATIC_DRAW); 45283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(GL_ARRAY_BUFFER, 0, unrelatedUploadSize, &vertexData[0]); 45293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 45303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_unrelatedUploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) 45313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 45323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 45333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSuccessful; 45343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unrelatedUploadSize = (int)(vertexData.size() * sizeof(tcu::Vec4)); 45363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *unrelatedBuffer); 45383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, unrelatedUploadSize, DE_NULL, GL_STATIC_DRAW); 45393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(GL_ARRAY_BUFFER, 0, unrelatedUploadSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT); 45413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 45423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::Exception("MapBufferRange returned NULL"); 45433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy(mapPtr, &vertexData[0], unrelatedUploadSize); 45453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if unmapping fails, just try again later 45473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSuccessful = gl.unmapBuffer(GL_ARRAY_BUFFER); 45483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!unmapSuccessful) 45493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 45503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 45513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 45523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 45533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(unrelatedUploadSize != -1); 45553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Measure both draw and associated readpixels 45573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 45583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 45593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 45613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 45623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 45633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 45643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 45653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 45663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 45683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderDuration = endTime - startTime; 45703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 45713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 45733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 45743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 45753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 45763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.readDuration = endTime - startTime; 45783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 45793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.renderDataSize = getVertexDataSize() * sample.result.numVertices; 45813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.uploadedDataSize = renderUploadSize; 45823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.unrelatedDataSize = unrelatedUploadSize; 45833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderReadDuration = sample.result.duration.renderDuration + sample.result.duration.readDuration; 45843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.totalDuration = sample.result.duration.renderDuration + sample.result.duration.readDuration; 45853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.fitResponseDuration = sample.result.duration.renderReadDuration; 45863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 45873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass ReferenceReadPixelsTimeCase : public TestCase 45893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 45903c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 45913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ReferenceReadPixelsTimeCase (Context& context, const char* name, const char* description); 45923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 45943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 45953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 45963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logAndSetTestResult (void); 45973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 45983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 45993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 46003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RENDER_AREA_SIZE = 128 46013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 46023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_numSamples; 46043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_sampleNdx; 46053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<int> m_samples; 46063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 46073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46083c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReferenceReadPixelsTimeCase::ReferenceReadPixelsTimeCase (Context& context, const char* name, const char* description) 46093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, tcu::NODETYPE_PERFORMANCE, name, description) 46103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numSamples (20) 46113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_sampleNdx (0) 46123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_samples (m_numSamples) 46133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 46143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 46153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceReadPixelsTimeCase::init (void) 46173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 46183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 46193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 46203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Measuring the time used in a single readPixels call with " << m_numSamples << " test samples.\n" 46213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the median of the samples in microseconds.\n" 46223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Note! Test result should only be used as a baseline reference result for buffer.data_upload.* test group results." 46233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 46243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 46253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46263c827367444ee418f129b2c238299f49d3264554Jarkko PoyryReferenceReadPixelsTimeCase::IterateResult ReferenceReadPixelsTimeCase::iterate (void) 46273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 46283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 46293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultSurface (RENDER_AREA_SIZE, RENDER_AREA_SIZE); 46303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 46313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 46323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 46343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 46353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deYield(); 46363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // "Render" something and wait for it 46383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clearColor(0.0f, 1.0f, m_sampleNdx / float(m_numSamples), 1.0f); 46393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT); 46403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // wait for results 46423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 46433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // measure time used in readPixels 46453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 46463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 46473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 46483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_samples[m_sampleNdx] = (int)(endTime - startTime); 46503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_sampleNdx < m_numSamples) 46523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 46533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAndSetTestResult(); 46553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 46563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 46573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid ReferenceReadPixelsTimeCase::logAndSetTestResult (void) 46593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 46603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log sample list 46613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 46623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 46633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleList("Samples", "Samples") 46643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 46653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 46663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 46673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)m_samples.size(); ++sampleNdx) 46693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 46703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Sample 46713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << m_samples[sampleNdx] 46723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 46733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::EndSampleList; 46753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 46763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log median 46783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 46793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float median; 46803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float limit60Low; 46813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float limit60Up; 46823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(m_samples.begin(), m_samples.end()); 46843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry median = linearSample(m_samples, 0.5f); 46853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry limit60Low = linearSample(m_samples, 0.2f); 46863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry limit60Up = linearSample(m_samples, 0.8f); 46873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 46893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Median", "Median", "us", QP_KEY_TAG_TIME, median) 46903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 46913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "60 % of samples within range:\n" 46923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage 46933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("Low60Range", "Lower", "us", QP_KEY_TAG_TIME, limit60Low) 46943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Float("High60Range", "Upper", "us", QP_KEY_TAG_TIME, limit60Up); 46953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 46963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::floatToString(median, 2).c_str()); 46973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 46983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 46993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 47013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass GenericUploadRenderTimeCase : public RenderCase<SampleType> 47023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 47033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 47043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef typename RenderCase<SampleType>::SampleResult SampleResult; 47053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GenericUploadRenderTimeCase (Context& context, 47073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 47083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description, 47093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod method, 47103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer, 47113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod, 47123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferState bufferState, 47133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadRange uploadRange, 47143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UnrelatedBufferType unrelatedBufferType); 47153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47163c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 47173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 47183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void runSample (SampleResult& sample); 47193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using RenderCase<SampleType>::RENDER_AREA_SIZE; 47213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TargetBuffer m_targetBuffer; 47233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const BufferState m_bufferState; 47243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadMethod m_uploadMethod; 47253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UnrelatedBufferType m_unrelatedBufferType; 47263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadRange m_uploadRange; 47273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using RenderCase<SampleType>::m_context; 47293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using RenderCase<SampleType>::m_testCtx; 47303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using RenderCase<SampleType>::m_drawMethod; 47313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 47323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47333c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 47343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryGenericUploadRenderTimeCase<SampleType>::GenericUploadRenderTimeCase (Context& context, 47353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 47363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description, 47373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod method, 47383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer, 47393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod, 47403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferState bufferState, 47413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadRange uploadRange, 47423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UnrelatedBufferType unrelatedBufferType) 47433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderCase<SampleType> (context, name, description, method) 47443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_targetBuffer (targetBuffer) 47453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferState (bufferState) 47463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_uploadMethod (uploadMethod) 47473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_unrelatedBufferType (unrelatedBufferType) 47483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_uploadRange (uploadRange) 47493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 47503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_targetBuffer < TARGETBUFFER_LAST); 47513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_bufferState < BUFFERSTATE_LAST); 47523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_uploadMethod < UPLOADMETHOD_LAST); 47533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_unrelatedBufferType < UNRELATEDBUFFERTYPE_LAST); 47543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_uploadRange < UPLOADRANGE_LAST); 47553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 47563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 47583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GenericUploadRenderTimeCase<SampleType>::init (void) 47593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 47603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // init parent 47613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<SampleType>::init(); 47623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 47643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 47653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* const targetFunctionName = (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) ? ("drawArrays") : ("drawElements"); 47663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int perVertexSize = (m_targetBuffer == TARGETBUFFER_INDEX) ? (sizeof(deUint32)) : (sizeof(tcu::Vec4[2])); 47673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int fullMinUploadSize = RenderCase<SampleType>::getMinWorkloadSize() * perVertexSize; 47683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int fullMaxUploadSize = RenderCase<SampleType>::getMaxWorkloadSize() * perVertexSize; 47693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int minUploadSize = (m_uploadRange == UPLOADRANGE_FULL) ? (fullMinUploadSize) : (deAlign32(fullMinUploadSize/2, 4)); 47703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int maxUploadSize = (m_uploadRange == UPLOADRANGE_FULL) ? (fullMaxUploadSize) : (deAlign32(fullMaxUploadSize/2, 4)); 47713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int minUnrelatedUploadSize = RenderCase<SampleType>::getMinWorkloadSize() * sizeof(tcu::Vec4[2]); 47723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int maxUnrelatedUploadSize = RenderCase<SampleType>::getMaxWorkloadSize() * sizeof(tcu::Vec4[2]); 47733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 47743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 47753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 47763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Measuring the time used in " << targetFunctionName << " and readPixels call with different rendering workloads.\n" 47773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "The " 47783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_targetBuffer == TARGETBUFFER_INDEX) ? ("index") : ("vertex attrib")) 47793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " buffer " 47803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_bufferState == BUFFERSTATE_NEW) ? ("") : ("contents ")) 47813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "sourced by the rendering command " 47823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_bufferState == BUFFERSTATE_NEW) ? ("is uploaded ") : 47833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadRange == UPLOADRANGE_FULL) ? ("are specified ") : 47843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadRange == UPLOADRANGE_PARTIAL) ? ("are updated (partial upload) ") : 47853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 47863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "just before issuing the rendering command.\n" 47873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_bufferState == BUFFERSTATE_EXISTING) ? ("The buffer has been used in rendering.\n") : ("The buffer is generated just before uploading.\n")) 47883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Buffer " 47893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_bufferState == BUFFERSTATE_NEW) ? ("is uploaded") : 47903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadRange == UPLOADRANGE_FULL) ? ("contents are specified") : 47913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadRange == UPLOADRANGE_PARTIAL) ? ("contents are partially updated") : 47923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 47933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " with " 47943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_uploadMethod == UPLOADMETHOD_BUFFER_DATA) ? ("bufferData") : (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) ? ("bufferSubData") : ("mapBufferRange")) 47953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " command. Usage of the target buffer is DYNAMIC_DRAW.\n" 47963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_uploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) ? ("Mapping buffer with bits MAP_WRITE_BIT | MAP_INVALIDATE_RANGE_BIT | MAP_INVALIDATE_BUFFER_BIT | MAP_UNSYNCHRONIZED_BIT\n") : ("")) 47973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_unrelatedBufferType == UNRELATEDBUFFERTYPE_VERTEX) ? ("Uploading an unrelated buffer just before issuing the rendering command with bufferData.\n") : ("")) 47983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << RenderCase<SampleType>::getNumSamples() << " test samples. Sample order is randomized.\n" 47993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "All samples at even positions (first = 0) are tested before samples at odd positions.\n" 48003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Generated workload is multiple viewport-covering grids with varying number of cells, each cell is two separate triangles.\n" 48013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Workload sizes are in the range [" 48023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << RenderCase<SampleType>::getMinWorkloadSize() << ", " 48033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << RenderCase<SampleType>::getMaxWorkloadSize() << "] vertices " 48043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "([" 48053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(RenderCase<SampleType>::getMinWorkloadDataSize()) << "," 48063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(RenderCase<SampleType>::getMaxWorkloadDataSize()) << "] to be processed).\n" 48073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Upload sizes are in the range [" 48083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(minUploadSize) << "," 48093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(maxUploadSize) << "].\n" 48103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) ? 48113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("Unrelated upload sizes are in the range [" + getHumanReadableByteSize(minUnrelatedUploadSize) + ", " + getHumanReadableByteSize(maxUnrelatedUploadSize) + "]\n") : 48123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ("")) 48133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the approximated processing rate in MiB / s.\n" 48143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Note that while upload time is measured, the time used is not included in the results.\n" 48153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_unrelatedBufferType == UNRELATEDBUFFERTYPE_VERTEX) ? ("Note that the data size and the time used in the unrelated upload is not included in the results.\n") : ("")) 48163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) ? ("Note that index array size is not included in the processed size.\n") : ("")) 48173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Note! Test result may not be useful as is but instead should be compared against the reference.* group and other upload_and_draw.* group results.\n" 48183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 48193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 48213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename SampleType> 48233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid GenericUploadRenderTimeCase<SampleType>::runSample (SampleResult& sample) 48243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 48253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 48263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer arrayBuffer (m_context.getRenderContext()); 48273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer indexBuffer (m_context.getRenderContext()); 48283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer unrelatedBuffer (m_context.getRenderContext()); 48293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVertices = getLayeredGridNumVertices(sample.scene); 48303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultSurface (RENDER_AREA_SIZE, RENDER_AREA_SIZE); 48313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 48323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 48333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> vertexData; 48343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> indexData; 48353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create data 48373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(vertexData, sample.scene); 48393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 48403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridIndexData(indexData, sample.scene); 48413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *arrayBuffer); 48433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *indexBuffer); 48443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<SampleType>::setupVertexAttribs(); 48453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // target should be an exisiting buffer? Draw from it once to make sure it exists on the gpu 48473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS && m_bufferState == BUFFERSTATE_EXISTING) 48493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 48503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_DYNAMIC_DRAW); 48513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 48523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS && m_bufferState == BUFFERSTATE_NEW) 48543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 48553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // do not touch the vertex buffer 48563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS && m_bufferState == BUFFERSTATE_EXISTING) 48583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 48593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // hint that the target buffer will be modified soon 48603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum vertexDataUsage = (m_targetBuffer == TARGETBUFFER_VERTEX) ? (GL_DYNAMIC_DRAW) : (GL_STATIC_DRAW); 48613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum indexDataUsage = (m_targetBuffer == TARGETBUFFER_INDEX) ? (GL_DYNAMIC_DRAW) : (GL_STATIC_DRAW); 48623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], vertexDataUsage); 48643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (glw::GLsizeiptr)(indexData.size() * sizeof(deUint32)), &indexData[0], indexDataUsage); 48653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 48663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS && m_bufferState == BUFFERSTATE_NEW) 48683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 48693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX) 48703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 48713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make the index buffer present on the gpu 48723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // use another vertex buffer to keep original buffer in unused state 48733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer vertexCopyBuffer(m_context.getRenderContext()); 48743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *vertexCopyBuffer); 48763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<SampleType>::setupVertexAttribs(); 48773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STATIC_DRAW); 48793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (glw::GLsizeiptr)(indexData.size() * sizeof(deUint32)), &indexData[0], GL_STATIC_DRAW); 48803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 48813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // restore original state 48833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *arrayBuffer); 48843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<SampleType>::setupVertexAttribs(); 48853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX) 48873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 48883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make the vertex buffer present on the gpu 48893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STATIC_DRAW); 48903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 48913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 48933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 48943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 48953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 48963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 48973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 48983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<SampleType>::waitGLResults(); 48993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "post buffer prepare"); 49003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f); 49023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT); 49033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<SampleType>::waitGLResults(); 49043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 49063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 49083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum target; 49113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizeiptr size; 49123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLintptr offset = 0; 49133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* source; 49143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX && m_uploadRange == UPLOADRANGE_FULL) 49163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ARRAY_BUFFER; 49183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)); 49193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = &vertexData[0]; 49203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX && m_uploadRange == UPLOADRANGE_FULL) 49223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ELEMENT_ARRAY_BUFFER; 49243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)(indexData.size() * sizeof(deUint32)); 49253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = &indexData[0]; 49263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_VERTEX && m_uploadRange == UPLOADRANGE_PARTIAL) 49283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_bufferState == BUFFERSTATE_EXISTING); 49303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ARRAY_BUFFER; 49323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)deAlign32((int)(vertexData.size() * sizeof(tcu::Vec4)) / 2, 4); 49333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offset = (glw::GLintptr)deAlign32((int)size / 2, 4); 49343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = (const deUint8*)&vertexData[0] + offset; 49353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX && m_uploadRange == UPLOADRANGE_PARTIAL) 49373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_bufferState == BUFFERSTATE_EXISTING); 49393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload to 25% - 75% range 49413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ELEMENT_ARRAY_BUFFER; 49423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)deAlign32((glw::GLsizeiptr)((int)(indexData.size() * sizeof(deUint32))) / 2, 4); 49433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offset = (glw::GLintptr)deAlign32((int)size / 2, 4); 49443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = (const deUint8*)&indexData[0] + offset; 49453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 49473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 49493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 49503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 49533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadMethod == UPLOADMETHOD_BUFFER_DATA) 49553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(target, size, source, GL_DYNAMIC_DRAW); 49563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) 49573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create buffer storage 49593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferState == BUFFERSTATE_NEW) 49603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(target, size, DE_NULL, GL_DYNAMIC_DRAW); 49613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(target, offset, size, source); 49623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_uploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) 49643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 49663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSuccessful; 49673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create buffer storage 49693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferState == BUFFERSTATE_NEW) 49703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(target, size, DE_NULL, GL_DYNAMIC_DRAW); 49713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(target, offset, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT); 49733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 49743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::Exception("MapBufferRange returned NULL"); 49753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy(mapPtr, source, (int)size); 49773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if unmapping fails, just try again later 49793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSuccessful = gl.unmapBuffer(target); 49803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!unmapSuccessful) 49813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 49823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 49843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 49853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 49873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.uploadedDataSize = (int)size; 49893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.uploadDuration = endTime - startTime; 49903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 49913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // unrelated 49933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_unrelatedBufferType == UNRELATEDBUFFERTYPE_VERTEX) 49943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 49953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int unrelatedUploadSize = (int)(vertexData.size() * sizeof(tcu::Vec4)); 49963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 49973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *unrelatedBuffer); 49983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, unrelatedUploadSize, &vertexData[0], GL_STATIC_DRAW); 49993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Attibute pointers are not modified, no need restore state 50003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.unrelatedDataSize = unrelatedUploadSize; 50023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 50033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw 50053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 50063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 50073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 50093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 50103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 50113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 50123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 50133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 50143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 50163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderDuration = endTime - startTime; 50183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 50193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // read 50213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 50223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 50233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 50243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 50253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.readDuration = endTime - startTime; 50273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 50283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // set results 50303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.renderDataSize = RenderCase<SampleType>::getVertexDataSize() * sample.result.numVertices; 50323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderReadDuration = sample.result.duration.renderDuration + sample.result.duration.readDuration; 50343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.totalDuration = sample.result.duration.uploadDuration + sample.result.duration.renderDuration + sample.result.duration.readDuration; 50353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.fitResponseDuration = sample.result.duration.renderReadDuration; 50363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 50373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BufferInUseRenderTimeCase : public RenderCase<RenderUploadRenderReadDuration> 50393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 50403c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 50413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum MapFlags 50423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 50433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MAPFLAG_NONE = 0, 50443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MAPFLAG_INVALIDATE_BUFFER, 50453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MAPFLAG_INVALIDATE_RANGE, 50463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MAPFLAG_LAST 50483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 50493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum UploadBufferTarget 50503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 50513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADBUFFERTARGET_DIFFERENT_BUFFER = 0, 50523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADBUFFERTARGET_SAME_BUFFER, 50533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UPLOADBUFFERTARGET_LAST 50553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 50563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferInUseRenderTimeCase (Context& context, 50573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 50583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description, 50593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod method, 50603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapFlags mapFlags, 50613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer, 50623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod, 50633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadRange uploadRange, 50643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadBufferTarget uploadTarget); 50653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 50673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 50683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void runSample (SampleResult& sample); 50693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TargetBuffer m_targetBuffer; 50713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadMethod m_uploadMethod; 50723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadRange m_uploadRange; 50733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const MapFlags m_mapFlags; 50743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadBufferTarget m_uploadBufferTarget; 50753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 50763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 50773c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferInUseRenderTimeCase::BufferInUseRenderTimeCase (Context& context, 50783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 50793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description, 50803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod method, 50813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry MapFlags mapFlags, 50823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer, 50833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod, 50843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadRange uploadRange, 50853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadBufferTarget uploadTarget) 50863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderCase<RenderUploadRenderReadDuration> (context, name, description, method) 50873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_targetBuffer (targetBuffer) 50883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_uploadMethod (uploadMethod) 50893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_uploadRange (uploadRange) 50903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_mapFlags (mapFlags) 50913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_uploadBufferTarget (uploadTarget) 50923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 50933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_targetBuffer < TARGETBUFFER_LAST); 50943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_uploadMethod < UPLOADMETHOD_LAST); 50953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_uploadRange < UPLOADRANGE_LAST); 50963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_mapFlags < MAPFLAG_LAST); 50973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_uploadBufferTarget < UPLOADBUFFERTARGET_LAST); 50983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 50993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferInUseRenderTimeCase::init (void) 51013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 51023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderCase<RenderUploadRenderReadDuration>::init(); 51033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 51053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 51063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* const targetFunctionName = (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) ? ("drawArrays") : ("drawElements"); 51073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* const uploadFunctionName = (m_uploadMethod == UPLOADMETHOD_BUFFER_DATA) ? ("bufferData") : (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) ? ("bufferSubData") : ("mapBufferRange"); 51083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool isReferenceCase = (m_uploadBufferTarget == UPLOADBUFFERTARGET_DIFFERENT_BUFFER); 51093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::MessageBuilder message (&m_testCtx.getLog()); 51103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << "Measuring the time used in " << targetFunctionName << " call, a buffer upload, " 51123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << targetFunctionName << " call using the uploaded buffer and readPixels call with different upload sizes.\n"; 51133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isReferenceCase) 51153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << "Rendering:\n" 51163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " before test: create and use buffers B and C\n" 51173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " first draw: render using buffer B\n" 51183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_uploadRange == UPLOADRANGE_FULL) ? (" upload: respecify buffer C contents\n") : 51193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadRange == UPLOADRANGE_PARTIAL) ? (" upload: modify buffer C contents\n") : 51203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 51213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " second draw: render using buffer C\n" 51223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " read: readPixels\n"; 51233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 51243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << "Rendering:\n" 51253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " before test: create and use buffer B\n" 51263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " first draw: render using buffer B\n" 51273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_uploadRange == UPLOADRANGE_FULL) ? (" upload: respecify buffer B contents\n") : 51283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadRange == UPLOADRANGE_PARTIAL) ? (" upload: modify buffer B contents\n") : 51293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 51303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " second draw: render using buffer B\n" 51313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " read: readPixels\n"; 51323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << "Uploading using " << uploadFunctionName 51343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_mapFlags == MAPFLAG_INVALIDATE_RANGE) ? (", flags = MAP_WRITE_BIT | MAP_INVALIDATE_RANGE_BIT") : 51353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_mapFlags == MAPFLAG_INVALIDATE_BUFFER) ? (", flags = MAP_WRITE_BIT | MAP_INVALIDATE_BUFFER_BIT") : 51363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_mapFlags == MAPFLAG_NONE) ? ("") : 51373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 51383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n" 51393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getNumSamples() << " test samples. Sample order is randomized.\n" 51403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "All samples at even positions (first = 0) are tested before samples at odd positions.\n" 51413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Workload sizes are in the range [" 51423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getMinWorkloadSize() << ", " 51433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getMaxWorkloadSize() << "] vertices " 51443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "([" 51453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMinWorkloadDataSize()) << "," 51463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << getHumanReadableByteSize(getMaxWorkloadDataSize()) << "] to be processed).\n" 51473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the approximated processing rate in MiB / s of the second draw call and the readPixels call.\n"; 51483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (isReferenceCase) 51503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << "Note! Test result should only be used as a baseline reference result for buffer.render_after_upload.draw_modify_draw test group results."; 51513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 51523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << "Note! Test result may not be useful as is but instead should be compared against the buffer.render_after_upload.reference.draw_upload_draw group results.\n"; 51533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry message << tcu::TestLog::EndMessage; 51553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 51563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 51573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferInUseRenderTimeCase::runSample (SampleResult& sample) 51593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 51603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 51613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer arrayBuffer (m_context.getRenderContext()); 51623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer indexBuffer (m_context.getRenderContext()); 51633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer alternativeUploadBuffer (m_context.getRenderContext()); 51643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numVertices = getLayeredGridNumVertices(sample.scene); 51653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultSurface (RENDER_AREA_SIZE, RENDER_AREA_SIZE); 51663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 51673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 51683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> vertexData; 51693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> indexData; 51703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create data 51723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(vertexData, sample.scene); 51743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 51753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridIndexData(indexData, sample.scene); 51763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // make buffers used 51783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *arrayBuffer); 51803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *indexBuffer); 51813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 51823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 51843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 51853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STREAM_DRAW); 51863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 51873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 51883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 51893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 51903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STREAM_DRAW); 51913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (glw::GLsizeiptr)(indexData.size() * sizeof(deUint32)), &indexData[0], GL_STREAM_DRAW); 51923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 51933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 51943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 51953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 51963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 51973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // another pair of buffers for reference case 51983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadBufferTarget == UPLOADBUFFERTARGET_DIFFERENT_BUFFER) 51993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX) 52013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *alternativeUploadBuffer); 52033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)), &vertexData[0], GL_STREAM_DRAW); 52043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 52063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 52073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX) 52093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *alternativeUploadBuffer); 52113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (glw::GLsizeiptr)(indexData.size() * sizeof(deUint32)), &indexData[0], GL_STREAM_DRAW); 52123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 52133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 52153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 52163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // restore state 52183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *arrayBuffer); 52193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, *indexBuffer); 52203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 52213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 52243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "post buffer prepare"); 52253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clearColor(0.0f, 0.0f, 0.0f, 1.0f); 52273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT); 52283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 52293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::warmupCPU(); 52313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // first draw 52333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 52353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 52373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 52383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 52393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 52403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 52413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 52423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 52443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.firstRenderDuration = endTime - startTime; 52463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 52493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum target; 52513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizeiptr size; 52523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLintptr offset = 0; 52533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* source; 52543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX && m_uploadRange == UPLOADRANGE_FULL) 52563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ARRAY_BUFFER; 52583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)(vertexData.size() * sizeof(tcu::Vec4)); 52593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = &vertexData[0]; 52603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX && m_uploadRange == UPLOADRANGE_FULL) 52623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ELEMENT_ARRAY_BUFFER; 52643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)(indexData.size() * sizeof(deUint32)); 52653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = &indexData[0]; 52663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_VERTEX && m_uploadRange == UPLOADRANGE_PARTIAL) 52683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ARRAY_BUFFER; 52703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)deAlign32((int)(vertexData.size() * sizeof(tcu::Vec4)) / 2, 4); 52713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offset = (glw::GLintptr)deAlign32((int)size / 2, 4); 52723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = (const deUint8*)&vertexData[0] + offset; 52733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX && m_uploadRange == UPLOADRANGE_PARTIAL) 52753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload to 25% - 75% range 52773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ELEMENT_ARRAY_BUFFER; 52783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)deAlign32((glw::GLsizeiptr)((int)(indexData.size() * sizeof(deUint32))) / 2, 4); 52793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry offset = (glw::GLintptr)deAlign32((int)size / 2, 4); 52803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = (const deUint8*)&indexData[0] + offset; 52813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 52833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 52843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 52853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 52863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 52873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // reference case? don't modify the buffer in use 52893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadBufferTarget == UPLOADBUFFERTARGET_DIFFERENT_BUFFER) 52903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(target, *alternativeUploadBuffer); 52913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 52933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 52943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadMethod == UPLOADMETHOD_BUFFER_DATA) 52953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(target, size, source, GL_STREAM_DRAW); 52963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) 52973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(target, offset, size, source); 52983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_uploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) 52993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 53003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int mapFlags = (m_mapFlags == MAPFLAG_INVALIDATE_BUFFER) ? (GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT) : 53013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_mapFlags == MAPFLAG_INVALIDATE_RANGE) ? (GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT) : 53023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (-1); 53033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 53043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSuccessful; 53053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(target, offset, size, mapFlags); 53073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 53083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::Exception("MapBufferRange returned NULL"); 53093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy(mapPtr, source, (int)size); 53113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if unmapping fails, just try again later 53133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSuccessful = gl.unmapBuffer(target); 53143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!unmapSuccessful) 53153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 53163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 53173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 53183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 53193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 53213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.uploadedDataSize = (int)size; 53233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.uploadDuration = endTime - startTime; 53243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 53253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // second draw 53273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 53283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Source vertex data from alternative buffer in refernce case 53293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadBufferTarget == UPLOADBUFFERTARGET_DIFFERENT_BUFFER && m_targetBuffer == TARGETBUFFER_VERTEX) 53303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 53313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 53333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 53353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, numVertices); 53363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 53373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, numVertices, GL_UNSIGNED_INT, DE_NULL); 53383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 53393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 53403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 53423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.secondRenderDuration = endTime - startTime; 53443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 53453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // read 53473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 53483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 53493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 53503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 53513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.readDuration = endTime - startTime; 53533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 53543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // set results 53563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.renderDataSize = getVertexDataSize() * sample.result.numVertices; 53583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.renderReadDuration = sample.result.duration.secondRenderDuration + sample.result.duration.readDuration; 53603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.totalDuration = sample.result.duration.firstRenderDuration + 53613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.uploadDuration + 53623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.secondRenderDuration + 53633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.readDuration; 53643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.result.duration.fitResponseDuration = sample.result.duration.renderReadDuration; 53653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 53663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53673c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass UploadWaitDrawCase : public RenderPerformanceTestBase 53683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 53693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 53703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct Sample 53713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 53723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numFrames; 53733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 uploadCallEndTime; 53743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 53753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct Result 53763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 53773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 uploadDuration; 53783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderDuration; 53793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 readDuration; 53803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 renderReadDuration; 53813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 timeBeforeUse; 53833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 53843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadWaitDrawCase (Context& context, 53863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 53873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description, 53883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod, 53893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer, 53903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod, 53913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferState bufferState); 53923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~UploadWaitDrawCase (void); 53933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 53953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 53963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 53973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 53983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 53993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void uploadBuffer (Sample& sample, Result& result); 54003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawFromBuffer (Sample& sample, Result& result); 54013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void reuseAndDeleteBuffer (void); 54023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logAndSetTestResult (void); 54033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void logSamples (void); 54043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawMisc (void); 54053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int findStabilizationSample (deUint64 (Result::*target), const char* description); 54063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool checkSampleTemporalStability (deUint64 (Result::*target), const char* description); 54073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const DrawMethod m_drawMethod; 54093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TargetBuffer m_targetBuffer; 54103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const UploadMethod m_uploadMethod; 54113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const BufferState m_bufferState; 54123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_numSamplesPerSwap; 54143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_numMaxSwaps; 54153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_frameNdx; 54173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_sampleNdx; 54183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numVertices; 54193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> m_vertexData; 54213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint32> m_indexData; 54223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<Sample> m_samples; 54233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<Result> m_results; 54243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<int> m_iterationOrder; 54253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_vertexBuffer; 54273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_indexBuffer; 54283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_miscBuffer; 54293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numMiscVertices; 54303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 54313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryUploadWaitDrawCase::UploadWaitDrawCase (Context& context, 54333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name, 54343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description, 54353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod, 54363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer, 54373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod, 54383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferState bufferState) 54393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : RenderPerformanceTestBase (context, name, description) 54403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_drawMethod (drawMethod) 54413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_targetBuffer (targetBuffer) 54423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_uploadMethod (uploadMethod) 54433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_bufferState (bufferState) 54443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numSamplesPerSwap (10) 54453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numMaxSwaps (4) 54463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_frameNdx (0) 54473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_sampleNdx (0) 54483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numVertices (-1) 54493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_vertexBuffer (0) 54503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_indexBuffer (0) 54513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_miscBuffer (0) 54523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numMiscVertices (-1) 54533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 54543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 54553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54563c827367444ee418f129b2c238299f49d3264554Jarkko PoyryUploadWaitDrawCase::~UploadWaitDrawCase (void) 54573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 54583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 54593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 54603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::init (void) 54623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 54633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 54643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int vertexAttribSize = (int)sizeof(tcu::Vec4) * 2; // color4, position4 54653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int vertexIndexSize = (int)sizeof(deUint32); 54663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int vertexUploadDataSize = (m_targetBuffer == TARGETBUFFER_VERTEX) ? (vertexAttribSize) : (vertexIndexSize); 54673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderPerformanceTestBase::init(); 54693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // requirements 54713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_context.getRenderTarget().getWidth() < RENDER_AREA_SIZE || 54733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderTarget().getHeight() < RENDER_AREA_SIZE) 54743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Test case requires " + de::toString<int>(RENDER_AREA_SIZE) + "x" + de::toString<int>(RENDER_AREA_SIZE) + " render target"); 54753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // gl state 54773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(0, 0, RENDER_AREA_SIZE, RENDER_AREA_SIZE); 54793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // enable bleding to prevent grid layers from being discarded 54813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 54833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.blendEquation(GL_FUNC_ADD); 54843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enable(GL_BLEND); 54853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // scene 54873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 54893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LayeredGridSpec scene; 54903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create ~8MB workload with similar characteristics as in the other test 54923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // => makes comparison to other results more straightforward 54933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.gridWidth = 93; 54943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.gridHeight = 93; 54953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.gridLayers = 5; 54963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 54973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(m_vertexData, scene); 54983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridIndexData(m_indexData, scene); 54993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_numVertices = getLayeredGridNumVertices(scene); 55003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // buffers 55033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferState == BUFFERSTATE_NEW) 55053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 55073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // reads from two buffers, prepare the static buffer 55093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX) 55113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // index buffer is static, use another vertex buffer to keep original buffer in unused state 55133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glu::Buffer vertexCopyBuffer(m_context.getRenderContext()); 55143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_indexBuffer); 55163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *vertexCopyBuffer); 55173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer); 55183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(m_vertexData.size() * sizeof(tcu::Vec4)), &m_vertexData[0], GL_STATIC_DRAW); 55193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (glw::GLsizeiptr)(m_indexData.size() * sizeof(deUint32)), &m_indexData[0], GL_STATIC_DRAW); 55203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 55223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, m_numVertices, GL_UNSIGNED_INT, DE_NULL); 55233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX) 55253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // vertex buffer is static 55273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_vertexBuffer); 55283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); 55293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(m_vertexData.size() * sizeof(tcu::Vec4)), &m_vertexData[0], GL_STATIC_DRAW); 55303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 55323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, m_numVertices); 55333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 55353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 55363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_bufferState == BUFFERSTATE_EXISTING) 55393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum vertexUsage = (m_targetBuffer == TARGETBUFFER_VERTEX) ? (GL_STATIC_DRAW) : (GL_STATIC_DRAW); 55413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum indexUsage = (m_targetBuffer == TARGETBUFFER_INDEX) ? (GL_STATIC_DRAW) : (GL_STATIC_DRAW); 55423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_vertexBuffer); 55443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); 55453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(m_vertexData.size() * sizeof(tcu::Vec4)), &m_vertexData[0], vertexUsage); 55463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 55483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_indexBuffer); 55503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer); 55513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, (glw::GLsizeiptr)(m_indexData.size() * sizeof(deUint32)), &m_indexData[0], indexUsage); 55523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 55553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 55573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, m_numVertices); 55583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 55593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, m_numVertices, GL_UNSIGNED_INT, DE_NULL); 55603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 55613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 55623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 55643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 55653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // misc draw buffer 55673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> vertexData; 55693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LayeredGridSpec scene; 55703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // create ~1.5MB workload with similar characteristics 55723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.gridWidth = 40; 55733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.gridHeight = 40; 55743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.gridLayers = 5; 55753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLayeredGridVertexAttribData4C4V(vertexData, scene); 55773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_miscBuffer); 55793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_miscBuffer); 55803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)(sizeof(tcu::Vec4) * vertexData.size()), &vertexData[0], GL_STATIC_DRAW); 55813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_numMiscVertices = getLayeredGridNumVertices(scene); 55833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // iterations 55863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_samples.resize((m_numMaxSwaps+1) * m_numSamplesPerSwap); 55883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_results.resize((m_numMaxSwaps+1) * m_numSamplesPerSwap); 55893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int numSwaps = 0; numSwaps <= m_numMaxSwaps; ++numSwaps) 55913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < m_numSamplesPerSwap; ++sampleNdx) 55923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 55933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int index = numSwaps*m_numSamplesPerSwap + sampleNdx; 55943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_samples[index].numFrames = numSwaps; 55963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 55973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 55983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iterationOrder.resize(m_samples.size()); 55993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateTwoPassRandomIterationOrder(m_iterationOrder, (int)m_samples.size()); 56003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 56033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 56043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 56053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Measuring time used in " << ((m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) ? ("drawArrays") : ("drawElements")) << " and readPixels call.\n" 56063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Drawing using a buffer that has been uploaded N frames ago. Testing with N within range [0, " << m_numMaxSwaps << "].\n" 56073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Uploaded buffer is a " << ((m_targetBuffer == TARGETBUFFER_VERTEX) ? ("vertex attribute") : ("index")) << " buffer.\n" 56083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Uploading using " 56093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_uploadMethod == UPLOADMETHOD_BUFFER_DATA) ? ("bufferData") : 56103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) ? ("bufferSubData") : 56113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (m_uploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) ? ("mapBufferRange, flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT") : 56123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ((const char*)DE_NULL)) 56133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n" 56143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Upload size is " << getHumanReadableByteSize(m_numVertices * vertexUploadDataSize) << ".\n" 56153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ((m_bufferState == BUFFERSTATE_EXISTING) ? ("All test samples use the same buffer object.\n") : ("")) 56163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Test result is the number of frames (swaps) required for the render time to stabilize.\n" 56173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Assuming combined time used in the draw call and readPixels call is stabilizes to a constant value.\n" 56183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 56193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 56203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::deinit (void) 56223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 56233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RenderPerformanceTestBase::deinit(); 56243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_vertexBuffer) 56263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_vertexBuffer); 56283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vertexBuffer = 0; 56293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_indexBuffer) 56313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_indexBuffer); 56333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBuffer = 0; 56343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_miscBuffer) 56363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_miscBuffer); 56383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_miscBuffer = 0; 56393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 56413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryUploadWaitDrawCase::IterateResult UploadWaitDrawCase::iterate (void) 56433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 56443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 56453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int betweenIterationDummyFrameCount = 5; // draw misc between test samples 56463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int frameNdx = m_frameNdx++; 56473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int currentSampleNdx = m_iterationOrder[m_sampleNdx]; 56483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Simulate work for about 8ms 56503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry busyWait(8000); 56513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Dummy rendering during dummy frames 56533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (frameNdx != m_samples[currentSampleNdx].numFrames) 56543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw similar from another buffer 56563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawMisc(); 56573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (frameNdx == 0) 56603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload and start the clock 56623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadBuffer(m_samples[currentSampleNdx], m_results[currentSampleNdx]); 56633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (frameNdx == m_samples[currentSampleNdx].numFrames) // \note: not else if, m_samples[currentSampleNdx].numFrames can be 0 56663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw using the uploaded buffer 56683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawFromBuffer(m_samples[currentSampleNdx], m_results[currentSampleNdx]); 56693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // re-use buffer for something else to make sure test iteration do not affect each other 56713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferState == BUFFERSTATE_NEW) 56723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry reuseAndDeleteBuffer(); 56733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (frameNdx == m_samples[currentSampleNdx].numFrames + betweenIterationDummyFrameCount) 56753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 56763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // next sample 56773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ++m_sampleNdx; 56783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_frameNdx = 0; 56793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 56803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "post-iterate"); 56823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_sampleNdx < (int)m_samples.size()) 56843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 56853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logAndSetTestResult(); 56873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 56883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 56893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::uploadBuffer (Sample& sample, Result& result) 56913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 56923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 56933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 56943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 56953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum target; 56963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLsizeiptr size; 56973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const void* source; 56983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 56993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // data source 57003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX) 57023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT((m_vertexBuffer == 0) == (m_bufferState == BUFFERSTATE_NEW)); 57043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ARRAY_BUFFER; 57063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)(m_vertexData.size() * sizeof(tcu::Vec4)); 57073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = &m_vertexData[0]; 57083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX) 57103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT((m_indexBuffer == 0) == (m_bufferState == BUFFERSTATE_NEW)); 57123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry target = GL_ELEMENT_ARRAY_BUFFER; 57143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry size = (glw::GLsizeiptr)(m_indexData.size() * sizeof(deUint32)); 57153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry source = &m_indexData[0]; 57163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 57183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 57203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 57213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // gen buffer 57243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_bufferState == BUFFERSTATE_NEW) 57263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX) 57283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_vertexBuffer); 57303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); 57313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX) 57333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_indexBuffer); 57353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer); 57363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 57383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 57393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA || 57413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_uploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) 57423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(target, size, DE_NULL, GL_STATIC_DRAW); 57443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_bufferState == BUFFERSTATE_EXISTING) 57473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_VERTEX) 57493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); 57503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_INDEX) 57513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer); 57523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 57533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 57543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 57563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 57573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // upload 57593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 57613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_uploadMethod == UPLOADMETHOD_BUFFER_DATA) 57633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(target, size, source, GL_STATIC_DRAW); 57643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_uploadMethod == UPLOADMETHOD_BUFFER_SUB_DATA) 57653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferSubData(target, 0, size, source); 57663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_uploadMethod == UPLOADMETHOD_MAP_BUFFER_RANGE) 57673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 57683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void* mapPtr; 57693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLboolean unmapSuccessful; 57703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapPtr = gl.mapBufferRange(target, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT); 57723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!mapPtr) 57733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::Exception("MapBufferRange returned NULL"); 57743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deMemcpy(mapPtr, source, (int)size); 57763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // if unmapping fails, just try again later 57783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unmapSuccessful = gl.unmapBuffer(target); 57793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!unmapSuccessful) 57803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw UnmapFailureError(); 57813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 57823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 57833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 57843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 57863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sample.uploadCallEndTime = endTime; 57883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.uploadDuration = endTime - startTime; 57893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 57903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::drawFromBuffer (Sample& sample, Result& result) 57923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 57933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 57943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultSurface (RENDER_AREA_SIZE, RENDER_AREA_SIZE); 57953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 startTime; 57963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint64 endTime; 57973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 57983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_vertexBuffer != 0); 57993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 58003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_indexBuffer == 0); 58013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 58023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_indexBuffer != 0); 58033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 58043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 58053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw 58073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_vertexBuffer); 58093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 58103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer); 58113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 58133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // microseconds passed since return from upload call 58153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.timeBeforeUse = deGetMicroseconds() - sample.uploadCallEndTime; 58163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 58183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_drawMethod == DRAWMETHOD_DRAW_ARRAYS) 58203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, m_numVertices); 58213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_drawMethod == DRAWMETHOD_DRAW_ELEMENTS) 58223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, m_numVertices, GL_UNSIGNED_INT, DE_NULL); 58233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 58243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 58253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 58273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.renderDuration = endTime - startTime; 58293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 58303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // read 58323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry startTime = deGetMicroseconds(); 58343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, resultSurface.getAccess()); 58353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry endTime = deGetMicroseconds(); 58363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.readDuration = endTime - startTime; 58383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 58393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.renderReadDuration = result.renderDuration + result.readDuration; 58413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 58423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::reuseAndDeleteBuffer (void) 58443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 58453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 58463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_targetBuffer == TARGETBUFFER_INDEX) 58483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // respecify and delete index buffer 58503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const deUint32 indices[3] = {1, 3, 8}; 58513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_indexBuffer != 0); 58533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW); 58553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, DE_NULL); 58563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &m_indexBuffer); 58573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_indexBuffer = 0; 58583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 58593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_targetBuffer == TARGETBUFFER_VERTEX) 58603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // respecify and delete vertex buffer 58623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const tcu::Vec4 coloredTriangle[6] = 58633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-0.4f, -0.4f, 0.0f, 1.0f), 58653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4(-0.2f, 0.4f, 0.0f, 1.0f), 58663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), tcu::Vec4( 0.8f, -0.1f, 0.0f, 1.0f), 58673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 58683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_vertexBuffer != 0); 58703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, sizeof(coloredTriangle), coloredTriangle, GL_STATIC_DRAW); 58723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, 3); 58733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.deleteBuffers(1, &m_vertexBuffer); 58743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vertexBuffer = 0; 58753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 58763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry waitGLResults(); 58783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 58793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::logAndSetTestResult (void) 58813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 58823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int uploadStabilization; 58833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int renderReadStabilization; 58843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int renderStabilization; 58853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int readStabilization; 58863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool temporallyStable; 58873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(m_testCtx.getLog(), "Samples", "Result samples"); 58903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry logSamples(); 58913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 58923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 58943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(m_testCtx.getLog(), "Stabilization", "Sample stability"); 58953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 58963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log stabilization points 58973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderReadStabilization = findStabilizationSample(&Result::renderReadDuration, "Combined draw and read"); 58983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadStabilization = findStabilizationSample(&Result::uploadDuration, "Upload time"); 58993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderStabilization = findStabilizationSample(&Result::renderDuration, "Draw call time"); 59003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry readStabilization = findStabilizationSample(&Result::readDuration, "ReadPixels time"); 59013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry temporallyStable = true; 59033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry temporallyStable &= checkSampleTemporalStability(&Result::renderReadDuration, "Combined draw and read"); 59043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry temporallyStable &= checkSampleTemporalStability(&Result::uploadDuration, "Upload time"); 59053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry temporallyStable &= checkSampleTemporalStability(&Result::renderDuration, "Draw call time"); 59063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry temporallyStable &= checkSampleTemporalStability(&Result::readDuration, "ReadPixels time"); 59073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 59083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 59103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section(m_testCtx.getLog(), "Results", "Results"); 59113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check result sanily 59133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (uploadStabilization != 0) 59143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Warning! Upload times are not stable, test result may not be accurate." << tcu::TestLog::EndMessage; 59153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!temporallyStable) 59163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Warning! Time samples do not seem to be temporally stable, sample times seem to drift to one direction during test execution." << tcu::TestLog::EndMessage; 59173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // render & read 59193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (renderReadStabilization == -1) 59203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Combined time used in draw call and ReadPixels did not stabilize." << tcu::TestLog::EndMessage; 59213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 59223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Integer("RenderReadStabilizationPoint", "Combined draw call and ReadPixels call time stabilization time", "frames", QP_KEY_TAG_TIME, renderReadStabilization); 59233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw call 59253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (renderStabilization == -1) 59263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Time used in draw call did not stabilize." << tcu::TestLog::EndMessage; 59273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 59283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Integer("DrawCallStabilizationPoint", "Draw call time stabilization time", "frames", QP_KEY_TAG_TIME, renderStabilization); 59293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // readpixels 59313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (readStabilization == -1) 59323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Time used in ReadPixels did not stabilize." << tcu::TestLog::EndMessage; 59333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 59343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Integer("ReadPixelsStabilizationPoint", "ReadPixels call time stabilization time", "frames", QP_KEY_TAG_TIME, readStabilization); 59353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Report renderReadStabilization 59373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (renderReadStabilization != -1) 59383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::toString(renderReadStabilization).c_str()); 59393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 59403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, de::toString(m_numMaxSwaps).c_str()); // don't report -1 59413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 59423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 59433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59443c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::logSamples (void) 59453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 59463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Inverse m_iterationOrder 59473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<int> runOrder(m_iterationOrder.size()); 59493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)m_iterationOrder.size(); ++ndx) 59503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry runOrder[m_iterationOrder[ndx]] = ndx; 59513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Log samples 59533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 59553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleList("Samples", "Samples") 59563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::SampleInfo 59573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("NumSwaps", "SwapBuffers before use", "", QP_SAMPLE_VALUE_TAG_PREDICTOR) 59583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("Delay", "Time before use", "us", QP_SAMPLE_VALUE_TAG_PREDICTOR) 59593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("RunOrder", "Sample run order", "", QP_SAMPLE_VALUE_TAG_PREDICTOR) 59603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawReadTime", "Draw call and ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 59613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("TotalTime", "Total time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 59623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("Upload time", "Upload time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 59633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("DrawCallTime", "Draw call time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 59643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::ValueInfo("ReadTime", "ReadPixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 59653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSampleInfo; 59663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)m_samples.size(); ++sampleNdx) 59683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 59693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Sample 59703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << m_samples[sampleNdx].numFrames 59713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)m_results[sampleNdx].timeBeforeUse 59723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << runOrder[sampleNdx] 59733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)m_results[sampleNdx].renderReadDuration 59743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)(m_results[sampleNdx].renderReadDuration + m_results[sampleNdx].uploadDuration) 59753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)m_results[sampleNdx].uploadDuration 59763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)m_results[sampleNdx].renderDuration 59773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << (int)m_results[sampleNdx].readDuration 59783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndSample; 59793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::EndSampleList; 59813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 59823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid UploadWaitDrawCase::drawMisc (void) 59843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 59853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 59863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_miscBuffer); 59883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupVertexAttribs(); 59893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, m_numMiscVertices); 59903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 59913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59923c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct DistributionCompareResult 59933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 59943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool equal; 59953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float standardDeviations; 59963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 59973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 59983c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename Comparer> 59993c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic float sumOfRanks (const std::vector<deUint64>& testSamples, const std::vector<deUint64>& allSamples, const Comparer& comparer) 60003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 60013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float sum = 0; 60023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = 0; sampleNdx < (int)testSamples.size(); ++sampleNdx) 60043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 60053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint64 testSample = testSamples[sampleNdx]; 60063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int lowerIndex = (int)(std::lower_bound(allSamples.begin(), allSamples.end(), testSample, comparer) - allSamples.begin()); 60073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int upperIndex = (int)(std::upper_bound(allSamples.begin(), allSamples.end(), testSample, comparer) - allSamples.begin()); 60083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int lowerRank = lowerIndex + 1; // convert zero-indexed to rank 60093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int upperRank = upperIndex; // convert zero-indexed to rank, upperIndex is last equal + 1 60103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float rankMidpoint = (lowerRank + upperRank) / 2.0f; 60113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sum += rankMidpoint; 60133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 60143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sum; 60163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 60173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60183c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename Comparer> 60193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic DistributionCompareResult distributionCompare (const std::vector<deUint64>& orderedObservationsA, const std::vector<deUint64>& orderedObservationsB, const Comparer& comparer) 60203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 60213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Mann�Whitney U test 60223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int n1 = (int)orderedObservationsA.size(); 60243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int n2 = (int)orderedObservationsB.size(); 60253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint64> allSamples (n1 + n2); 60263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::copy(orderedObservationsA.begin(), orderedObservationsA.end(), allSamples.begin()); 60283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::copy(orderedObservationsB.begin(), orderedObservationsB.end(), allSamples.begin() + n1); 60293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(allSamples.begin(), allSamples.end()); 60303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 60323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float R1 = sumOfRanks(orderedObservationsA, allSamples, comparer); 60333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float U1 = n1*n2 + n1*(n1 + 1)/2 - R1; 60353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float U2 = (n1 * n2) - U1; 60363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float U = de::min(U1, U2); 60373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: sample sizes might not be large enough to expect normal distribution but we do it anyway 60393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float mU = n1*n2 / 2.0f; 60413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float sigmaU = deFloatSqrt((n1*n2*(n1+n2+1)) / 12.0f); 60423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float z = (U - mU) / sigmaU; 60433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DistributionCompareResult result; 60453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.equal = (de::abs(z) <= 1.96f); // accept within 95% confidence interval 60473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry result.standardDeviations = z; 60483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return result; 60503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 60513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 60523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytemplate <typename T> 60543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystruct ThresholdComparer 60553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 60563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float relativeThreshold; 60573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry T absoluteThreshold; 60583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool operator() (const T& a, const T& b) const 60603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 60613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float diff = de::abs((float)a - (float)b); 60623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // thresholds 60643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (diff <= (float)absoluteThreshold) 60653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 60663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (diff <= a*relativeThreshold || 60673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry diff <= b*relativeThreshold) 60683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 60693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // cmp 60713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return a < b; 60723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 60733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 60743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint UploadWaitDrawCase::findStabilizationSample (deUint64 (UploadWaitDrawCase::Result::*target), const char* description) 60763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 60773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<std::vector<deUint64> > sampleObservations(m_numMaxSwaps+1); 60783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ThresholdComparer<deUint64> comparer; 60793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry comparer.relativeThreshold = 0.15f; // 15% 60813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry comparer.absoluteThreshold = 100; // (us), assumed sampling precision 60823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // get observations and order them 60843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int swapNdx = 0; swapNdx <= m_numMaxSwaps; ++swapNdx) 60863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 60873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int insertNdx = 0; 60883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleObservations[swapNdx].resize(m_numSamplesPerSwap); 60903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)m_samples.size(); ++ndx) 60923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_samples[ndx].numFrames == swapNdx) 60933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sampleObservations[swapNdx][insertNdx++] = m_results[ndx].*target; 60943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(insertNdx == m_numSamplesPerSwap); 60963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 60973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::sort(sampleObservations[swapNdx].begin(), sampleObservations[swapNdx].end()); 60983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 60993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // find stabilization point 61013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int sampleNdx = m_numMaxSwaps-1; sampleNdx != -1; --sampleNdx ) 61033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Distribution is equal to all following distributions 61053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int cmpTargetDistribution = sampleNdx+1; cmpTargetDistribution <= m_numMaxSwaps; ++cmpTargetDistribution) 61063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Stable section ends here? 61083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const DistributionCompareResult result = distributionCompare(sampleObservations[sampleNdx], sampleObservations[cmpTargetDistribution], comparer); 61093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!result.equal) 61103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Last two samples are not equal? Samples never stabilized 61123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (sampleNdx == m_numMaxSwaps-1) 61133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 61153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 61163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << description << ": Samples with swap count " << sampleNdx << " and " << cmpTargetDistribution << " do not seem to have the same distribution:\n" 61173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tDifference in standard deviations: " << result.standardDeviations << "\n" 61183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tSwap count " << sampleNdx << " median: " << linearSample(sampleObservations[sampleNdx], 0.5f) << "\n" 61193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tSwap count " << cmpTargetDistribution << " median: " << linearSample(sampleObservations[cmpTargetDistribution], 0.5f) << "\n" 61203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 61213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return -1; 61223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 61243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 61263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 61273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << description << ": Samples with swap count " << sampleNdx << " and " << cmpTargetDistribution << " do not seem to have the same distribution:\n" 61283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tSamples with swap count " << sampleNdx << " are not part of the tail of stable results.\n" 61293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tDifference in standard deviations: " << result.standardDeviations << "\n" 61303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tSwap count " << sampleNdx << " median: " << linearSample(sampleObservations[sampleNdx], 0.5f) << "\n" 61313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tSwap count " << cmpTargetDistribution << " median: " << linearSample(sampleObservations[cmpTargetDistribution], 0.5f) << "\n" 61323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 61333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return sampleNdx+1; 61353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 61413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 61423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << description << ": All samples seem to have the same distribution" 61433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 61443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // all distributions equal 61463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return 0; 61473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 61483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool UploadWaitDrawCase::checkSampleTemporalStability (deUint64 (UploadWaitDrawCase::Result::*target), const char* description) 61503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 61513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Try to find correlation with sample order and sample times 61523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int numDataPoints = (int)m_iterationOrder.size(); 61548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry std::vector<tcu::Vec2> dataPoints (m_iterationOrder.size()); 61558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry LineParametersWithConfidence lineFit; 61563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < (int)m_iterationOrder.size(); ++ndx) 61583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dataPoints[m_iterationOrder[ndx]].x() = (float)ndx; 61603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dataPoints[m_iterationOrder[ndx]].y() = (float)(m_results[m_iterationOrder[ndx]].*target); 61613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry lineFit = theilSenSiegelLinearRegression(dataPoints, 0.6f); 61643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Difference of more than 25% of the offset along the whole sample range 61663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (de::abs(lineFit.coefficient) * numDataPoints > de::abs(lineFit.offset) * 0.25f) 61673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 61693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 61703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << description << ": Correlation with data point observation order and result time. Results are not temporally stable, observations are not independent.\n" 61713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\tCoefficient: " << lineFit.coefficient << " (us / observation)\n" 61723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 61733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 61753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 61763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 61773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 61783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 61793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 61813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61823c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferDataUploadTests::BufferDataUploadTests (Context& context) 61833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "data_upload", "Buffer data upload performance tests") 61843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 61853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 61863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61873c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBufferDataUploadTests::~BufferDataUploadTests (void) 61883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 61893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 61903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 61913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BufferDataUploadTests::init (void) 61923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 61933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct BufferUsage 61943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 61953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 61963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 usage; 61973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool primaryUsage; 61983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } bufferUsages[] = 61993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "stream_draw", GL_STREAM_DRAW, true }, 62013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "stream_read", GL_STREAM_READ, false }, 62023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "stream_copy", GL_STREAM_COPY, false }, 62033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "static_draw", GL_STATIC_DRAW, true }, 62043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "static_read", GL_STATIC_READ, false }, 62053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "static_copy", GL_STATIC_COPY, false }, 62063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "dynamic_draw", GL_DYNAMIC_DRAW, true }, 62073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "dynamic_read", GL_DYNAMIC_READ, false }, 62083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "dynamic_copy", GL_DYNAMIC_COPY, false }, 62093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 62103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const referenceGroup = new tcu::TestCaseGroup(m_testCtx, "reference", "Reference functions"); 62123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const functionCallGroup = new tcu::TestCaseGroup(m_testCtx, "function_call", "Function call timing"); 62133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const modifyAfterUseGroup = new tcu::TestCaseGroup(m_testCtx, "modify_after_use", "Function call time after buffer has been used"); 62143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const renderAfterUploadGroup = new tcu::TestCaseGroup(m_testCtx, "render_after_upload", "Function call time of draw commands after buffer has been modified"); 62153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(referenceGroup); 62173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(functionCallGroup); 62183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(modifyAfterUseGroup); 62193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(renderAfterUploadGroup); 62203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .reference 62223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct BufferSizeRange 62243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 62263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int minBufferSize; 62273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int maxBufferSize; 62283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numSamples; 62293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool largeBuffersCase; 62303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } sizeRanges[] = 62313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "small_buffers", 0, 1 << 18, 64, false }, // !< 0kB - 256kB 62333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "large_buffers", 1 << 18, 1 << 24, 32, true }, // !< 256kB - 16MB 62343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 62353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int bufferSizeRangeNdx = 0; bufferSizeRangeNdx < DE_LENGTH_OF_ARRAY(sizeRanges); ++bufferSizeRangeNdx) 62373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry referenceGroup->addChild(new ReferenceMemcpyCase(m_context, 62393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("memcpy_").append(sizeRanges[bufferSizeRangeNdx].name).c_str(), 62403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Test memcpy performance", 62413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sizeRanges[bufferSizeRangeNdx].minBufferSize, 62423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sizeRanges[bufferSizeRangeNdx].maxBufferSize, 62433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sizeRanges[bufferSizeRangeNdx].numSamples, 62443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sizeRanges[bufferSizeRangeNdx].largeBuffersCase)); 62453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 62463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 62473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .function_call 62493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int minBufferSize = 0; // !< 0kiB 62513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int maxBufferSize = 1 << 24; // !< 16MiB 62523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numDataSamples = 25; 62533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numMapSamples = 25; 62543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferDataMethodGroup = new tcu::TestCaseGroup(m_testCtx, "buffer_data", "Use glBufferData"); 62563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferSubDataMethodGroup = new tcu::TestCaseGroup(m_testCtx, "buffer_sub_data", "Use glBufferSubData"); 62573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const mapBufferRangeMethodGroup = new tcu::TestCaseGroup(m_testCtx, "map_buffer_range", "Use glMapBufferRange"); 62583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry functionCallGroup->addChild(bufferDataMethodGroup); 62603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry functionCallGroup->addChild(bufferSubDataMethodGroup); 62613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry functionCallGroup->addChild(mapBufferRangeMethodGroup); 62623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .buffer_data 62643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct TargetCase 62663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* group; 62683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferDataUploadCase::CaseType caseType; 62693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool allUsages; 62703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } targetCases[] = 62713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "new_buffer", "Target new buffer"), BufferDataUploadCase::CASE_NEW_BUFFER, true }, 62733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "unspecified_buffer", "Target new unspecified buffer"), BufferDataUploadCase::CASE_UNSPECIFIED_BUFFER, true }, 62743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "specified_buffer", "Target new specified buffer"), BufferDataUploadCase::CASE_SPECIFIED_BUFFER, true }, 62753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "used_buffer", "Target buffer that was used in draw"), BufferDataUploadCase::CASE_USED_BUFFER, true }, 62763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "larger_used_buffer", "Target larger buffer that was used in draw"), BufferDataUploadCase::CASE_USED_LARGER_BUFFER, false }, 62773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 62783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(targetCases); ++targetNdx) 62803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferDataMethodGroup->addChild(targetCases[targetNdx].group); 62823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(bufferUsages); ++usageNdx) 62843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferUsages[usageNdx].primaryUsage || targetCases[targetNdx].allUsages) 62853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetCases[targetNdx].group->addChild(new BufferDataUploadCase(m_context, 62863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("usage_").append(bufferUsages[usageNdx].name).c_str(), 62873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("Test with usage = ").append(bufferUsages[usageNdx].name).c_str(), 62883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minBufferSize, 62893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry maxBufferSize, 62903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numDataSamples, 62913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsages[usageNdx].usage, 62923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry targetCases[targetNdx].caseType)); 62933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 62943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 62953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 62963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .buffer_sub_data 62973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 62983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct FlagCase 62993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* group; 63013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferSubDataUploadCase::CaseType parentCase; 63023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool allUsages; 63033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int flags; 63043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } flagCases[] = 63053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "used_buffer_full_upload", ""), BufferSubDataUploadCase::CASE_USED_BUFFER, true, BufferSubDataUploadCase::FLAG_FULL_UPLOAD }, 63073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "used_buffer_invalidate_before_full_upload", "Clear buffer with bufferData(...,NULL) before sub data call"), BufferSubDataUploadCase::CASE_USED_BUFFER, false, BufferSubDataUploadCase::FLAG_FULL_UPLOAD | BufferSubDataUploadCase::FLAG_INVALIDATE_BEFORE_USE }, 63083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "used_buffer_partial_upload", ""), BufferSubDataUploadCase::CASE_USED_BUFFER, true, BufferSubDataUploadCase::FLAG_PARTIAL_UPLOAD }, 63093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { new tcu::TestCaseGroup(m_testCtx, "used_buffer_invalidate_before_partial_upload", "Clear buffer with bufferData(...,NULL) before sub data call"), BufferSubDataUploadCase::CASE_USED_BUFFER, false, BufferSubDataUploadCase::FLAG_PARTIAL_UPLOAD | BufferSubDataUploadCase::FLAG_INVALIDATE_BEFORE_USE }, 63103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 63113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int flagNdx = 0; flagNdx < DE_LENGTH_OF_ARRAY(flagCases); ++flagNdx) 63133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferSubDataMethodGroup->addChild(flagCases[flagNdx].group); 63153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(bufferUsages); ++usageNdx) 63173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferUsages[usageNdx].primaryUsage || flagCases[flagNdx].allUsages) 63183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flagCases[flagNdx].group->addChild(new BufferSubDataUploadCase(m_context, 63193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("usage_").append(bufferUsages[usageNdx].name).c_str(), 63203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("Test with usage = ").append(bufferUsages[usageNdx].name).c_str(), 63213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minBufferSize, 63223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry maxBufferSize, 63233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numDataSamples, 63243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsages[usageNdx].usage, 63253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flagCases[flagNdx].parentCase, 63263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flagCases[flagNdx].flags)); 63273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 63283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 63293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .map_buffer_range 63313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct FlagCase 63333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 63353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool usefulForUnusedBuffers; 63363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool allUsages; 63373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int glFlags; 63383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int caseFlags; 63393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } flagCases[] = 63403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_write_full", true, true, GL_MAP_WRITE_BIT, 0 }, 63423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_write_partial", true, true, GL_MAP_WRITE_BIT, MapBufferRangeCase::FLAG_PARTIAL }, 63433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_read_write_full", true, true, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT, 0 }, 63443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_read_write_partial", true, true, GL_MAP_WRITE_BIT | GL_MAP_READ_BIT, MapBufferRangeCase::FLAG_PARTIAL }, 63453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_invalidate_range_full", true, false, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT, 0 }, 63463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_invalidate_range_partial", true, false, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT, MapBufferRangeCase::FLAG_PARTIAL }, 63473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_invalidate_buffer_full", true, false, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT, 0 }, 63483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_invalidate_buffer_partial", true, false, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT, MapBufferRangeCase::FLAG_PARTIAL }, 63493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_write_full_manual_invalidate_buffer", false, false, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT, MapBufferRangeCase::FLAG_MANUAL_INVALIDATION }, 63503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_write_partial_manual_invalidate_buffer", false, false, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT, MapBufferRangeCase::FLAG_PARTIAL | MapBufferRangeCase::FLAG_MANUAL_INVALIDATION }, 63513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_unsynchronized_full", true, false, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT, 0 }, 63523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_unsynchronized_partial", true, false, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT, MapBufferRangeCase::FLAG_PARTIAL }, 63533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_unsynchronized_and_invalidate_buffer_full", true, false, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT, 0 }, 63543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_unsynchronized_and_invalidate_buffer_partial", true, false, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | GL_MAP_INVALIDATE_BUFFER_BIT, MapBufferRangeCase::FLAG_PARTIAL }, 63553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 63563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct FlushCases 63573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 63593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int glFlags; 63603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int caseFlags; 63613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } flushCases[] = 63623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_flush_explicit_map_full", GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT, 0 }, 63643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_flush_explicit_map_partial", GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT, MapBufferRangeFlushCase::FLAG_PARTIAL }, 63653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_flush_explicit_map_full_flush_in_parts", GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT, MapBufferRangeFlushCase::FLAG_FLUSH_IN_PARTS }, 63663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "flag_flush_explicit_map_full_flush_partial", GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT, MapBufferRangeFlushCase::FLAG_FLUSH_PARTIAL }, 63673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 63683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct MapTestGroup 63693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int flags; 63713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool unusedBufferCase; 63723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* group; 63733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } groups[] = 63743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { MapBufferRangeCase::FLAG_USE_UNUSED_UNSPECIFIED_BUFFER, true, new tcu::TestCaseGroup(m_testCtx, "new_unspecified_buffer", "Test with unused, unspecified buffers"), }, 63763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { MapBufferRangeCase::FLAG_USE_UNUSED_SPECIFIED_BUFFER, true, new tcu::TestCaseGroup(m_testCtx, "new_specified_buffer", "Test with unused, specified buffers"), }, 63773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 0, false, new tcu::TestCaseGroup(m_testCtx, "used_buffer", "Test with used (data has been sourced from a buffer) buffers") }, 63783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 63793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // we OR same flags to both range and flushRange cases, make sure it is legal 63813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_STATIC_ASSERT((int)MapBufferRangeCase::FLAG_USE_UNUSED_SPECIFIED_BUFFER == (int)MapBufferRangeFlushCase::FLAG_USE_UNUSED_SPECIFIED_BUFFER); 63823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_STATIC_ASSERT((int)MapBufferRangeCase::FLAG_USE_UNUSED_UNSPECIFIED_BUFFER == (int)MapBufferRangeFlushCase::FLAG_USE_UNUSED_UNSPECIFIED_BUFFER); 63833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int groupNdx = 0; groupNdx < DE_LENGTH_OF_ARRAY(groups); ++groupNdx) 63853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferTypeGroup = groups[groupNdx].group; 63873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry mapBufferRangeMethodGroup->addChild(bufferTypeGroup); 63893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(flagCases); ++caseNdx) 63913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 63923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (groups[groupNdx].unusedBufferCase && !flagCases[caseNdx].usefulForUnusedBuffers) 63933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 63943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferUsageGroup = new tcu::TestCaseGroup(m_testCtx, flagCases[caseNdx].name, ""); 63963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferTypeGroup->addChild(bufferUsageGroup); 63973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 63983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(bufferUsages); ++usageNdx) 63993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferUsages[usageNdx].primaryUsage || flagCases[caseNdx].allUsages) 64003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsageGroup->addChild(new MapBufferRangeCase(m_context, 64013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsages[usageNdx].name, 64023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("Test with usage = ").append(bufferUsages[usageNdx].name).c_str(), 64033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minBufferSize, 64043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry maxBufferSize, 64053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numMapSamples, 64063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsages[usageNdx].usage, 64073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flagCases[caseNdx].glFlags, 64083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flagCases[caseNdx].caseFlags | groups[groupNdx].flags)); 64093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int caseNdx = 0; caseNdx < DE_LENGTH_OF_ARRAY(flushCases); ++caseNdx) 64123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferUsageGroup = new tcu::TestCaseGroup(m_testCtx, flushCases[caseNdx].name, ""); 64143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferTypeGroup->addChild(bufferUsageGroup); 64153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(bufferUsages); ++usageNdx) 64173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferUsages[usageNdx].primaryUsage) 64183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsageGroup->addChild(new MapBufferRangeFlushCase(m_context, 64193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsages[usageNdx].name, 64203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string("Test with usage = ").append(bufferUsages[usageNdx].name).c_str(), 64213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry minBufferSize, 64223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry maxBufferSize, 64233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numMapSamples, 64243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferUsages[usageNdx].usage, 64253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flushCases[caseNdx].glFlags, 64263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry flushCases[caseNdx].caseFlags | groups[groupNdx].flags)); 64273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .modify_after_use 64333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int minBufferSize = 0; // !< 0kiB 64353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int maxBufferSize = 1 << 24; // !< 16MiB 64363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct Usage 64383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 64403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 64413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 usage; 64423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } usages[] = 64433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "static_draw", "Test with GL_STATIC_DRAW", GL_STATIC_DRAW }, 64453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "dynamic_draw", "Test with GL_DYNAMIC_DRAW", GL_DYNAMIC_DRAW }, 64463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "stream_draw", "Test with GL_STREAM_DRAW", GL_STREAM_DRAW }, 64473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 64493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int usageNdx = 0; usageNdx < DE_LENGTH_OF_ARRAY(usages); ++usageNdx) 64513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const usageGroup = new tcu::TestCaseGroup(m_testCtx, usages[usageNdx].name, usages[usageNdx].description); 64533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry modifyAfterUseGroup->addChild(usageGroup); 64543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferDataCase (m_context, "buffer_data", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0)); 64563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferDataCase (m_context, "buffer_data_different_size", "Respecify buffer contents and size after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithBufferDataCase::FLAG_RESPECIFY_SIZE)); 64573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferDataCase (m_context, "buffer_data_repeated", "Respecify buffer contents after upload and use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithBufferDataCase::FLAG_UPLOAD_REPEATED)); 64583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferSubDataCase (m_context, "buffer_sub_data_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0)); 64603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferSubDataCase (m_context, "buffer_sub_data_partial", "Respecify buffer contents partially use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithBufferSubDataCase::FLAG_PARTIAL)); 64613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferSubDataCase (m_context, "buffer_sub_data_full_repeated", "Respecify buffer contents after upload and use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithBufferSubDataCase::FLAG_UPLOAD_REPEATED)); 64623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithBufferSubDataCase (m_context, "buffer_sub_data_partial_repeated", "Respecify buffer contents partially upload and use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithBufferSubDataCase::FLAG_UPLOAD_REPEATED | ModifyAfterWithBufferSubDataCase::FLAG_PARTIAL)); 64633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_write_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0, GL_MAP_WRITE_BIT)); 64653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_write_partial", "Respecify buffer contents partially after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithMapBufferRangeCase::FLAG_PARTIAL, GL_MAP_WRITE_BIT)); 64663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_read_write_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)); 64673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_read_write_partial", "Respecify buffer contents partially after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithMapBufferRangeCase::FLAG_PARTIAL, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)); 64683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_invalidate_range_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT)); 64693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_invalidate_range_partial", "Respecify buffer contents partially after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithMapBufferRangeCase::FLAG_PARTIAL, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT)); 64703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_invalidate_buffer_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)); 64713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_invalidate_buffer_partial", "Respecify buffer contents partially after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithMapBufferRangeCase::FLAG_PARTIAL, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)); 64723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_unsynchronized_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT)); 64733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferRangeCase (m_context, "map_flag_unsynchronized_partial", "Respecify buffer contents partially after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithMapBufferRangeCase::FLAG_PARTIAL, GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT)); 64743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferFlushCase (m_context, "map_flag_flush_explicit_full", "Respecify buffer contents after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, 0, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT)); 64763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry usageGroup->addChild(new ModifyAfterWithMapBufferFlushCase (m_context, "map_flag_flush_explicit_partial", "Respecify buffer contents partially after use", minBufferSize, maxBufferSize, usages[usageNdx].usage, ModifyAfterWithMapBufferFlushCase::FLAG_PARTIAL, GL_MAP_WRITE_BIT | GL_MAP_FLUSH_EXPLICIT_BIT)); 64773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .render_after_upload 64813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .reference 64833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const renderReferenceGroup = new tcu::TestCaseGroup(m_testCtx, "reference", "Baseline results"); 64853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderAfterUploadGroup->addChild(renderReferenceGroup); 64863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .draw 64883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 64893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const drawGroup = new tcu::TestCaseGroup(m_testCtx, "draw", "Time usage of functions with non-modified buffers"); 64903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderReferenceGroup->addChild(drawGroup); 64913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Time consumed by readPixels 64933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawGroup->addChild(new ReferenceReadPixelsTimeCase (m_context, "read_pixels", "Measure time consumed by readPixels() function call")); 64943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 64953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Time consumed by rendering 64963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawGroup->addChild(new ReferenceRenderTimeCase (m_context, "draw_arrays", "Measure time consumed by drawArrays() function call", DRAWMETHOD_DRAW_ARRAYS)); 64973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawGroup->addChild(new ReferenceRenderTimeCase (m_context, "draw_elements", "Measure time consumed by drawElements() function call", DRAWMETHOD_DRAW_ELEMENTS)); 64983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 64993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .draw_upload_draw 65013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 65033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 65053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 65063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod; 65073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer; 65083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool partial; 65093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadTargets[] = 65103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_arrays_upload_vertices", 65133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawArrays, vertex attribute upload, another drawArrays, and readPixels function calls.", 65143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS, 65153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 65163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 65173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 65183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_arrays_upload_vertices_partial", 65203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawArrays, partial vertex attribute upload, another drawArrays, and readPixels function calls.", 65213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS, 65223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 65233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry true 65243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 65253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_vertices", 65273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawElements, vertex attribute upload, another drawElements, and readPixels function calls.", 65283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 65293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 65303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 65313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 65323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_indices", 65343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawElements, index upload, another drawElements, and readPixels function calls.", 65353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 65363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 65373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 65383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 65393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_indices_partial", 65413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawElements, partial index upload, another drawElements, and readPixels function calls.", 65423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 65433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 65443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry true 65453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 65463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 65473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 65483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 65503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 65513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod; 65523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferInUseRenderTimeCase::MapFlags mapFlags; 65533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool supportsPartialUpload; 65543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadMethods[] = 65553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_data", "bufferData", UPLOADMETHOD_BUFFER_DATA, BufferInUseRenderTimeCase::MAPFLAG_NONE, false }, 65573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_sub_data", "bufferSubData", UPLOADMETHOD_BUFFER_SUB_DATA, BufferInUseRenderTimeCase::MAPFLAG_NONE, true }, 65583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range_invalidate_range", "mapBufferRange", UPLOADMETHOD_MAP_BUFFER_RANGE, BufferInUseRenderTimeCase::MAPFLAG_INVALIDATE_RANGE, true }, 65593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range_invalidate_buffer", "mapBufferRange", UPLOADMETHOD_MAP_BUFFER_RANGE, BufferInUseRenderTimeCase::MAPFLAG_INVALIDATE_BUFFER, false }, 65603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 65613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const drawUploadDrawGroup = new tcu::TestCaseGroup(m_testCtx, "draw_upload_draw", "Time usage of functions draw, upload and another draw"); 65633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderReferenceGroup->addChild(drawUploadDrawGroup); 65643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadTargetNdx = 0; uploadTargetNdx < DE_LENGTH_OF_ARRAY(uploadTargets); ++uploadTargetNdx) 65663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadMethodNdx = 0; uploadMethodNdx < DE_LENGTH_OF_ARRAY(uploadMethods); ++uploadMethodNdx) 65673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string() + uploadTargets[uploadTargetNdx].name + "_with_" + uploadMethods[uploadMethodNdx].name; 65693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (uploadTargets[uploadTargetNdx].partial && !uploadMethods[uploadMethodNdx].supportsPartialUpload) 65713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 65723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawUploadDrawGroup->addChild(new BufferInUseRenderTimeCase(m_context, 65743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name.c_str(), 65753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].description, 65763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].drawMethod, 65773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].mapFlags, 65783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].targetBuffer, 65793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].uploadMethod, 65803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (uploadTargets[uploadTargetNdx].partial) ? (UPLOADRANGE_PARTIAL) : (UPLOADRANGE_FULL), 65813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferInUseRenderTimeCase::UPLOADBUFFERTARGET_DIFFERENT_BUFFER)); 65823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 65833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 65843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 65853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .upload_unrelated_and_draw 65873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 65893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 65913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 65923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod; 65933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } drawMethods[] = 65943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 65953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "draw_arrays", "drawArrays", DRAWMETHOD_DRAW_ARRAYS }, 65963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "draw_elements", "drawElements", DRAWMETHOD_DRAW_ELEMENTS }, 65973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 65983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 65993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 66003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 66023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod; 66033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadMethods[] = 66043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_data", UPLOADMETHOD_BUFFER_DATA }, 66063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_sub_data", UPLOADMETHOD_BUFFER_SUB_DATA }, 66073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range", UPLOADMETHOD_MAP_BUFFER_RANGE }, 66083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 66093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const uploadUnrelatedGroup = new tcu::TestCaseGroup(m_testCtx, "upload_unrelated_and_draw", "Time usage of functions after an unrelated upload"); 66113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderAfterUploadGroup->addChild(uploadUnrelatedGroup); 66123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int drawMethodNdx = 0; drawMethodNdx < DE_LENGTH_OF_ARRAY(drawMethods); ++drawMethodNdx) 66143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadMethodNdx = 0; uploadMethodNdx < DE_LENGTH_OF_ARRAY(uploadMethods); ++uploadMethodNdx) 66153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string() + drawMethods[drawMethodNdx].name + "_upload_unrelated_with_" + uploadMethods[uploadMethodNdx].name; 66173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string desc = std::string() + "Measure time consumed by " + drawMethods[drawMethodNdx].description + " function call after an unrelated upload"; 66183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Time consumed by rendering command after an unrelated upload 66203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadUnrelatedGroup->addChild(new UnrelatedUploadRenderTimeCase(m_context, name.c_str(), desc.c_str(), drawMethods[drawMethodNdx].drawMethod, uploadMethods[uploadMethodNdx].uploadMethod)); 66223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 66233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 66243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .upload_and_draw 66263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 66283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 66303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 66313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferState bufferState; 66323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UnrelatedBufferType unrelatedBuffer; 66333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool supportsPartialUpload; 66343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } bufferConfigs[] = 66353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "used_buffer", "Upload to an used buffer", BUFFERSTATE_EXISTING, UNRELATEDBUFFERTYPE_NONE, true }, 66373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "new_buffer", "Upload to a new buffer", BUFFERSTATE_NEW, UNRELATEDBUFFERTYPE_NONE, false }, 66383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "used_buffer_and_unrelated_upload", "Upload to an used buffer and an unrelated buffer and then draw", BUFFERSTATE_EXISTING, UNRELATEDBUFFERTYPE_VERTEX, true }, 66393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "new_buffer_and_unrelated_upload", "Upload to a new buffer and an unrelated buffer and then draw", BUFFERSTATE_NEW, UNRELATEDBUFFERTYPE_VERTEX, false }, 66403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 66413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const uploadAndDrawGroup = new tcu::TestCaseGroup(m_testCtx, "upload_and_draw", "Time usage of rendering functions with modified buffers"); 66433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderAfterUploadGroup->addChild(uploadAndDrawGroup); 66443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 66453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .used_buffer 66463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .new_buffer 66473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .used_buffer_and_unrelated_upload 66483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .new_buffer_and_unrelated_upload 66493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int stateNdx = 0; stateNdx < DE_LENGTH_OF_ARRAY(bufferConfigs); ++stateNdx) 66503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 66523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 66543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 66553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod; 66563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer; 66573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool partial; 66583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadTargets[] = 66593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_arrays_upload_vertices", 66623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by vertex attribute upload, drawArrays, and readPixels function calls", 66633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS, 66643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 66653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 66663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 66673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_arrays_upload_vertices_partial", 66693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by partial vertex attribute upload, drawArrays, and readPixels function calls", 66703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS, 66713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 66723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry true 66733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 66743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_vertices", 66763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by vertex attribute upload, drawElements, and readPixels function calls", 66773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 66783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 66793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 66803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 66813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_indices", 66833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by index upload, drawElements, and readPixels function calls", 66843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 66853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 66863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 66873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 66883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_indices_partial", 66903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by partial index upload, drawElements, and readPixels function calls", 66913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 66923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 66933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry true 66943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 66953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 66963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 66973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 66983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 66993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 67003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod; 67013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool supportsPartialUpload; 67023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadMethods[] = 67033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_data", "bufferData", UPLOADMETHOD_BUFFER_DATA, false }, 67053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_sub_data", "bufferSubData", UPLOADMETHOD_BUFFER_SUB_DATA, true }, 67063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range", "mapBufferRange", UPLOADMETHOD_MAP_BUFFER_RANGE, true }, 67073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 67083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, bufferConfigs[stateNdx].name, bufferConfigs[stateNdx].description); 67103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadAndDrawGroup->addChild(group); 67113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadTargetNdx = 0; uploadTargetNdx < DE_LENGTH_OF_ARRAY(uploadTargets); ++uploadTargetNdx) 67133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadMethodNdx = 0; uploadMethodNdx < DE_LENGTH_OF_ARRAY(uploadMethods); ++uploadMethodNdx) 67143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string() + uploadTargets[uploadTargetNdx].name + "_with_" + uploadMethods[uploadMethodNdx].name; 67163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (uploadTargets[uploadTargetNdx].partial && !uploadMethods[uploadMethodNdx].supportsPartialUpload) 67183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 67193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (uploadTargets[uploadTargetNdx].partial && !bufferConfigs[stateNdx].supportsPartialUpload) 67203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 67213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Don't log unrelated buffer information to samples if there is no such buffer 67233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (bufferConfigs[stateNdx].unrelatedBuffer == UNRELATEDBUFFERTYPE_NONE) 67253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef UploadRenderReadDuration SampleType; 67273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef GenericUploadRenderTimeCase<SampleType> TestType; 67283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new TestType(m_context, 67303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name.c_str(), 67313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].description, 67323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].drawMethod, 67333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].targetBuffer, 67343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].uploadMethod, 67353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferConfigs[stateNdx].bufferState, 67363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (uploadTargets[uploadTargetNdx].partial) ? (UPLOADRANGE_PARTIAL) : (UPLOADRANGE_FULL), 67373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferConfigs[stateNdx].unrelatedBuffer)); 67383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 67393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 67403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef UploadRenderReadDurationWithUnrelatedUploadSize SampleType; 67423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry typedef GenericUploadRenderTimeCase<SampleType> TestType; 67433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry group->addChild(new TestType(m_context, 67453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name.c_str(), 67463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].description, 67473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].drawMethod, 67483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].targetBuffer, 67493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].uploadMethod, 67503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferConfigs[stateNdx].bufferState, 67513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (uploadTargets[uploadTargetNdx].partial) ? (UPLOADRANGE_PARTIAL) : (UPLOADRANGE_FULL), 67523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferConfigs[stateNdx].unrelatedBuffer)); 67533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 67543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 67553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 67563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 67573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 67583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .draw_modify_draw 67593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 67613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 67633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 67643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod; 67653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer; 67663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool partial; 67673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadTargets[] = 67683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_arrays_upload_vertices", 67713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawArrays, vertex attribute upload, another drawArrays, and readPixels function calls.", 67723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS, 67733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 67743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 67753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 67763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_arrays_upload_vertices_partial", 67783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawArrays, partial vertex attribute upload, another drawArrays, and readPixels function calls.", 67793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ARRAYS, 67803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 67813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry true 67823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 67833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_vertices", 67853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawElements, vertex attribute upload, another drawElements, and readPixels function calls.", 67863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 67873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_VERTEX, 67883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 67893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 67903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_indices", 67923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawElements, index upload, another drawElements, and readPixels function calls.", 67933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 67943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 67953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry false 67963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 67973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 67983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "draw_elements_upload_indices_partial", 67993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "Measure time consumed by drawElements, partial index upload, another drawElements, and readPixels function calls.", 68003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DRAWMETHOD_DRAW_ELEMENTS, 68013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TARGETBUFFER_INDEX, 68023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry true 68033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }, 68043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 68053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 68063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 68083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 68093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod; 68103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferInUseRenderTimeCase::MapFlags mapFlags; 68113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool supportsPartialUpload; 68123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadMethods[] = 68133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_data", "bufferData", UPLOADMETHOD_BUFFER_DATA, BufferInUseRenderTimeCase::MAPFLAG_NONE, false }, 68153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_sub_data", "bufferSubData", UPLOADMETHOD_BUFFER_SUB_DATA, BufferInUseRenderTimeCase::MAPFLAG_NONE, true }, 68163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range_invalidate_range", "mapBufferRange", UPLOADMETHOD_MAP_BUFFER_RANGE, BufferInUseRenderTimeCase::MAPFLAG_INVALIDATE_RANGE, true }, 68173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range_invalidate_buffer", "mapBufferRange", UPLOADMETHOD_MAP_BUFFER_RANGE, BufferInUseRenderTimeCase::MAPFLAG_INVALIDATE_BUFFER, false }, 68183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 68193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const drawModifyDrawGroup = new tcu::TestCaseGroup(m_testCtx, "draw_modify_draw", "Time used in rendering functions with modified buffers while original buffer is still in use"); 68213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderAfterUploadGroup->addChild(drawModifyDrawGroup); 68223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadTargetNdx = 0; uploadTargetNdx < DE_LENGTH_OF_ARRAY(uploadTargets); ++uploadTargetNdx) 68243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadMethodNdx = 0; uploadMethodNdx < DE_LENGTH_OF_ARRAY(uploadMethods); ++uploadMethodNdx) 68253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string() + uploadTargets[uploadTargetNdx].name + "_with_" + uploadMethods[uploadMethodNdx].name; 68273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (uploadTargets[uploadTargetNdx].partial && !uploadMethods[uploadMethodNdx].supportsPartialUpload) 68293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 68303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawModifyDrawGroup->addChild(new BufferInUseRenderTimeCase(m_context, 68323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name.c_str(), 68333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].description, 68343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].drawMethod, 68353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].mapFlags, 68363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].targetBuffer, 68373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].uploadMethod, 68383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (uploadTargets[uploadTargetNdx].partial) ? (UPLOADRANGE_PARTIAL) : (UPLOADRANGE_FULL), 68393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferInUseRenderTimeCase::UPLOADBUFFERTARGET_SAME_BUFFER)); 68403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 68413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 68423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .upload_wait_draw 68443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 68463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 68483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 68493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BufferState bufferState; 68503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } bufferStates[] = 68513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "new_buffer", "Uploading to just generated name", BUFFERSTATE_NEW }, 68533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "used_buffer", "Uploading to a used buffer", BUFFERSTATE_EXISTING }, 68543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 68553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 68563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 68583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 68593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DrawMethod drawMethod; 68603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TargetBuffer targetBuffer; 68613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadTargets[] = 68623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "draw_arrays_vertices", "Upload vertex data, draw with drawArrays", DRAWMETHOD_DRAW_ARRAYS, TARGETBUFFER_VERTEX }, 68643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "draw_elements_vertices", "Upload vertex data, draw with drawElements", DRAWMETHOD_DRAW_ELEMENTS, TARGETBUFFER_VERTEX }, 68653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "draw_elements_indices", "Upload index data, draw with drawElements", DRAWMETHOD_DRAW_ELEMENTS, TARGETBUFFER_INDEX }, 68663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 68673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct 68683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 68703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* description; 68713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry UploadMethod uploadMethod; 68723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } uploadMethods[] = 68733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_data", "bufferData", UPLOADMETHOD_BUFFER_DATA }, 68753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "buffer_sub_data", "bufferSubData", UPLOADMETHOD_BUFFER_SUB_DATA }, 68763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { "map_buffer_range", "mapBufferRange", UPLOADMETHOD_MAP_BUFFER_RANGE }, 68773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 68783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const uploadSwapDrawGroup = new tcu::TestCaseGroup(m_testCtx, "upload_wait_draw", "Time used in rendering functions after a buffer upload N frames ago"); 68803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderAfterUploadGroup->addChild(uploadSwapDrawGroup); 68813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int bufferStateNdx = 0; bufferStateNdx < DE_LENGTH_OF_ARRAY(bufferStates); ++bufferStateNdx) 68833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferGroup = new tcu::TestCaseGroup(m_testCtx, bufferStates[bufferStateNdx].name, bufferStates[bufferStateNdx].description); 68853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadSwapDrawGroup->addChild(bufferGroup); 68863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadTargetNdx = 0; uploadTargetNdx < DE_LENGTH_OF_ARRAY(uploadTargets); ++uploadTargetNdx) 68883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int uploadMethodNdx = 0; uploadMethodNdx < DE_LENGTH_OF_ARRAY(uploadMethods); ++uploadMethodNdx) 68893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 68903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string() + uploadTargets[uploadTargetNdx].name + "_with_" + uploadMethods[uploadMethodNdx].name; 68913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 68923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferGroup->addChild(new UploadWaitDrawCase(m_context, 68933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry name.c_str(), 68943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].description, 68953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].drawMethod, 68963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadTargets[uploadTargetNdx].targetBuffer, 68973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry uploadMethods[uploadMethodNdx].uploadMethod, 68983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferStates[bufferStateNdx].bufferState)); 68993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 69003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 69013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 69023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 69033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 69043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 69053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Performance 69063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 69073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 6908