es2fRandomFragmentOpTests.cpp revision ce69f90677293129efc908755aa3e73605478c08
13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.0 Module 33c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * ------------------------------------------------- 43c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 53c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Copyright 2014 The Android Open Source Project 63c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 73c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Licensed under the Apache License, Version 2.0 (the "License"); 83c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * you may not use this file except in compliance with the License. 93c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * You may obtain a copy of the License at 103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * http://www.apache.org/licenses/LICENSE-2.0 123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * Unless required by applicable law or agreed to in writing, software 143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * distributed under the License is distributed on an "AS IS" BASIS, 153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * See the License for the specific language governing permissions and 173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * limitations under the License. 183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * 193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*! 203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \file 213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * \brief Randomized per-fragment operation tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fRandomFragmentOpTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsFragmentOpUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsInteractionTestUtil.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuCommandLine.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTextureUtil.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h" 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "rrFragmentOperations.hpp" 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceUtils.hpp" 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <algorithm> 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing std::vector; 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec2; 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::IVec2; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::BVec4; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VIEWPORT_WIDTH = 64, 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry VIEWPORT_HEIGHT = 64, 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NUM_CALLS_PER_ITERATION = 3, 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry NUM_ITERATIONS_PER_CASE = 10 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const tcu::Vec4 CLEAR_COLOR (0.25f, 0.5f, 0.75f, 1.0f); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const float CLEAR_DEPTH = 1.0f; 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int CLEAR_STENCIL = 0; 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const bool ENABLE_CALL_LOG = true; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::FragmentOpUtil; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::InteractionTestUtil; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid translateStencilState (const StencilState& src, rr::StencilState& dst) 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.func = sglr::rr_util::mapGLTestFunc(src.function); 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.ref = src.reference; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.compMask = src.compareMask; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.sFail = sglr::rr_util::mapGLStencilOp(src.stencilFailOp); 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.dpFail = sglr::rr_util::mapGLStencilOp(src.depthFailOp); 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.dpPass = sglr::rr_util::mapGLStencilOp(src.depthPassOp); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.writeMask = src.writeMask; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid translateBlendState (const BlendState& src, rr::BlendState& dst) 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.equation = sglr::rr_util::mapGLBlendEquation(src.equation); 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.srcFunc = sglr::rr_util::mapGLBlendFunc(src.srcFunc); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.dstFunc = sglr::rr_util::mapGLBlendFunc(src.dstFunc); 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid translateState (const RenderState& src, rr::FragmentOperationState& dst, const tcu::RenderTarget& renderTarget) 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool hasDepth = renderTarget.getDepthBits() > 0; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool hasStencil = renderTarget.getStencilBits() > 0; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.scissorTestEnabled = src.scissorTestEnabled; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.scissorRectangle = src.scissorRectangle; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.stencilTestEnabled = hasStencil && src.stencilTestEnabled; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.depthTestEnabled = hasDepth && src.depthTestEnabled; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.blendMode = src.blendEnabled ? rr::BLENDMODE_STANDARD : rr::BLENDMODE_NONE; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.numStencilBits = renderTarget.getStencilBits(); 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.colorMask = src.colorMask; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (dst.depthTestEnabled) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.depthFunc = sglr::rr_util::mapGLTestFunc(src.depthFunc); 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.depthMask = src.depthWriteMask; 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (dst.stencilTestEnabled) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translateStencilState(src.stencil[rr::FACETYPE_BACK], dst.stencilStates[rr::FACETYPE_BACK]); 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translateStencilState(src.stencil[rr::FACETYPE_FRONT], dst.stencilStates[rr::FACETYPE_FRONT]); 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (src.blendEnabled) 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translateBlendState(src.blendRGBState, dst.blendRGBState); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translateBlendState(src.blendAState, dst.blendAState); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.blendColor = tcu::clamp(src.blendColor, Vec4(0.0f), Vec4(1.0f)); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void renderQuad (const glw::Functions& gl, gls::FragmentOpUtil::QuadRenderer& renderer, const gls::FragmentOpUtil::IntegerQuad& quad, int baseX, int baseY) 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::FragmentOpUtil::Quad translated; 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::copy(DE_ARRAY_BEGIN(quad.color), DE_ARRAY_END(quad.color), DE_ARRAY_BEGIN(translated.color)); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool flipX = quad.posB.x() < quad.posA.x(); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool flipY = quad.posB.y() < quad.posA.y(); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportX = de::min(quad.posA.x(), quad.posB.x()); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportY = de::min(quad.posA.y(), quad.posB.y()); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportW = de::abs(quad.posA.x()-quad.posB.x())+1; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int viewportH = de::abs(quad.posA.y()-quad.posB.y())+1; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translated.posA = Vec2(flipX ? 1.0f : -1.0f, flipY ? 1.0f : -1.0f); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translated.posB = Vec2(flipX ? -1.0f : 1.0f, flipY ? -1.0f : 1.0f); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \todo [2012-12-18 pyry] Pass in DepthRange parameters. 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(quad.depth); ndx++) 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translated.depth[ndx] = quad.depth[ndx]*2.0f - 1.0f; 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport(baseX+viewportX, baseY+viewportY, viewportW, viewportH); 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderer.render(translated); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void setGLState (glu::CallLogWrapper& wrapper, const RenderState& state, int viewportX, int viewportY) 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.scissorTestEnabled) 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glEnable(GL_SCISSOR_TEST); 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glScissor(viewportX+state.scissorRectangle.left, viewportY+state.scissorRectangle.bottom, 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry state.scissorRectangle.width, state.scissorRectangle.height); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDisable(GL_SCISSOR_TEST); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.stencilTestEnabled) 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glEnable(GL_STENCIL_TEST); 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int face = 0; face < rr::FACETYPE_LAST; face++) 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 glFace = face == rr::FACETYPE_BACK ? GL_BACK : GL_FRONT; 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const StencilState& sParams = state.stencil[face]; 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glStencilFuncSeparate(glFace, sParams.function, sParams.reference, sParams.compareMask); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glStencilOpSeparate(glFace, sParams.stencilFailOp, sParams.depthFailOp, sParams.depthPassOp); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glStencilMaskSeparate(glFace, sParams.writeMask); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDisable(GL_STENCIL_TEST); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.depthTestEnabled) 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glEnable(GL_DEPTH_TEST); 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDepthFunc(state.depthFunc); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDepthMask(state.depthWriteMask ? GL_TRUE : GL_FALSE); 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDisable(GL_DEPTH_TEST); 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.blendEnabled) 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glEnable(GL_BLEND); 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glBlendEquationSeparate(state.blendRGBState.equation, state.blendAState.equation); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glBlendFuncSeparate(state.blendRGBState.srcFunc, state.blendRGBState.dstFunc, state.blendAState.srcFunc, state.blendAState.dstFunc); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glBlendColor(state.blendColor.x(), state.blendColor.y(), state.blendColor.z(), state.blendColor.w()); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDisable(GL_BLEND); 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.ditherEnabled) 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glEnable(GL_DITHER); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glDisable(GL_DITHER); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry wrapper.glColorMask(state.colorMask[0] ? GL_TRUE : GL_FALSE, 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry state.colorMask[1] ? GL_TRUE : GL_FALSE, 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry state.colorMask[2] ? GL_TRUE : GL_FALSE, 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry state.colorMask[3] ? GL_TRUE : GL_FALSE); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RandomFragmentOpCase : public TestCase 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RandomFragmentOpCase (Context& context, const char* name, const char* desc, deUint32 seed); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RandomFragmentOpCase (void); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::UVec4 getCompareThreshold (void) const; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_seed; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::CallLogWrapper m_callLogWrapper; 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::FragmentOpUtil::QuadRenderer* m_renderer; 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel* m_refColorBuffer; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel* m_refDepthBuffer; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TextureLevel* m_refStencilBuffer; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::FragmentOpUtil::ReferenceQuadRenderer* m_refRenderer; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iterNdx; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomFragmentOpCase::RandomFragmentOpCase (Context& context, const char* name, const char* desc, deUint32 seed) 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, desc) 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_seed (seed) 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_callLogWrapper (context.getRenderContext().getFunctions(), context.getTestContext().getLog()) 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderer (DE_NULL) 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_refColorBuffer (DE_NULL) 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_refDepthBuffer (DE_NULL) 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_refStencilBuffer (DE_NULL) 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_refRenderer (DE_NULL) 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterNdx (0) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_callLogWrapper.enableLogging(ENABLE_CALL_LOG); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2513c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomFragmentOpCase::~RandomFragmentOpCase (void) 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_renderer; 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refColorBuffer; 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refDepthBuffer; 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refStencilBuffer; 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refRenderer; 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomFragmentOpCase::init (void) 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_renderer && !m_refColorBuffer && !m_refDepthBuffer && !m_refStencilBuffer && !m_refRenderer); 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = de::min<int>(m_context.getRenderTarget().getWidth(), VIEWPORT_WIDTH); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = de::min<int>(m_context.getRenderTarget().getHeight(), VIEWPORT_HEIGHT); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool useRGB = m_context.getRenderTarget().getPixelFormat().alphaBits == 0; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer = new gls::FragmentOpUtil::QuadRenderer(m_context.getRenderContext(), glu::GLSL_VERSION_100_ES); 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refColorBuffer = new tcu::TextureLevel(tcu::TextureFormat(useRGB ? tcu::TextureFormat::RGB : tcu::TextureFormat::RGBA, tcu::TextureFormat::UNORM_INT8), width, height); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refDepthBuffer = new tcu::TextureLevel(tcu::TextureFormat(tcu::TextureFormat::D, tcu::TextureFormat::FLOAT), width, height); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refStencilBuffer = new tcu::TextureLevel(tcu::TextureFormat(tcu::TextureFormat::S, tcu::TextureFormat::UNSIGNED_INT32), width, height); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refRenderer = new gls::FragmentOpUtil::ReferenceQuadRenderer(); 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iterNdx = 0; 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomFragmentOpCase::deinit (void) 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_renderer; 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refColorBuffer; 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refDepthBuffer; 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refStencilBuffer; 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_refRenderer; 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_renderer = DE_NULL; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refColorBuffer = DE_NULL; 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refDepthBuffer = DE_NULL; 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refStencilBuffer = DE_NULL; 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refRenderer = DE_NULL; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomFragmentOpCase::IterateResult RandomFragmentOpCase::iterate (void) 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 29671f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry const bool isMSAA = m_context.getRenderTarget().getNumSamples() > 1; 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 iterSeed = deUint32Hash(m_seed) ^ deInt32Hash(m_iterNdx) ^ deInt32Hash(m_testCtx.getCommandLine().getBaseSeed()); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (iterSeed); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = m_refColorBuffer->getWidth(); 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = m_refColorBuffer->getHeight(); 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int viewportX = rnd.getInt(0, m_context.getRenderTarget().getWidth()-width); 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int viewportY = rnd.getInt(0, m_context.getRenderTarget().getHeight()-height); 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface renderedImg (width, height); 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const Vec4 clearColor = CLEAR_COLOR; 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float clearDepth = CLEAR_DEPTH; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int clearStencil = CLEAR_STENCIL; 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool gotError = false; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection iterSection (m_testCtx.getLog(), std::string("Iteration") + de::toString(m_iterNdx), std::string("Iteration ") + de::toString(m_iterNdx)); 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compute randomized rendering commands. 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry vector<RenderCommand> commands; 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry computeRandomRenderCommands(rnd, glu::ApiType::es(2,0), NUM_CALLS_PER_ITERATION, width, height, commands); 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Reset default fragment state. 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.disable(GL_SCISSOR_TEST); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.colorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.depthMask(GL_TRUE); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.stencilMask(~0u); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render using GL. 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_callLogWrapper.glClearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w()); 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_callLogWrapper.glClearDepthf(clearDepth); 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_callLogWrapper.glClearStencil(clearStencil); 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_callLogWrapper.glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_callLogWrapper.glViewport(viewportX, viewportY, width, height); 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<RenderCommand>::const_iterator cmd = commands.begin(); cmd != commands.end(); cmd++) 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setGLState(m_callLogWrapper, cmd->state, viewportX, viewportY); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (ENABLE_CALL_LOG) 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << "// Quad: " << cmd->quad.posA << " -> " << cmd->quad.posB 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ", color: [" << cmd->quad.color[0] << ", " << cmd->quad.color[1] << ", " << cmd->quad.color[2] << ", " << cmd->quad.color[3] << "]" 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << ", depth: [" << cmd->quad.depth[0] << ", " << cmd->quad.depth[1] << ", " << cmd->quad.depth[2] << ", " << cmd->quad.depth[3] << "]" 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndMessage; 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderQuad(gl, *m_renderer, cmd->quad, viewportX, viewportY); 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Check error. 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_callLogWrapper.glGetError() != GL_NO_ERROR) 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gotError = true; 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.flush(); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference while GPU is doing work. 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clear (m_refColorBuffer->getAccess(), clearColor); 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clearDepth (m_refDepthBuffer->getAccess(), clearDepth); 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::clearStencil (m_refStencilBuffer->getAccess(), clearStencil); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (vector<RenderCommand>::const_iterator cmd = commands.begin(); cmd != commands.end(); cmd++) 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::FragmentOperationState refState; 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry translateState(cmd->state, refState, m_context.getRenderTarget()); 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_refRenderer->render(gls::FragmentOpUtil::getMultisampleAccess(m_refColorBuffer->getAccess()), 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::FragmentOpUtil::getMultisampleAccess(m_refDepthBuffer->getAccess()), 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gls::FragmentOpUtil::getMultisampleAccess(m_refStencilBuffer->getAccess()), 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry cmd->quad, refState); 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read rendered image. 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), viewportX, viewportY, renderedImg.getAccess()); 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iterNdx += 1; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare to reference. 37271f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry bool isLastIter = m_iterNdx >= NUM_ITERATIONS_PER_CASE; 37371f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry const tcu::UVec4 threshold = getCompareThreshold(); 37471f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry bool compareOk; 37571f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry 37671f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry if (isMSAA) 37771f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry { 37871f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry // in MSAA cases, the sampling points could be anywhere in the pixel and we could 37971f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry // even have multiple samples that are combined in resolve. Allow arbitrary sample 38071f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry // positions by using bilinearCompare. 38171f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry compareOk = tcu::bilinearCompare(m_testCtx.getLog(), 38271f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry "CompareResult", 38371f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry "Image Comparison Result", 38471f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry m_refColorBuffer->getAccess(), 38571f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry renderedImg.getAccess(), 38671f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry tcu::RGBA(threshold.x(), threshold.y(), threshold.z(), threshold.w()), 38771f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry tcu::COMPARE_LOG_RESULT); 38871f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry } 38971f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry else 39071f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry compareOk = tcu::intThresholdCompare(m_testCtx.getLog(), 39171f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry "CompareResult", 39271f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry "Image Comparison Result", 39371f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry m_refColorBuffer->getAccess(), 39471f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry renderedImg.getAccess(), 39571f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry threshold, 39671f9d74aee3c64e1b586dcd20ecd5f489bfd7d8bJarkko Pöyry tcu::COMPARE_LOG_RESULT); 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << (compareOk ? " Passed." : " FAILED!") << TestLog::EndMessage; 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!compareOk) 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image comparison failed"); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (gotError) 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "GL error"); 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (compareOk && !gotError && !isLastIter) 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyrytcu::UVec4 RandomFragmentOpCase::getCompareThreshold (void) const 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::PixelFormat format = m_context.getRenderTarget().getPixelFormat(); 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (format == tcu::PixelFormat(8, 8, 8, 8) || format == tcu::PixelFormat(8, 8, 8, 0)) 416ce69f90677293129efc908755aa3e73605478c08Pyry Haulos return format.getColorThreshold().toIVec().asUint() + tcu::UVec4(6); // Default threshold. 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return format.getColorThreshold().toIVec().asUint() 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * tcu::UVec4(5) + tcu::UVec4(2); // \note Non-scientific ad hoc formula. Need big threshold when few color bits; especially multiple blendings bring extra inaccuracy. 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomFragmentOpTests::RandomFragmentOpTests (Context& context) 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "random", "Randomized Per-Fragment Operation Tests") 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRandomFragmentOpTests::~RandomFragmentOpTests (void) 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RandomFragmentOpTests::init (void) 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < 100; ndx++) 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new RandomFragmentOpCase(m_context, de::toString(ndx).c_str(), "", (deUint32)(ndx*NUM_ITERATIONS_PER_CASE))); 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 440