13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 2.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 Depth tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fDepthTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuImageCompare.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrContextUtil.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrReferenceContext.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "sglrGLContext.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::RGBA; 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DepthShader : public sglr::ShaderProgram 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DepthShader (void); 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setColor (sglr::Context& ctx, deUint32 programID, const tcu::Vec4& color); 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const; 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const; 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const sglr::UniformSlot& u_color; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDepthShader::DepthShader (void) 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : sglr::ShaderProgram(sglr::pdec::ShaderProgramDeclaration() 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexAttribute("a_position", rr::GENERICVECTYPE_FLOAT) 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::FragmentOutput(rr::GENERICVECTYPE_FLOAT) 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::Uniform("u_color", glu::TYPE_FLOAT_VEC4) 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::VertexSource("attribute highp vec4 a_position;\n" 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n") 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << sglr::pdec::FragmentSource("uniform mediump vec4 u_color;\n" 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_FragColor = u_color;\n" 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n")) 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , u_color(getUniformByName("u_color")) 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DepthShader::setColor (sglr::Context& ctx, deUint32 programID, const tcu::Vec4& color) 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.useProgram(programID); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ctx.uniform4fv(ctx.getUniformLocation(programID, "u_color"), 1, color.getPtr()); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DepthShader::shadeVertices (const rr::VertexAttrib* inputs, rr::VertexPacket* const* packets, const int numPackets) const 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry packets[packetNdx]->position = rr::readVertexAttribFloat(inputs[0], packets[packetNdx]->instanceNdx, packets[packetNdx]->vertexNdx); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DepthShader::shadeFragments (rr::FragmentPacket* packets, const int numPackets, const rr::FragmentShadingContext& context) const 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 color(u_color.value.f4); 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_UNREF(packets); 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int packetNdx = 0; packetNdx < numPackets; ++packetNdx) 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int fragNdx = 0; fragNdx < 4; ++fragNdx) 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry rr::writeFragmentOutput(context, packetNdx, fragNdx, 0, color); 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// \todo [2011-07-11 pyry] This code is duplicated in a quite many places. Move it to some utility? 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DepthCase : public TestCase 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DepthCase (Context& context, const char* name, const char* description); 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~DepthCase (void) {} 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual IterateResult iterate (void); 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void render (sglr::Context& context) = DE_NULL; 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDepthCase::DepthCase (Context& context, const char* name, const char* description) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase(context, name, description) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTestCase::IterateResult DepthCase::iterate (void) 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 clearColor = tcu::Vec4(0.125f, 0.25f, 0.5f, 1.0f); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::RenderContext& renderCtx = m_context.getRenderContext(); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RenderTarget& renderTarget = renderCtx.getRenderTarget(); 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestLog& log = m_testCtx.getLog(); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* failReason = DE_NULL; 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Position & size for context 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(deStringHash(getName())); 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = deMin32(renderTarget.getWidth(), 128); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = deMin32(renderTarget.getHeight(), 128); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int x = rnd.getInt(0, renderTarget.getWidth() - width); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int y = rnd.getInt(0, renderTarget.getHeight() - height); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface gles2Frame (width, height); 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface refFrame (width, height); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 gles2Error; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 refError; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render using GLES2 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::GLContext context(renderCtx, log, sglr::GLCONTEXT_LOG_CALLS, tcu::IVec4(x, y, width, height)); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w()); 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(context); // Call actual render func 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(gles2Frame, 0, 0, width, height); 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gles2Error = context.getError(); 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Render reference image 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContextBuffers buffers (tcu::PixelFormat(8,8,8,renderTarget.getPixelFormat().alphaBits?8:0), renderTarget.getDepthBits(), renderTarget.getStencilBits(), width, height); 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::ReferenceContext context (sglr::ReferenceContextLimits(renderCtx), buffers.getColorbuffer(), buffers.getDepthbuffer(), buffers.getStencilbuffer()); 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearColor(clearColor.x(), clearColor.y(), clearColor.z(), clearColor.w()); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry render(context); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.readPixels(refFrame, 0, 0, width, height); 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry refError = context.getError(); 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare error codes 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool errorCodesOk = (gles2Error == refError); 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!errorCodesOk) 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << tcu::TestLog::Message << "Error code mismatch: got " << glu::getErrorStr(gles2Error) << ", expected " << glu::getErrorStr(refError) << tcu::TestLog::EndMessage; 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry failReason = "Got unexpected error"; 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Compare images 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float threshold = 0.02f; 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool imagesOk = tcu::fuzzyCompare(log, "ComparisonResult", "Image comparison result", refFrame, gles2Frame, threshold, tcu::COMPARE_LOG_RESULT); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!imagesOk && !failReason) 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry failReason = "Image comparison failed"; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Store test result 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = errorCodesOk && imagesOk; 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(isOk ? QP_TEST_RESULT_PASS : QP_TEST_RESULT_FAIL, 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk ? "Pass" : failReason); 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass DepthCompareCase : public DepthCase 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DepthCompareCase (Context& context, const char* name, const char* description, deUint32 compareOp) 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : DepthCase (context, name, description) 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_compareOp (compareOp) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void render (sglr::Context& context) 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::Vec3; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DepthShader shader; 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 shaderID = context.createProgram(&shader); 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 red (1.0f, 0.0f, 0.0f, 1.0); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4 green (0.0f, 1.0f, 0.0f, 1.0f); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear depth to 1 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clearDepthf(1.0f); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.clear(GL_DEPTH_BUFFER_BIT); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Enable depth test. 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.enable(GL_DEPTH_TEST); 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upper left: two quads with same depth 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(GL_ALWAYS); 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, red); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(-1.0f, -1.0f, 0.2f), Vec3(0.0f, 0.0f, 0.2f)); 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(m_compareOp); 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, green); 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(-1.0f, -1.0f, 0.2f), Vec3(0.0f, 0.0f, 0.2f)); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Lower left: two quads, d1 < d2 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(GL_ALWAYS); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, red); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(-1.0f, 0.0f, -0.4f), Vec3(0.0f, 1.0f, -0.4f)); 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(m_compareOp); 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, green); 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(-1.0f, 0.0f, -0.1f), Vec3(0.0f, 1.0f, -0.1f)); 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Upper right: two quads, d1 > d2 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(GL_ALWAYS); 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, red); 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(0.0f, -1.0f, 0.5f), Vec3(1.0f, 0.0f, 0.5f)); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(m_compareOp); 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, green); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(0.0f, -1.0f, 0.3f), Vec3(1.0f, 0.0f, 0.3f)); 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Lower right: two quads, d1 = 0, d2 = [-1..1] 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(GL_ALWAYS); 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, red); 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(0.0f, 0.0f, 0.0f), Vec3(1.0f, 1.0f, 0.0f)); 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry context.depthFunc(m_compareOp); 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry shader.setColor(context, shaderID, green); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry sglr::drawQuad(context, shaderID, Vec3(0.0f, 0.0f, -1.0f), Vec3(1.0f, 1.0f, 1.0f)); 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_compareOp; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDepthTests::DepthTests (Context& context) 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "depth", "Depth Tests") 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2593c827367444ee418f129b2c238299f49d3264554Jarkko PoyryDepthTests::~DepthTests (void) 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid DepthTests::init (void) 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_always", "Always pass depth test", GL_ALWAYS)); 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_never", "Never pass depth test", GL_NEVER)); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_equal", "Depth compare: equal", GL_EQUAL)); 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_not_equal", "Depth compare: not equal", GL_NOTEQUAL)); 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_less_than", "Depth compare: less than", GL_LESS)); 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_less_or_equal", "Depth compare: less than or equal", GL_LEQUAL)); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_greater_than", "Depth compare: greater than", GL_GREATER)); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new DepthCompareCase(m_context, "cmp_greater_or_equal", "Depth compare: greater than or equal", GL_GEQUAL)); 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 278