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