18852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry/*------------------------------------------------------------------------- 28852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * drawElements Quality Program OpenGL ES 3.0 Module 38852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * ------------------------------------------------- 48852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 58852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * Copyright 2014 The Android Open Source Project 68852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 78852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 88852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * you may not use this file except in compliance with the License. 98852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * You may obtain a copy of the License at 108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * See the License for the specific language governing permissions and 178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * limitations under the License. 188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * 198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry *//*! 208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * \file 218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry * \brief Depth buffer performance tests. 228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry *//*--------------------------------------------------------------------*/ 238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "es3pDepthTests.hpp" 258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "glsCalibration.hpp" 278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "gluShaderProgram.hpp" 298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "gluObjectWrapper.hpp" 308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "gluPixelTransfer.hpp" 318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "glwFunctions.hpp" 338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "glwEnums.hpp" 348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuTestLog.hpp" 368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuStringTemplate.hpp" 378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuCPUWarmup.hpp" 388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "tcuCommandLine.hpp" 39ab44fc6da25bb126919615ad2ded101695251161Jarkko Pöyry#include "tcuResultCollector.hpp" 408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deClock.h" 428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deString.h" 438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deMath.h" 448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deStringUtil.hpp" 458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deRandom.hpp" 468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include "deUniquePtr.hpp" 478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include <vector> 498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry#include <algorithm> 508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace deqp 528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace gles3 548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace Performance 568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace 588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing namespace glw; 608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing de::MovePtr; 618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing tcu::TestContext; 628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing tcu::TestLog; 638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing tcu::Vec4; 648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing tcu::Vec3; 658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing tcu::Vec2; 668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing glu::RenderContext; 678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing glu::ProgramSources; 688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing glu::ShaderSource; 698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing std::vector; 708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing std::string; 718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryusing std::map; 728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystruct Sample 748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deInt64 nullTime; 768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deInt64 baseTime; 778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deInt64 testTime; 788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int order; 798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int workload; 808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystruct SampleParams 838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int step; 858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int measurement; 868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry SampleParams(int step_, int measurement_) : step(step_), measurement(measurement_) {} 888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrytypedef vector<float> Geometry; 918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrystruct ObjectData 938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ProgramSources shader; 958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Geometry geometry; 968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ObjectData (const ProgramSources& shader_, const Geometry& geometry_) : shader(shader_), geometry(geometry_) {} 988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass RenderData 1018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 1038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry RenderData (const ObjectData& object, const glu::RenderContext& renderCtx, TestLog& log); 1048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~RenderData (void) {}; 1058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glu::ShaderProgram m_program; 1078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glu::VertexArray m_vao; 1088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glu::Buffer m_vbo; 1098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int m_numVertices; 1118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 1128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryRenderData::RenderData (const ObjectData& object, const glu::RenderContext& renderCtx, TestLog& log) 1148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : m_program (renderCtx, object.shader) 1158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_vao (renderCtx.getFunctions()) 1168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_vbo (renderCtx.getFunctions()) 1178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_numVertices (int(object.geometry.size())/4) 1188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = renderCtx.getFunctions(); 1208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (!m_program.isOk()) 1228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << m_program; 1238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, *m_vbo); 1258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, object.geometry.size() * sizeof(float), &object.geometry[0], GL_STATIC_DRAW); 1268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindAttribLocation(m_program.getProgram(), 0, "a_position"); 1278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindVertexArray(*m_vao); 1298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.vertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, DE_NULL); 1308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.enableVertexAttribArray(0); 1318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindVertexArray(0); 1328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 1338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrynamespace Utils 1358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 1368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<float> getFullscreenQuad (float depth) 1378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float data[] = 1398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry +1.0f, +1.0f, depth, 0.0f, // .w is gl_VertexId%3 since Nexus 4&5 can't handle that on their own 1418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry +1.0f, -1.0f, depth, 1.0f, 1428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, -1.0f, depth, 2.0f, 1438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, -1.0f, depth, 0.0f, 1448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, +1.0f, depth, 1.0f, 1458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry +1.0f, +1.0f, depth, 2.0f, 1468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry }; 1478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return vector<float>(DE_ARRAY_BEGIN(data), DE_ARRAY_END(data)); 1498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 1508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<float> getFullscreenQuadWithGradient (float depth0, float depth1) 1528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float data[] = 1548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry +1.0f, +1.0f, depth0, 0.0f, 1568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry +1.0f, -1.0f, depth0, 1.0f, 1578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, -1.0f, depth1, 2.0f, 1588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, -1.0f, depth1, 0.0f, 1598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, +1.0f, depth1, 1.0f, 1608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry +1.0f, +1.0f, depth0, 2.0f, 1618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry }; 1628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return vector<float>(DE_ARRAY_BEGIN(data), DE_ARRAY_END(data)); 1648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 1658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<float> getPartScreenQuad (float coverage, float depth) 1678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float xMax = -1.0f + 2.0f*coverage; 1698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float data[] = 1708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry xMax, +1.0f, depth, 0.0f, 1728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry xMax, -1.0f, depth, 1.0f, 1738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, -1.0f, depth, 2.0f, 1748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, -1.0f, depth, 0.0f, 1758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry -1.0f, +1.0f, depth, 1.0f, 1768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry xMax, +1.0f, depth, 2.0f, 1778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry }; 1788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return vector<float>(DE_ARRAY_BEGIN(data), DE_ARRAY_END(data)); 1808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 1818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Axis aligned grid. Depth of vertices is baseDepth +/- depthNoise 1838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<float> getFullScreenGrid (int resolution, deUint32 seed, float baseDepth, float depthNoise, float xyNoise) 1848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int gridsize = resolution+1; 1868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<Vec3> vertices (gridsize*gridsize); 1878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<float> retval; 1888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry de::Random rng (seed); 1898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (int y = 0; y < gridsize; y++) 1918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (int x = 0; x < gridsize; x++) 1928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 1938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const bool isEdge = x == 0 || y == 0 || x == resolution || y == resolution; 1948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float x_ = float(x)/float(resolution)*2.0f - 1.0f + (isEdge ? 0.0f : rng.getFloat(-xyNoise, +xyNoise)); 1958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float y_ = float(y)/float(resolution)*2.0f - 1.0f + (isEdge ? 0.0f : rng.getFloat(-xyNoise, +xyNoise)); 1968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float z_ = baseDepth + rng.getFloat(-depthNoise, +depthNoise); 1978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vertices[y*gridsize + x] = Vec3(x_, y_, z_); 1998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry retval.reserve(resolution*resolution*6); 2028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (int y = 0; y < resolution; y++) 2048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (int x = 0; x < resolution; x++) 2058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Vec3& p0 = vertices[(y+0)*gridsize + (x+0)]; 2078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Vec3& p1 = vertices[(y+0)*gridsize + (x+1)]; 2088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Vec3& p2 = vertices[(y+1)*gridsize + (x+0)]; 2098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Vec3& p3 = vertices[(y+1)*gridsize + (x+1)]; 2108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float temp[6*4] = 2128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry p0.x(), p0.y(), p0.z(), 0.0f, 2148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry p2.x(), p2.y(), p2.z(), 1.0f, 2158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry p1.x(), p1.y(), p1.z(), 2.0f, 2168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry p3.x(), p3.y(), p3.z(), 0.0f, 2188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry p1.x(), p1.y(), p1.z(), 1.0f, 2198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry p2.x(), p2.y(), p2.z(), 2.0f, 2208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry }; 2218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry retval.insert(retval.end(), DE_ARRAY_BEGIN(temp), DE_ARRAY_END(temp)); 2238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return retval; 2268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Outputs barycentric coordinates as v_bcoords. Otherwise a passthrough shader 2298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getBaseVertexShader (void) 2308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 2328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in highp vec4 a_position;\n" 2338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec3 v_bcoords;\n" 2348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 2358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 2368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " v_bcoords = vec3(0, 0, 0);\n" 2378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " v_bcoords[int(a_position.w)] = 1.0;\n" 2388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " gl_Position = vec4(a_position.xyz, 1.0);\n" 2398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 2408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Adds noise to coordinates based on InstanceID Outputs barycentric coordinates as v_bcoords 2438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getInstanceNoiseVertexShader (void) 2448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 2468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in highp vec4 a_position;\n" 2478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec3 v_bcoords;\n" 2488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 2498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 2508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " v_bcoords = vec3(0, 0, 0);\n" 2518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " v_bcoords[int(a_position.w)] = 1.0;\n" 2528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " vec3 noise = vec3(sin(float(gl_InstanceID)*1.05), sin(float(gl_InstanceID)*1.23), sin(float(gl_InstanceID)*1.71));\n" 2538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " gl_Position = vec4(a_position.xyz + noise * 0.005, 1.0);\n" 2548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 2558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Renders green triangles with edges highlighted. Exact shade depends on depth. 2588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getDepthAsGreenFragmentShader (void) 2598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 2618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 2628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 2638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 2648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 2658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 2668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 2678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,1,d,1);\n" 2688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 2698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(0,d,0,1);\n" 2708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 2718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Renders green triangles with edges highlighted. Exact shade depends on depth. 2748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getDepthAsRedFragmentShader (void) 2758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 2778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 2788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 2798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 2808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 2818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 2828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 2838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(1,d,d,1);\n" 2848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 2858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,0,0,1);\n" 2868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 2878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 2888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Basic time waster. Renders red triangles with edges highlighted. Exact shade depends on depth. 2908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getArithmeticWorkloadFragmentShader (void) 2918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 2928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 2938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 2948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 2958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 2968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "uniform mediump int u_iterations;\n" 2978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 2988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 2998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 3008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " for (int i = 0; i<u_iterations; i++)\n" 3018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // cos(a)^2 + sin(a)^2 == 1. since d is in range [0,1] this will lose a few ULP's of precision per iteration but should not significantly change the value of d without extreme iteration counts 3028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n" 3038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 3048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(1,d,d,1);\n" 3058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 3068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,0,0,1);\n" 3078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 3088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Arithmetic workload shader but contains discard 3118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getArithmeticWorkloadDiscardFragmentShader (void) 3128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 3148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 3158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 3168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "uniform mediump int u_iterations;\n" 3178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 3188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 3198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 3208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " for (int i = 0; i<u_iterations; i++)\n" 3218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n" 3228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (d < 0.5) discard;\n" 3238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 3248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(1,d,d,1);\n" 3258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 3268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,0,0,1);\n" 3278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 3288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Texture fetch based time waster. Renders red triangles with edges highlighted. Exact shade depends on depth. 3318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getTextureWorkloadFragmentShader (void) 3328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 3348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 3358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 3368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "uniform mediump int u_iterations;\n" 3378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "uniform sampler2D u_texture;\n" 3388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 3398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 3408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 3418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " for (int i = 0; i<u_iterations; i++)\n" 3428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " d *= texture(u_texture, (gl_FragCoord.xy+vec2(i))/512.0).r;\n" // Texture is expected to be fully white 3438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 3448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(1,1,1,1);\n" 3458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 3468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,0,0,1);\n" 3478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 3488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Discard fragments in a grid pattern 3518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getGridDiscardFragmentShader (int gridsize) 3528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const string fragSrc = "#version 300 es\n" 3548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 3558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 3568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 3578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 3588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 3598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if ((int(gl_FragCoord.x)/${GRIDRENDER_SIZE} + int(gl_FragCoord.y)/${GRIDRENDER_SIZE})%2 == 0)\n" 3608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " discard;\n" 3618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 3628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,1,d,1);\n" 3638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 3648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(0,d,0,1);\n" 3658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 3668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry map<string, string> params; 3678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry params["GRIDRENDER_SIZE"] = de::toString(gridsize); 3698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return tcu::StringTemplate(fragSrc).specialize(params); 3718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // A static increment to frag depth 3748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getStaticFragDepthFragmentShader (void) 3758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 3778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 3788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 3798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 3808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 3818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 3828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " gl_FragDepth = gl_FragCoord.z + 0.1;\n" 3838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 3848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,1,d,1);\n" 3858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 3868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(0,d,0,1);\n" 3878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 3888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 3898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 3908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // A trivial dynamic change to frag depth 3918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getDynamicFragDepthFragmentShader (void) 3928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 3938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 3948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 3958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 3968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 3978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 3988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 3998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " gl_FragDepth = gl_FragCoord.z + (v_bcoords.x + v_bcoords.y + v_bcoords.z)*0.05;\n" // Sum of v_bcoords components is allways 1 4008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 4018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,1,d,1);\n" 4028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 4038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(0,d,0,1);\n" 4048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 4058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // A static increment to frag depth 4088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getStaticFragDepthArithmeticWorkloadFragmentShader (void) 4098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 4118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 4128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 4138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "uniform mediump int u_iterations;\n" 4148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 4158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 4168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 4178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " gl_FragDepth = gl_FragCoord.z + 0.1;\n" 4188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " for (int i = 0; i<u_iterations; i++)\n" 4198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n" 4208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 4218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(1,d,d,1);\n" 4228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 4238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,0,0,1);\n" 4248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 4258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // A trivial dynamic change to frag depth 4288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry string getDynamicFragDepthArithmeticWorkloadFragmentShader (void) 4298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return "#version 300 es\n" 4318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "in mediump vec3 v_bcoords;\n" 4328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "out mediump vec4 fragColor;\n" 4338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "uniform mediump int u_iterations;\n" 4348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "void main()\n" 4358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "{\n" 4368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " mediump float d = gl_FragCoord.z;\n" 4378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " gl_FragDepth = gl_FragCoord.z + (v_bcoords.x + v_bcoords.y + v_bcoords.z)*0.05;\n" // Sum of v_bcoords components is allways 1 4388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " for (int i = 0; i<u_iterations; i++)\n" 4398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " d = d*sin(d)*sin(d) + d*cos(d)*cos(d);\n" 4408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " if (v_bcoords.x < 0.02 || v_bcoords.y < 0.02 || v_bcoords.z < 0.02)\n" 4418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(1,d,d,1);\n" 4428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " else\n" 4438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry " fragColor = vec4(d,0,0,1);\n" 4448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "}\n"; 4458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::ProgramSources getBaseShader (void) 4488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return glu::makeVtxFragSources(getBaseVertexShader(), getDepthAsGreenFragmentShader()); 4508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::ProgramSources getArithmeticWorkloadShader (void) 4538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return glu::makeVtxFragSources(getBaseVertexShader(), getArithmeticWorkloadFragmentShader()); 4558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::ProgramSources getArithmeticWorkloadDiscardShader (void) 4588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return glu::makeVtxFragSources(getBaseVertexShader(), getArithmeticWorkloadDiscardFragmentShader()); 4608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::ProgramSources getTextureWorkloadShader (void) 4638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return glu::makeVtxFragSources(getBaseVertexShader(), getTextureWorkloadFragmentShader()); 4658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::ProgramSources getGridDiscardShader (int gridsize) 4688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return glu::makeVtxFragSources(getBaseVertexShader(), getGridDiscardFragmentShader(gridsize)); 4708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry inline ObjectData quadWith (const glu::ProgramSources& shader, float depth) 4738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(shader, getFullscreenQuad(depth)); 4758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry inline ObjectData quadWith (const string& fragShader, float depth) 4788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(glu::makeVtxFragSources(getBaseVertexShader(), fragShader), getFullscreenQuad(depth)); 4808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry inline ObjectData variableQuad (float depth) 4838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(glu::makeVtxFragSources(getInstanceNoiseVertexShader(), getDepthAsRedFragmentShader()), getFullscreenQuad(depth)); 4858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry inline ObjectData fastQuad (float depth) 4888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(getBaseShader(), getFullscreenQuad(depth)); 4908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry inline ObjectData slowQuad (float depth) 4938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(getArithmeticWorkloadShader(), getFullscreenQuad(depth)); 4958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 4968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 4978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry inline ObjectData fastQuadWithGradient (float depth0, float depth1) 4988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 4998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(getBaseShader(), getFullscreenQuadWithGradient(depth0, depth1)); 5008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 5018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // Utils 5028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Shared base 5048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass BaseCase : public tcu::TestCase 5058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 5068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 5078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry enum {RENDER_SIZE = 512}; 5088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry BaseCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc); 5108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~BaseCase (void) {} 5118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual IterateResult iterate (void); 5138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprotected: 5158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry void logSamples (const vector<Sample>& samples, const string& name, const string& desc); 5168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry void logGeometry (const tcu::ConstPixelBufferAccess& sample, const glu::ShaderProgram& occluderProg, const glu::ShaderProgram& occludedProg); 5178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logAnalysis (const vector<Sample>& samples) = 0; 5188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) = 0; 5198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const = 0; 5218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const = 0; 5228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual int calibrate (void) const = 0; 5248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual Sample renderSample (const RenderData& occluder, const RenderData& occluded, int workload) const = 0; 5258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry void render (const RenderData& data) const; 5278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry void render (const RenderData& data, int instances) const; 5288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const RenderContext& m_renderCtx; 5308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::ResultCollector m_results; 5318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry enum {ITERATION_STEPS = 10, ITERATION_SAMPLES = 16}; 5338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 5348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryBaseCase::BaseCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 5368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : TestCase (testCtx, tcu::NODETYPE_PERFORMANCE, name, desc) 5378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_renderCtx (renderCtx) 5388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 5398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 5408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryBaseCase::IterateResult BaseCase::iterate (void) 5428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 5438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry typedef de::MovePtr<RenderData> RenderDataP; 5448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 5468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 5478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glu::Framebuffer framebuffer (gl); 5498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glu::Renderbuffer renderbuffer (gl); 5508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glu::Renderbuffer depthbuffer (gl); 5518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<Sample> results; 5538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<int> params; 5548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry RenderDataP occluderData; 5558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry RenderDataP occludedData; 5568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TextureLevel resultTex (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), RENDER_SIZE, RENDER_SIZE); 5578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int maxWorkload = 0; 5588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry de::Random rng (deInt32Hash(deStringHash(getName())) ^ m_testCtx.getCommandLine().getBaseSeed()); 5598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry logDescription(); 5618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindRenderbuffer(GL_RENDERBUFFER, *renderbuffer); 5638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.renderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, RENDER_SIZE, RENDER_SIZE); 5648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindRenderbuffer(GL_RENDERBUFFER, *depthbuffer); 5658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.renderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, RENDER_SIZE, RENDER_SIZE); 5668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindFramebuffer(GL_FRAMEBUFFER, *framebuffer); 5688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, *renderbuffer); 5698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, *depthbuffer); 5708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.viewport(0, 0, RENDER_SIZE, RENDER_SIZE); 5718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clearColor(0.125f, 0.25f, 0.5f, 1.0f); 5728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry maxWorkload = calibrate(); 5748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Setup data 5768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry occluderData = RenderDataP(new RenderData (genOccluderGeometry(), m_renderCtx, log)); 5778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry occludedData = RenderDataP(new RenderData (genOccludedGeometry(), m_renderCtx, log)); 5788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TCU_CHECK(occluderData->m_program.isOk()); 5808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TCU_CHECK(occludedData->m_program.isOk()); 5818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Force initialization of GPU resources 5838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 5848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.enable(GL_DEPTH_TEST); 5858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(*occluderData); 5878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(*occludedData); 5888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry glu::readPixels(m_renderCtx, 0, 0, resultTex.getAccess()); 5898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry logGeometry(resultTex.getAccess(), occluderData->m_program, occludedData->m_program); 5918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry params.reserve(ITERATION_STEPS*ITERATION_SAMPLES); 5938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Setup parameters 5958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (int step = 0; step < ITERATION_STEPS; step++) 5968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 5978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int workload = maxWorkload*step/ITERATION_STEPS; 5988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 5998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (int count = 0; count < ITERATION_SAMPLES; count++) 6008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry params.push_back(workload); 6018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry rng.shuffle(params.begin(), params.end()); 6048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Render samples 6068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (size_t ndx = 0; ndx < params.size(); ndx++) 6078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int workload = params[ndx]; 6098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Sample sample = renderSample(*occluderData, *occludedData, workload); 6108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.workload = workload; 6128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.order = int(ndx); 6138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry results.push_back(sample); 6158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry logSamples(results, "Samples", "Samples"); 6188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry logAnalysis(results); 6198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.setTestContextResult(m_testCtx); 6218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return STOP; 6238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 6248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid BaseCase::logSamples (const vector<Sample>& samples, const string& name, const string& desc) 6268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 6278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 6288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry bool testOnly = true; 6308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (size_t ndx = 0; ndx < samples.size(); ndx++) 6328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (samples[ndx].baseTime != 0 || samples[ndx].nullTime != 0) 6348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry testOnly = false; 6368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 6378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::SampleList(name, desc); 6418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (testOnly) 6438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::SampleInfo 6458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("Workload", "Workload", "", QP_SAMPLE_VALUE_TAG_PREDICTOR) 6468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("Order", "Order of sample", "", QP_SAMPLE_VALUE_TAG_PREDICTOR) 6478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("TestTime", "Test render time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 6488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::EndSampleInfo; 6498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (size_t sampleNdx = 0; sampleNdx < samples.size(); sampleNdx++) 6518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Sample& sample = samples[sampleNdx]; 6538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Sample << sample.workload << sample.order << sample.testTime << TestLog::EndSample; 6558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else 6588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::SampleInfo 6608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("Workload", "Workload", "", QP_SAMPLE_VALUE_TAG_PREDICTOR) 6618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("Order", "Order of sample", "", QP_SAMPLE_VALUE_TAG_PREDICTOR) 6628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("TestTime", "Test render time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 6638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("NullTime", "Read pixels time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 6648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::ValueInfo("BaseTime", "Base render time", "us", QP_SAMPLE_VALUE_TAG_RESPONSE) 6658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << TestLog::EndSampleInfo; 6668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (size_t sampleNdx = 0; sampleNdx < samples.size(); sampleNdx++) 6688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 6698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Sample& sample = samples[sampleNdx]; 6708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Sample << sample.workload << sample.order << sample.testTime << sample.nullTime << sample.baseTime << TestLog::EndSample; 6728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 6748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSampleList; 6768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 6778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid BaseCase::logGeometry (const tcu::ConstPixelBufferAccess& sample, const glu::ShaderProgram& occluderProg, const glu::ShaderProgram& occludedProg) 6798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 6808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 6818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Geometry", "Geometry"); 6838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Occluding geometry is green with shade dependent on depth (rgb == 0, depth, 0)" << TestLog::EndMessage; 6848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Occluded geometry is red with shade dependent on depth (rgb == depth, 0, 0)" << TestLog::EndMessage; 6858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Primitive edges are a lighter shade of red/green" << TestLog::EndMessage; 6868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Image("Test Geometry", "Test Geometry", sample); 6888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 6898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Occluder", "Occluder"); 6918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << occluderProg; 6928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 6938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Occluded", "Occluded"); 6958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << occludedProg; 6968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 6978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 6988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 6998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid BaseCase::render (const RenderData& data) const 7008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 7018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 7028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.useProgram(data.m_program.getProgram()); 7048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindVertexArray(*data.m_vao); 7068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.drawArrays(GL_TRIANGLES, 0, data.m_numVertices); 7078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindVertexArray(0); 7088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 7098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid BaseCase::render (const RenderData& data, int instances) const 7118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 7128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 7138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.useProgram(data.m_program.getProgram()); 7158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindVertexArray(*data.m_vao); 7178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.drawArraysInstanced(GL_TRIANGLES, 0, data.m_numVertices, instances); 7188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindVertexArray(0); 7198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 7208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Render occluder once, then repeatedly render occluded geometry. Sample with multiple repetition counts & establish time per call with linear regression 7228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass RenderCountCase : public BaseCase 7238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 7248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 7258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry RenderCountCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc); 7268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~RenderCountCase (void) {} 7278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprotected: 7298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logAnalysis (const vector<Sample>& samples); 7308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 7328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual int calibrate (void) const; 7338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual Sample renderSample (const RenderData& occluder, const RenderData& occluded, int callcount) const; 7348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 7358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryRenderCountCase::RenderCountCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 7378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : BaseCase (testCtx, renderCtx, name, desc) 7388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 7398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 7408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid RenderCountCase::logAnalysis (const vector<Sample>& samples) 7428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 7438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry using namespace gls; 7448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 7468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int maxWorkload = 0; 7478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<Vec2> testSamples (samples.size()); 7488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (size_t ndx = 0; ndx < samples.size(); ndx++) 7508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 7518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Sample& sample = samples[ndx]; 7528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry testSamples[ndx] = Vec2((float)sample.workload, (float)sample.testTime); 7548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry maxWorkload = de::max(maxWorkload, sample.workload); 7568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 7578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 7598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float confidence = 0.60f; 7608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence testParam = theilSenSiegelLinearRegression(testSamples, confidence); 7618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float usPerCall = testParam.coefficient; 7628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float pxPerCall = RENDER_SIZE*RENDER_SIZE; 7638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float pxPerUs = pxPerCall/usPerCall; 7648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float mpxPerS = pxPerUs; 7658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Linear Regression", "Linear Regression"); 7678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Offset & coefficient presented as [confidence interval min, estimate, confidence interval max]. Reported confidence interval for this test is " << confidence << TestLog::EndMessage; 7688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Render time for scene with depth test was\n\t" 7698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << testParam.offsetConfidenceLower << ", " << testParam.offset << ", " << testParam.offsetConfidenceUpper << "]us +" 7708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << testParam.coefficientConfidenceLower << ", " << testParam.coefficient << ", " << testParam.coefficientConfidenceUpper << "]" 7718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "us/workload" << TestLog::EndMessage; 7728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 7738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Result", "Result"); 7758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (testParam.coefficientConfidenceLower < 0.0f) 7778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 7788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Coefficient confidence bounds include values below 0.0, the operation likely has neglible per-pixel cost" << TestLog::EndMessage; 7798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, "Pass"); 7808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 7818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else if (testParam.coefficientConfidenceLower < testParam.coefficientConfidenceUpper*0.25) 7828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 7838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Coefficient confidence range is extremely large, cannot give reliable result" << TestLog::EndMessage; 7848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, "Result confidence extremely low"); 7858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 7868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else 7878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 7888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Culled hidden pixels @ " << mpxPerS << "Mpx/s" << TestLog::EndMessage; 7898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, de::floatToString(mpxPerS, 2)); 7908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 7918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 7938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 7948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 7958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 7968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyrySample RenderCountCase::renderSample (const RenderData& occluder, const RenderData& occluded, int callcount) const 7978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 7988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 7998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Sample sample; 8008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint64 now = 0; 8018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint64 prev = 0; 8028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint8 buffer[4]; 8038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Stabilize 8058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 8068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 8078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.enable(GL_DEPTH_TEST); 8088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 8098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 8108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 8128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 8148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.enable(GL_DEPTH_TEST); 8158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluder); 8178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluded, callcount); 8188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 8208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 8228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.testTime = now - prev; 8248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.baseTime = 0; 8258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.nullTime = 0; 8268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.workload = callcount; 8278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return sample; 8298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 8308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryint RenderCountCase::calibrate (void) const 8328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 8338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry using namespace gls; 8348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 8368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 8378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const RenderData occluderGeometry (genOccluderGeometry(), m_renderCtx, log); 8398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const RenderData occludedGeometry (genOccludedGeometry(), m_renderCtx, log); 8408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TheilSenCalibrator calibrator (CalibratorParameters(20, // Initial workload 8428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10, // Max iteration frames 8438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 20.0f, // Iteration shortcut threshold ms 8448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 20, // Max iterations 8458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 33.0f, // Target frame time 8468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 40.0f, // Frame time cap 8478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1000.0f // Target measurement duration 8488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry )); 8498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry while (true) 8518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 8528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry switch(calibrator.getState()) 8538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 8548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case TheilSenCalibrator::STATE_FINISHED: 8558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry logCalibrationInfo(m_testCtx.getLog(), calibrator); 8568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return calibrator.getCallCount(); 8578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case TheilSenCalibrator::STATE_MEASURE: 8598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 8608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint8 buffer[4]; 8618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deInt64 now; 8628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deInt64 prev; 8638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 8658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 8678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 8688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluderGeometry); 8708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occludedGeometry, calibrator.getCallCount()); 8718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 8738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 8758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry calibrator.recordIteration(now - prev); 8778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 8788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 8798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case TheilSenCalibrator::STATE_RECOMPUTE_PARAMS: 8818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry calibrator.recomputeParameters(); 8828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 8838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry default: 8848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry DE_ASSERT(false); 8858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 1; 8868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 8878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 8888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 8898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Compares time/workload gradients of same geometry with and without depth testing 8918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass RelativeChangeCase : public BaseCase 8928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 8938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 8948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry RelativeChangeCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc); 8958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~RelativeChangeCase (void) {} 8968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 8978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprotected: 8988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Sample renderSample (const RenderData& occluder, const RenderData& occluded, int workload) const; 8998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logAnalysis (const vector<Sample>& samples); 9018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 9038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int calibrate (void) const; 9048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 9058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryRelativeChangeCase::RelativeChangeCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 9078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : BaseCase (testCtx, renderCtx, name, desc) 9088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 9098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 9108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryint RelativeChangeCase::calibrate (void) const 9128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 9138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry using namespace gls; 9148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 9168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 9178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const RenderData geom (genOccludedGeometry(), m_renderCtx, log); 9198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TheilSenCalibrator calibrator(CalibratorParameters( 20, // Initial workload 9218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10, // Max iteration frames 9228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 20.0f, // Iteration shortcut threshold ms 9238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 20, // Max iterations 9248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10.0f, // Target frame time 9258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15.0f, // Frame time cap 9268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 1000.0f // Target measurement duration 9278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry )); 9288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry while (true) 9308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 9318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry switch(calibrator.getState()) 9328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 9338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case TheilSenCalibrator::STATE_FINISHED: 9348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry logCalibrationInfo(m_testCtx.getLog(), calibrator); 9358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return calibrator.getCallCount(); 9368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case TheilSenCalibrator::STATE_MEASURE: 9388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 9398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint8 buffer[4]; 9408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const GLuint program = geom.m_program.getProgram(); 9418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.useProgram(program); 9438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.uniform1i(gl.getUniformLocation(program, "u_iterations"), calibrator.getCallCount()); 9448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const deInt64 prev = deGetMicroseconds(); 9468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 9488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 9498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(geom); 9518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 9538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const deInt64 now = deGetMicroseconds(); 9558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry calibrator.recordIteration(now - prev); 9578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 9588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 9598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry case TheilSenCalibrator::STATE_RECOMPUTE_PARAMS: 9618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry calibrator.recomputeParameters(); 9628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry break; 9638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry default: 9648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry DE_ASSERT(false); 9658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return 1; 9668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 9678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 9688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 9698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyrySample RelativeChangeCase::renderSample (const RenderData& occluder, const RenderData& occluded, int workload) const 9718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 9728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 9738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const GLuint program = occluded.m_program.getProgram(); 9748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Sample sample; 9758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint64 now = 0; 9768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint64 prev = 0; 9778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint8 buffer[4]; 9788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.useProgram(program); 9808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.uniform1i(gl.getUniformLocation(program, "u_iterations"), workload); 9818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Warmup (this workload seems to reduce variation in following workloads) 9838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 9848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 9858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 9868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 9888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 9898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Null time 9918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 9928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 9938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 9958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 9968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 9988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 9998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 10008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.nullTime = now - prev; 10028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 10038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Test time 10058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 10068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 10078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 10098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.enable(GL_DEPTH_TEST); 10108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluder); 10128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluded); 10138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 10158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 10178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.testTime = now - prev; 10198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 10208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Base time 10228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 10238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 10248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 10268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 10278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluder); 10298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluded); 10308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 10328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 10348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.baseTime = now - prev; 10368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 10378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.workload = 0; 10398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return sample; 10418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 10428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid RelativeChangeCase::logAnalysis (const vector<Sample>& samples) 10448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 10458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry using namespace gls; 10468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 10488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int maxWorkload = 0; 10508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<Vec2> nullSamples (samples.size()); 10528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<Vec2> baseSamples (samples.size()); 10538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry vector<Vec2> testSamples (samples.size()); 10548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry for (size_t ndx = 0; ndx < samples.size(); ndx++) 10568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 10578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const Sample& sample = samples[ndx]; 10588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry nullSamples[ndx] = Vec2((float)sample.workload, (float)sample.nullTime); 10608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry baseSamples[ndx] = Vec2((float)sample.workload, (float)sample.baseTime); 10618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry testSamples[ndx] = Vec2((float)sample.workload, (float)sample.testTime); 10628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry maxWorkload = de::max(maxWorkload, sample.workload); 10648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 10658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 10678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float confidence = 0.60f; 10688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence nullParam = theilSenSiegelLinearRegression(nullSamples, confidence); 10708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence baseParam = theilSenSiegelLinearRegression(baseSamples, confidence); 10718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const LineParametersWithConfidence testParam = theilSenSiegelLinearRegression(testSamples, confidence); 10728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (!de::inRange(0.0f, nullParam.coefficientConfidenceLower, nullParam.coefficientConfidenceUpper)) 10748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 10758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_FAIL, "Constant operation sequence duration not constant"); 10768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Constant operation sequence timing may vary as a function of workload. Result quality extremely low" << TestLog::EndMessage; 10778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 10788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (de::inRange(0.0f, baseParam.coefficientConfidenceLower, baseParam.coefficientConfidenceUpper)) 10808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 10818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_FAIL, "Workload has no effect on duration"); 10828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload factor has no effect on duration of sample (smart optimizer?)" << TestLog::EndMessage; 10838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 10848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Linear Regression", "Linear Regression"); 10868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Offset & coefficient presented as [confidence interval min, estimate, confidence interval max]. Reported confidence interval for this test is " << confidence << TestLog::EndMessage; 10878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Render time for empty scene was\n\t" 10898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << nullParam.offsetConfidenceLower << ", " << nullParam.offset << ", " << nullParam.offsetConfidenceUpper << "]us +" 10908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << nullParam.coefficientConfidenceLower << ", " << nullParam.coefficient << ", " << nullParam.coefficientConfidenceUpper << "]" 10918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "us/workload" << TestLog::EndMessage; 10928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Render time for scene without depth test was\n\t" 10948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << baseParam.offsetConfidenceLower << ", " << baseParam.offset << ", " << baseParam.offsetConfidenceUpper << "]us +" 10958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << baseParam.coefficientConfidenceLower << ", " << baseParam.coefficient << ", " << baseParam.coefficientConfidenceUpper << "]" 10968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "us/workload" << TestLog::EndMessage; 10978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 10988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Render time for scene with depth test was\n\t" 10998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << testParam.offsetConfidenceLower << ", " << testParam.offset << ", " << testParam.offsetConfidenceUpper << "]us +" 11008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "[" << testParam.coefficientConfidenceLower << ", " << testParam.coefficient << ", " << testParam.coefficientConfidenceUpper << "]" 11018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "us/workload" << TestLog::EndMessage; 11028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 11048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry if (de::inRange(0.0f, testParam.coefficientConfidenceLower, testParam.coefficientConfidenceUpper)) 11068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Test duration not dependent on culled workload" << TestLog::EndMessage; 11088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, "0.0"); 11098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else if (testParam.coefficientConfidenceLower < testParam.coefficientConfidenceUpper*0.25) 11118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Coefficient confidence range is extremely large, cannot give reliable result" << TestLog::EndMessage; 11138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, "Result confidence extremely low"); 11148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else if (baseParam.coefficientConfidenceLower < baseParam.coefficientConfidenceUpper*0.25) 11168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Coefficient confidence range for base render time is extremely large, cannot give reliable result" << TestLog::EndMessage; 11188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, "Result confidence extremely low"); 11198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry else 11218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Test duration is dependent on culled workload" << TestLog::EndMessage; 11238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_results.addResult(QP_TEST_RESULT_PASS, de::floatToString(de::abs(testParam.coefficient)/de::abs(baseParam.coefficient), 2)); 11248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 11278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Speed of trivial culling 11298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass BaseCostCase : public RenderCountCase 11308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 11318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 11328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry BaseCostCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 11338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase (testCtx, renderCtx, name, desc) {} 11348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~BaseCostCase (void) {} 11368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 11388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 11398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::variableQuad(0.8f); } 11408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 11428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 11448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 11468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 11478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second (occluded) is rendered repeatedly" << TestLog::EndMessage; 11488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 11498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 11508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 11518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 11538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Gradient 11558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass GradientCostCase : public RenderCountCase 11568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 11578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 11588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry GradientCostCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc, float gradientDistance) 11598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase (testCtx, renderCtx, name, desc) 11608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_gradientDistance (gradientDistance) 11618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~GradientCostCase (void) {} 11658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 11678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuadWithGradient(0.0f, 1.0f - m_gradientDistance); } 11688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const 11698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(glu::makeVtxFragSources(Utils::getInstanceNoiseVertexShader(), Utils::getDepthAsRedFragmentShader()), Utils::getFullscreenQuadWithGradient(m_gradientDistance, 1.0f)); 11718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 11748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 11768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 11788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 11798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second (occluded) is rendered repeatedly" << TestLog::EndMessage; 11808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 11818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The quads are tilted so that the left edge of the occluded quad has a depth of 1.0 and the right edge of the occluding quad has a depth of 0.0." << TestLog::EndMessage; 11828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The quads are spaced to have a depth difference of " << m_gradientDistance << " at all points." << TestLog::EndMessage; 11838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 11848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 11858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float m_gradientDistance; 11888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 11898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Constant offset to frag depth in occluder 11918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass OccluderStaticFragDepthCostCase : public RenderCountCase 11928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 11938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 11948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry OccluderStaticFragDepthCostCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 11958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase(testCtx, renderCtx, name, desc) 11968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 11978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 11988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 11998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~OccluderStaticFragDepthCostCase (void) {} 12008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 12028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::quadWith(Utils::getStaticFragDepthFragmentShader(), 0.2f); } 12038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::fastQuad(0.8f); } 12048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 12068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 12088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 12108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 12118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second (occluded) is rendered repeatedly" << TestLog::EndMessage; 12128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 12138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluder quad has a static offset applied to gl_FragDepth" << TestLog::EndMessage; 12148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 12158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 12168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 12178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 12188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Dynamic offset to frag depth in occluder 12208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass OccluderDynamicFragDepthCostCase : public RenderCountCase 12218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 12228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 12238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry OccluderDynamicFragDepthCostCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 12248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase(testCtx, renderCtx, name, desc) 12258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 12278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~OccluderDynamicFragDepthCostCase (void) {} 12298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 12318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::quadWith(Utils::getDynamicFragDepthFragmentShader(), 0.2f); } 12328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::fastQuad(0.8f); } 12338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 12358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 12378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 12398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 12408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second (occluded) is rendered repeatedly" << TestLog::EndMessage; 12418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 12428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluder quad has a dynamic offset applied to gl_FragDepth" << TestLog::EndMessage; 12438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 12448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 12458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 12468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 12478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Constant offset to frag depth in occluder 12498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass OccludedStaticFragDepthCostCase : public RenderCountCase 12508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 12518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 12528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry OccludedStaticFragDepthCostCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 12538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase(testCtx, renderCtx, name, desc) 12548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 12568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~OccludedStaticFragDepthCostCase (void) {} 12588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 12608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 12618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::quadWith(Utils::getStaticFragDepthFragmentShader(), 0.2f); } 12628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 12648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 12668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 12688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 12698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second (occluded) is rendered repeatedly" << TestLog::EndMessage; 12708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 12718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluded quad has a static offset applied to gl_FragDepth" << TestLog::EndMessage; 12728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 12738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 12748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 12758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 12768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Dynamic offset to frag depth in occluder 12788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass OccludedDynamicFragDepthCostCase : public RenderCountCase 12798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 12808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 12818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry OccludedDynamicFragDepthCostCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 12828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase(testCtx, renderCtx, name, desc) 12838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 12858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~OccludedDynamicFragDepthCostCase (void) {} 12878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 12898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 12908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::quadWith(Utils::getDynamicFragDepthFragmentShader(), 0.2f); } 12918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 12938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 12948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 12958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 12968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 12978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 12988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) is rendered once, the second (occluded) is rendered repeatedly" << TestLog::EndMessage; 12998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 13008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluded quad has a dynamic offset applied to gl_FragDepth" << TestLog::EndMessage; 13018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 13028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 13038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 13048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 13058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Culling speed with slightly less trivial geometry 13078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass OccludingGeometryComplexityCostCase : public RenderCountCase 13088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 13098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 13108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry OccludingGeometryComplexityCostCase (TestContext& testCtx, 13118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const RenderContext& renderCtx, 13128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const char* name, 13138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const char* desc, 13148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry int resolution, 13158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry float xyNoise, 13168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry float zNoise) 13178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RenderCountCase (testCtx, renderCtx, name, desc) 13188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_resolution (resolution) 13198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_xyNoise (xyNoise) 13208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_zNoise (zNoise) 13218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 13228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 13238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~OccludingGeometryComplexityCostCase (void) {} 13258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 13278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const 13288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 13298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(Utils::getBaseShader(), 13308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Utils::getFullScreenGrid(m_resolution, 13318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deInt32Hash(deStringHash(getName())) ^ m_testCtx.getCommandLine().getBaseSeed(), 13328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 0.2f, 13338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_zNoise, 13348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_xyNoise)); 13358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 13368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::variableQuad(0.8f); } 13388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 13408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 13418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 13428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 13448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing hidden fragment culling speed" << TestLog::EndMessage; 13458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of an occluding grid and an occluded fullsceen quad. The occluding geometry is rendered once, the occluded one is rendered repeatedly" << TestLog::EndMessage; 13468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of times the occluded quad is rendered" << TestLog::EndMessage; 13478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The time per culled pixel is estimated from the rate of change of rendering time as a function of workload" << TestLog::EndMessage; 13488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 13498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 13508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int m_resolution; 13528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float m_xyNoise; 13538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float m_zNoise; 13548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 13558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Cases with varying workloads in the fragment shader 13588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass FragmentWorkloadCullCase : public RelativeChangeCase 13598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 13608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 13618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry FragmentWorkloadCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc); 13628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~FragmentWorkloadCullCase (void) {} 13638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 13658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 13668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void); 13688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 13698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryFragmentWorkloadCullCase::FragmentWorkloadCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 13718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase (testCtx, renderCtx, name, desc) 13728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 13738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 13748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FragmentWorkloadCullCase::logDescription (void) 13768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 13778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 13788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 13808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of culled fragment workload on render time" << TestLog::EndMessage; 13818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) quad uses a trivial shader," 13828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "the second (occluded) contains significant fragment shader work" << TestLog::EndMessage; 13838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 13848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 13858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 13868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 13878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 13888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Additional workload consists of texture lookups 13908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass FragmentTextureWorkloadCullCase : public FragmentWorkloadCullCase 13918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 13928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 13938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry FragmentTextureWorkloadCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc); 13948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~FragmentTextureWorkloadCullCase (void) {} 13958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void init (void); 13978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void deinit (void); 13988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 13998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 14008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry typedef MovePtr<glu::Texture> TexPtr; 14018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const 14038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(Utils::getTextureWorkloadShader(), Utils::getFullscreenQuad(0.8f)); 14058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TexPtr m_texture; 14088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 14098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryFragmentTextureWorkloadCullCase::FragmentTextureWorkloadCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 14118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : FragmentWorkloadCullCase (testCtx, renderCtx, name, desc) 14128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 14138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 14148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FragmentTextureWorkloadCullCase::init (void) 14168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 14178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 14188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int size = 128; 14198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const vector<deUint8> data (size*size*4, 255); 14208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_texture = MovePtr<glu::Texture>(new glu::Texture(gl)); 14228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.bindTexture(GL_TEXTURE_2D, m_texture); 14248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.texImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]); 14258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 14268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.texParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 14278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 14288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid FragmentTextureWorkloadCullCase::deinit (void) 14308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 14318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry m_texture.clear(); 14328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 14338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Additional workload consists of arithmetic 14358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass FragmentArithmeticWorkloadCullCase : public FragmentWorkloadCullCase 14368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 14378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 14388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry FragmentArithmeticWorkloadCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 14398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : FragmentWorkloadCullCase (testCtx, renderCtx, name, desc) 14408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~FragmentArithmeticWorkloadCullCase (void) {} 14438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 14458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const 14468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(Utils::getArithmeticWorkloadShader(), Utils::getFullscreenQuad(0.8f)); 14488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 14508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Contains dynamicly unused discard after a series of calculations 14528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass FragmentDiscardArithmeticWorkloadCullCase : public FragmentWorkloadCullCase 14538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 14548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 14558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry FragmentDiscardArithmeticWorkloadCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 14568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : FragmentWorkloadCullCase (testCtx, renderCtx, name, desc) 14578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~FragmentDiscardArithmeticWorkloadCullCase (void) {} 14618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 14638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const 14648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return ObjectData(Utils::getArithmeticWorkloadDiscardShader(), Utils::getFullscreenQuad(0.8f)); 14668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 14698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 14718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 14738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of culled fragment workload on render time" << TestLog::EndMessage; 14748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) quad uses a trivial shader," 14758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "the second (occluded) contains significant fragment shader work and a discard that is never triggers but has a dynamic condition" << TestLog::EndMessage; 14768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 14778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 14788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 14798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 14808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 14828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Discards fragments from the occluder in a grid pattern 14848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass PartialOccluderDiscardCullCase : public RelativeChangeCase 14858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 14868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 14878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry PartialOccluderDiscardCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc, int gridsize) 14888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase (testCtx, renderCtx, name, desc) 14898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_gridsize (gridsize) 14908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 14918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 14928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ~PartialOccluderDiscardCullCase (void) {} 14938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 14958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::quadWith(Utils::getGridDiscardShader(m_gridsize), 0.2f); } 14968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::slowQuad(0.8f); } 14978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 14988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 14998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 15018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 15038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of partially discarded occluder on rendering time" << TestLog::EndMessage; 15048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullsceen quads. The first (occluding) quad discards half the " 15058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry "fragments in a grid pattern, the second (partially occluded) contains significant fragment shader work" << TestLog::EndMessage; 15068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 15078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 15088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in depth testing halving the render time" << TestLog::EndMessage; 15098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 15108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 15118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const int m_gridsize; 15138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 15148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Trivial occluder covering part of screen 15168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass PartialOccluderCullCase : public RelativeChangeCase 15178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 15188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 15198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry PartialOccluderCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc, float coverage) 15208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase (testCtx, renderCtx, name, desc) 15218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry , m_coverage (coverage) 15228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 15248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~PartialOccluderCullCase (void) {} 15258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 15278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return ObjectData(Utils::getBaseShader(), Utils::getPartScreenQuad(m_coverage, 0.2f)); } 15288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const {return Utils::slowQuad(0.8f); } 15298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 15318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 15338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 15358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of partial occluder on rendering time" << TestLog::EndMessage; 15368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two quads. The first (occluding) quad covers " << m_coverage*100.0f 15378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry << "% of the screen, while the second (partially occluded, fullscreen) contains significant fragment shader work" << TestLog::EndMessage; 15388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 15398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 15408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in render time increasing proportionally with unoccluded area" << TestLog::EndMessage; 15418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 15428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 15438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const float m_coverage; 15458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 15468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Constant offset to frag depth in occluder 15488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass StaticOccluderFragDepthCullCase : public RelativeChangeCase 15498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 15508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 15518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry StaticOccluderFragDepthCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 15528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase(testCtx, renderCtx, name, desc) 15538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 15558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~StaticOccluderFragDepthCullCase (void) {} 15578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 15598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::quadWith(Utils::getStaticFragDepthFragmentShader(), 0.2f); } 15608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::slowQuad(0.8f); } 15618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 15638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 15658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 15678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of non-default frag depth on culling efficiency" << TestLog::EndMessage; 15688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second (occluded) contains significant fragment shader work" << TestLog::EndMessage; 15698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 15708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluder quad has a static offset applied to gl_FragDepth" << TestLog::EndMessage; 15718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 15728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 15738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 15748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 15758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 15768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Dynamic offset to frag depth in occluder 15788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass DynamicOccluderFragDepthCullCase : public RelativeChangeCase 15798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 15808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 15818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry DynamicOccluderFragDepthCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 15828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase(testCtx, renderCtx, name, desc) 15838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 15858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~DynamicOccluderFragDepthCullCase (void) {} 15878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 15898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::quadWith(Utils::getDynamicFragDepthFragmentShader(), 0.2f); } 15908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::slowQuad(0.8f); } 15918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 15938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 15948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 15958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 15968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 15978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of non-default frag depth on culling efficiency" << TestLog::EndMessage; 15988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second (occluded) contains significant fragment shader work" << TestLog::EndMessage; 15998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 16008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluder quad has a dynamic offset applied to gl_FragDepth" << TestLog::EndMessage; 16018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 16028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 16038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 16048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 16068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Constant offset to frag depth in occluded 16088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass StaticOccludedFragDepthCullCase : public RelativeChangeCase 16098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 16108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 16118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry StaticOccludedFragDepthCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 16128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase(testCtx, renderCtx, name, desc) 16138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~StaticOccludedFragDepthCullCase (void) {} 16178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 16198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 16208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::quadWith(Utils::getStaticFragDepthArithmeticWorkloadFragmentShader(), 0.2f); } 16218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 16238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 16258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 16278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of non-default frag depth on rendering time" << TestLog::EndMessage; 16288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second (occluded) contains significant fragment shader work" << TestLog::EndMessage; 16298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 16308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluded quad has a static offset applied to gl_FragDepth" << TestLog::EndMessage; 16318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 16328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 16338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 16348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 16368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Dynamic offset to frag depth in occluded 16388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass DynamicOccludedFragDepthCullCase : public RelativeChangeCase 16398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 16408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 16418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry DynamicOccludedFragDepthCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 16428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase(testCtx, renderCtx, name, desc) 16438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~DynamicOccludedFragDepthCullCase (void) {} 16478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 16498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 16508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::quadWith(Utils::getDynamicFragDepthArithmeticWorkloadFragmentShader(), 0.2f); } 16518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 16538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 16558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 16578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of non-default frag depth on rendering time" << TestLog::EndMessage; 16588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullscreen quads. The first (occluding) quad is trivial, while the second (occluded) contains significant fragment shader work" << TestLog::EndMessage; 16598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 16608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The occluded quad has a dynamic offset applied to gl_FragDepth" << TestLog::EndMessage; 16618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 16628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 16638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 16648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 16668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry// Dynamic offset to frag depth in occluded 16688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryclass ReversedDepthOrderCullCase : public RelativeChangeCase 16698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 16708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyrypublic: 16718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ReversedDepthOrderCullCase (TestContext& testCtx, const RenderContext& renderCtx, const char* name, const char* desc) 16728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : RelativeChangeCase(testCtx, renderCtx, name, desc) 16738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry ~ReversedDepthOrderCullCase (void) {} 16778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryprivate: 16798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccluderGeometry (void) const { return Utils::fastQuad(0.2f); } 16808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual ObjectData genOccludedGeometry (void) const { return Utils::slowQuad(0.8f); } 16818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry virtual void logDescription (void) 16838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestLog& log = m_testCtx.getLog(); 16858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Section("Description", "Test description"); 16878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Testing effects of of back first rendering order on culling efficiency" << TestLog::EndMessage; 16888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Geometry consists of two fullscreen quads. The second (occluding) quad is trivial, while the first (occluded) contains significant fragment shader work" << TestLog::EndMessage; 16898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Workload indicates the number of iterations of dummy work done in the occluded quad's fragment shader" << TestLog::EndMessage; 16908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "The ratio of rendering times of this scene with/without depth testing are compared" << TestLog::EndMessage; 16918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::Message << "Successfull early Z-testing should result in no correlation between workload and render time" << TestLog::EndMessage; 16928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry log << TestLog::EndSection; 16938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 16948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 16958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Rendering order of occluder & occluded is reversed, otherwise identical to parent version 16968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Sample renderSample (const RenderData& occluder, const RenderData& occluded, int workload) const 16978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 16988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const glw::Functions& gl = m_renderCtx.getFunctions(); 16998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const GLuint program = occluded.m_program.getProgram(); 17008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry Sample sample; 17018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint64 now = 0; 17028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint64 prev = 0; 17038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry deUint8 buffer[4]; 17048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.useProgram(program); 17068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.uniform1i(gl.getUniformLocation(program, "u_iterations"), workload); 17078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Warmup (this workload seems to reduce variation in following workloads) 17098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 17118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 17128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 17148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 17158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Null time 17178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 17198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 17218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 17228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 17248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 17268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.nullTime = now - prev; 17288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 17298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Test time 17318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 17338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 17358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.enable(GL_DEPTH_TEST); 17368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluded); 17388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluder); 17398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 17418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 17438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.testTime = now - prev; 17458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 17468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry // Base time 17488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry prev = deGetMicroseconds(); 17508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 17528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.disable(GL_DEPTH_TEST); 17538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluded); 17558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry render(occluder); 17568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry gl.readPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); 17588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry now = deGetMicroseconds(); 17608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.baseTime = now - prev; 17628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 17638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry sample.workload = 0; 17658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry return sample; 17678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 17688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry}; 17698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // Anonymous 17718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko PoyryDepthTests::DepthTests (Context& context) 17738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry : TestCaseGroup (context, "depth", "Depth culling performance") 17748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 17758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 17768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyryvoid DepthTests::init (void) 17788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry{ 17798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry TestContext& testCtx = m_context.getTestContext(); 17808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry const RenderContext& renderCtx = m_context.getRenderContext(); 17818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const cullEfficiencyGroup = new tcu::TestCaseGroup(m_testCtx, "cull_efficiency", "Fragment cull efficiency"); 17848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry addChild(cullEfficiencyGroup); 17868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "workload", "Workload"); 17898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry cullEfficiencyGroup->addChild(group); 17918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new FragmentTextureWorkloadCullCase( testCtx, renderCtx, "workload_texture", "Fragment shader with texture lookup workload")); 17938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new FragmentArithmeticWorkloadCullCase( testCtx, renderCtx, "workload_arithmetic", "Fragment shader with arithmetic workload")); 17948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new FragmentDiscardArithmeticWorkloadCullCase( testCtx, renderCtx, "workload_arithmetic_discard", "Fragment shader that may discard with arithmetic workload")); 17958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 17968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 17978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 17988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "occluder_discard", "Discard"); 17998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry cullEfficiencyGroup->addChild(group); 18018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_256", "Parts of occluder geometry discarded", 256)); 18038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_128", "Parts of occluder geometry discarded", 128)); 18048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_64", "Parts of occluder geometry discarded", 64)); 18058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_32", "Parts of occluder geometry discarded", 32)); 18068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_16", "Parts of occluder geometry discarded", 16)); 18078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_8", "Parts of occluder geometry discarded", 8)); 18088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_4", "Parts of occluder geometry discarded", 4)); 18098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_2", "Parts of occluder geometry discarded", 2)); 18108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderDiscardCullCase(testCtx, renderCtx, "grid_1", "Parts of occluder geometry discarded", 1)); 18118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18138852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18148852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "partial_coverage", "Partial Coverage"); 18158852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18168852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry cullEfficiencyGroup->addChild(group); 18178852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18188852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "100", "Occluder covering only part of occluded geometry", 1.00f)); 18198852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "099", "Occluder covering only part of occluded geometry", 0.99f)); 18208852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "095", "Occluder covering only part of occluded geometry", 0.95f)); 18218852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "090", "Occluder covering only part of occluded geometry", 0.90f)); 18228852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "080", "Occluder covering only part of occluded geometry", 0.80f)); 18238852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "070", "Occluder covering only part of occluded geometry", 0.70f)); 18248852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "050", "Occluder covering only part of occluded geometry", 0.50f)); 18258852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "025", "Occluder covering only part of occluded geometry", 0.25f)); 18268852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new PartialOccluderCullCase(testCtx, renderCtx, "010", "Occluder covering only part of occluded geometry", 0.10f)); 18278852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18288852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18298852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18308852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "frag_depth", "Partial Coverage"); 18318852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18328852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry cullEfficiencyGroup->addChild(group); 18338852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18348852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new StaticOccluderFragDepthCullCase( testCtx, renderCtx, "occluder_static", "")); 18358852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new DynamicOccluderFragDepthCullCase(testCtx, renderCtx, "occluder_dynamic", "")); 18368852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new StaticOccludedFragDepthCullCase( testCtx, renderCtx, "occluded_static", "")); 18378852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new DynamicOccludedFragDepthCullCase(testCtx, renderCtx, "occluded_dynamic", "")); 18388852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18398852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18408852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18418852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "order", "Rendering order"); 18428852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18438852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry cullEfficiencyGroup->addChild(group); 18448852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18458852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new ReversedDepthOrderCullCase(testCtx, renderCtx, "reversed", "Back to front rendering order")); 18468852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18478852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18488852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18498852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18508852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const testCostGroup = new tcu::TestCaseGroup(m_testCtx, "culled_pixel_cost", "Fragment cull efficiency"); 18518852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18528852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry addChild(testCostGroup); 18538852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18548852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18558852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "gradient", "Gradients with small depth differences"); 18568852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18578852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry testCostGroup->addChild(group); 18588852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18598852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new BaseCostCase(testCtx, renderCtx, "flat", "")); 18608852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_050", "", 0.50f)); 18618852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_010", "", 0.10f)); 18628852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_005", "", 0.05f)); 18638852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_002", "", 0.02f)); 18648852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new GradientCostCase(testCtx, renderCtx, "gradient_001", "", 0.01f)); 18658852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18668852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18678852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18688852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "occluder_geometry", "Occluders with varying geometry complexity"); 18698852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18708852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry testCostGroup->addChild(group); 18718852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18728852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_5", "", 5, 0.0f, 0.0f)); 18738852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_15", "", 15, 0.0f, 0.0f)); 18748852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_25", "", 25, 0.0f, 0.0f)); 18758852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_50", "", 50, 0.0f, 0.0f)); 18768852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_uniform_grid_100", "", 100, 0.0f, 0.0f)); 18778852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18788852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_5", "", 5, 1.0f/5.0f, 0.0f)); 18798852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_15", "", 15, 1.0f/15.0f, 0.0f)); 18808852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_25", "", 25, 1.0f/25.0f, 0.0f)); 18818852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_50", "", 50, 1.0f/50.0f, 0.0f)); 18828852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "flat_noisy_grid_100", "", 100, 1.0f/100.0f, 0.0f)); 18838852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18848852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_5", "", 5, 0.0f, 0.2f)); 18858852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_15", "", 15, 0.0f, 0.2f)); 18868852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_25", "", 25, 0.0f, 0.2f)); 18878852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_50", "", 50, 0.0f, 0.2f)); 18888852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_uniform_grid_100", "", 100, 0.0f, 0.2f)); 18898852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18908852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_5", "", 5, 1.0f/5.0f, 0.2f)); 18918852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_15", "", 15, 1.0f/15.0f, 0.2f)); 18928852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_25", "", 25, 1.0f/25.0f, 0.2f)); 18938852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_50", "", 50, 1.0f/50.0f, 0.2f)); 18948852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludingGeometryComplexityCostCase(testCtx, renderCtx, "uneven_noisy_grid_100", "", 100, 1.0f/100.0f, 0.2f)); 18958852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 18968852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 18978852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry { 18988852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry tcu::TestCaseGroup* const group = new tcu::TestCaseGroup(m_testCtx, "frag_depth", "Modifying gl_FragDepth"); 18998852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 19008852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry testCostGroup->addChild(group); 19018852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 19028852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccluderStaticFragDepthCostCase( testCtx, renderCtx, "occluder_static", "")); 19038852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccluderDynamicFragDepthCostCase(testCtx, renderCtx, "occluder_dynamic", "")); 19048852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludedStaticFragDepthCostCase( testCtx, renderCtx, "occluded_static", "")); 19058852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry group->addChild(new OccludedDynamicFragDepthCostCase(testCtx, renderCtx, "occluded_dynamic", "")); 19068852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 19078852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry } 19088852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} 19098852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry 19108852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // Performance 19118852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // gles3 19128852c82a1ffa4760985c17cc6875d5d521daf343Jarkko Poyry} // deqp 1913