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 Rasterizer discard tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es3fRasterizerDiscardTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deString.h" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glw.h" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::Vec4; 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing tcu::TestLog; 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles3 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int NUM_CASE_ITERATIONS = 1; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const Vec4 FAIL_COLOR_RED = Vec4(1.0f, 0.0f, 0.0f, 1.0f); 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const Vec4 PASS_COLOR_BLUE = Vec4(0.0f, 0.0f, 0.5f, 1.0f); 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const Vec4 BLACK_COLOR = Vec4(0.0f, 0.0f, 0.0f, 1.0f); 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const float FAIL_DEPTH = 0.0f; 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const int FAIL_STENCIL = 1; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const float UNIT_SQUARE[16] = 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1.0f, 1.0f, 0.05f, 1.0f, 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1.0f, -1.0f, 0.05f, 1.0f, 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry -1.0f, 1.0f, 0.05f, 1.0f, 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry -1.0f, -1.0f, 0.05f, 1.0f 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CaseType 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_WRITE_DEPTH, 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_WRITE_STENCIL, 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_CLEAR_COLOR, 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_CLEAR_DEPTH, 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASE_CLEAR_STENCIL 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum CaseOptions 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASEOPTION_FBO = (1 << 0), 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CASEOPTION_SCISSOR = (1 << 1) 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RasterizerDiscardCase : public TestCase 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizerDiscardCase (Context& context, const char* name, const char* description, int numPrimitives, CaseType caseType, deUint32 caseOptions, deUint32 drawMode = GL_TRIANGLES); 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~RasterizerDiscardCase (void); 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizerDiscardCase (const RasterizerDiscardCase& other); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizerDiscardCase& operator= (const RasterizerDiscardCase& other); 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void setupFramebufferObject (void); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deleteFramebufferObject (void); 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numPrimitives; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CaseType m_caseType; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_caseOptions; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_drawMode; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_fbo; 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_colorBuf; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_depthStencilBuf; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iterNdx; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random m_rnd; 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1073c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizerDiscardCase::RasterizerDiscardCase (Context& context, const char* name, const char* description, int numPrimitives, CaseType caseType, deUint32 caseOptions, deUint32 drawMode) 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, description) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numPrimitives (numPrimitives) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseType (caseType) 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseOptions (caseOptions) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_drawMode (drawMode) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_program (DE_NULL) 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_fbo (0) 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_colorBuf (0) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_depthStencilBuf (0) 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterNdx (0) 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_rnd (deStringHash(name)) 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizerDiscardCase::~RasterizerDiscardCase (void) 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizerDiscardCase::deinit(); 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic void generateVertices (std::vector<float>& dst, int numPrimitives, de::Random& rnd, deUint32 drawMode) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int numVertices; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (drawMode) 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_POINTS: numVertices = numPrimitives; break; 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_LINES: numVertices = 2*numPrimitives; break; 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_LINE_STRIP: numVertices = numPrimitives+1; break; 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_LINE_LOOP: numVertices = numPrimitives+2; break; 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLES: numVertices = 3*numPrimitives; break; 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLE_STRIP: numVertices = numPrimitives+2; break; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLE_FAN: numVertices = numPrimitives+2; break; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry numVertices = 0; 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst.resize(numVertices * 4); 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < numVertices; i++) 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[i*4 ] = rnd.getFloat(-1.0f, 1.0f); // x 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[i*4 + 1] = rnd.getFloat(-1.0f, 1.0f); // y 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[i*4 + 2] = rnd.getFloat( 0.1f, 0.9f); // z 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry dst[i*4 + 3] = 1.0f; // w 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RasterizerDiscardCase::setupFramebufferObject (void) 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = m_context.getRenderTarget().getWidth(); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = m_context.getRenderTarget().getHeight(); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create framebuffer object 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenFramebuffers (1, &m_fbo); // FBO 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenTextures (1, &m_colorBuf); // Color attachment 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenRenderbuffers (1, &m_depthStencilBuf); // Depth and stencil attachments 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create color texture 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindTexture (GL_TEXTURE_2D, m_colorBuf); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL); 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create depth and stencil buffers 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindRenderbuffer (GL_RENDERBUFFER, m_depthStencilBuf); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glRenderbufferStorage (GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height); 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Attach texture and buffers to FBO 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindFramebuffer (GL_FRAMEBUFFER, m_fbo); 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFramebufferTexture2D (GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_colorBuf, 0); 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuf); 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFramebufferRenderbuffer (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuf); 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (fboStatus == GL_FRAMEBUFFER_UNSUPPORTED) 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Framebuffer unsupported", "", __FILE__, __LINE__); 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (fboStatus != GL_FRAMEBUFFER_COMPLETE) 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("Failed to create framebuffer object", "", __FILE__, __LINE__); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RasterizerDiscardCase::deleteFramebufferObject (void) 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteTextures (1, &m_colorBuf); // Color attachment 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteRenderbuffers (1, &m_depthStencilBuf); // Depth and stencil attachments 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteFramebuffers (1, &m_fbo); // FBO 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RasterizerDiscardCase::init (void) 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* vertShaderSource = 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n" 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) in mediump vec4 a_position;\n" 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\n" 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* fragShaderSource = 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "#version 300 es\n" 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 dEQP_FragColor;\n" 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "uniform mediump vec4 u_color;\n" 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "\n" 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " mediump float depth_gradient = gl_FragCoord.z;\n" 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " mediump float bias = 0.1;\n" 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " dEQP_FragColor = vec4(u_color.xyz * (depth_gradient + bias), 1.0);\n" 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!m_program); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(vertShaderSource, fragShaderSource)); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_program->isOk()) 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *m_program; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TCU_FAIL("Failed to compile shader program"); 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // Initialize test result to pass. 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG ("Case initialization finished"); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RasterizerDiscardCase::deinit (void) 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deleteFramebufferObject(); 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_program; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = DE_NULL; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizerDiscardCase::IterateResult RasterizerDiscardCase::iterate (void) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestLog& log = m_testCtx.getLog(); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RenderTarget& renderTarget = m_context.getRenderTarget(); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 colorUnif = glGetUniformLocation(m_program->getProgram(), "u_color"); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool failColorFound = false; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool passColorFound = false; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<float> vertices; 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string header = "Case iteration " + de::toString(m_iterNdx+1) + " / " + de::toString(NUM_CASE_ITERATIONS); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Section(header, header); 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT (m_program); 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Create and bind FBO if needed 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseOptions & CASEOPTION_FBO) 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry try 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry setupFramebufferObject(); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (tcu::NotSupportedError& e) 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "ERROR: " << e.what() << "." << TestLog::EndMessage << TestLog::EndSection; 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_NOT_SUPPORTED, "Not supported"); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry catch (tcu::InternalError& e) 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "ERROR: " << e.what() << "." << TestLog::EndMessage << TestLog::EndSection; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_INTERNAL_ERROR, "Error"); 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseOptions & CASEOPTION_SCISSOR) 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnable (GL_SCISSOR_TEST); 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glScissor(0, 0, renderTarget.getWidth(), renderTarget.getHeight()); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Scissor test enabled: glScissor(0, 0, " << renderTarget.getWidth() << ", " << renderTarget.getHeight() << ")" << TestLog::EndMessage; 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glUseProgram (m_program->getProgram()); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnable (GL_DEPTH_TEST); 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDepthRangef (0.0f, 1.0f); 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDepthFunc (GL_LEQUAL); 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnable (GL_STENCIL_TEST); 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glStencilFunc (GL_NOTEQUAL, 1, 0xFF); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glStencilOp (GL_REPLACE, GL_KEEP, GL_KEEP); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearColor (PASS_COLOR_BLUE.x(), PASS_COLOR_BLUE.y(), PASS_COLOR_BLUE.z(), PASS_COLOR_BLUE.w()); 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearDepthf (1.0f); 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearStencil (0); 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Generate vertices 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnableVertexAttribArray (0); 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateVertices (vertices, m_numPrimitives, m_rnd, m_drawMode); 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glVertexAttribPointer (0, 4, GL_FLOAT, GL_FALSE, 0, &vertices[0]); 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Clear color to black for depth and stencil clear cases 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == CASE_CLEAR_DEPTH || m_caseType == CASE_CLEAR_STENCIL) 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearColor (BLACK_COLOR.x(), BLACK_COLOR.y(), BLACK_COLOR.z(), BLACK_COLOR.w()); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClear (GL_COLOR_BUFFER_BIT); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Set fail values for color, depth and stencil 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glUniform4f (colorUnif, FAIL_COLOR_RED.x(), FAIL_COLOR_RED.y(), FAIL_COLOR_RED.z(), FAIL_COLOR_RED.w()); 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearColor (FAIL_COLOR_RED.x(), FAIL_COLOR_RED.y(), FAIL_COLOR_RED.z(), FAIL_COLOR_RED.w()); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearDepthf (FAIL_DEPTH); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glClearStencil (FAIL_STENCIL); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Enable rasterizer discard 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glEnable (GL_RASTERIZER_DISCARD); 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG ("Rasterizer discard enabled"); 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Do to-be-discarded primitive draws and buffer clears 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_caseType) 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_WRITE_DEPTH: glDrawArrays(m_drawMode, 0, (int)vertices.size() / 4); break; 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_WRITE_STENCIL: glDrawArrays(m_drawMode, 0, (int)vertices.size() / 4); break; 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_CLEAR_COLOR: (m_caseOptions & CASEOPTION_FBO) ? glClearBufferfv(GL_COLOR, 0, &FAIL_COLOR_RED[0]) : glClear(GL_COLOR_BUFFER_BIT); break; 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_CLEAR_DEPTH: (m_caseOptions & CASEOPTION_FBO) ? glClearBufferfv(GL_DEPTH, 0, &FAIL_DEPTH) : glClear(GL_DEPTH_BUFFER_BIT); break; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case CASE_CLEAR_STENCIL: (m_caseOptions & CASEOPTION_FBO) ? glClearBufferiv(GL_STENCIL, 0, &FAIL_STENCIL) : glClear(GL_STENCIL_BUFFER_BIT); break; 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: DE_ASSERT(false); 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Disable rasterizer discard 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDisable (GL_RASTERIZER_DISCARD); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_CHECK_MSG ("Rasterizer discard disabled"); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == CASE_WRITE_STENCIL) 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((m_caseOptions & CASEOPTION_FBO) || m_context.getRenderTarget().getStencilBits() > 0) 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw a full-screen square that colors all pixels red if they have stencil value 1. 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glVertexAttribPointer (0, 4, GL_FLOAT, GL_FALSE, 0, &UNIT_SQUARE[0]); 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glStencilFunc (GL_EQUAL, 1, 0xFF); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDrawArrays (GL_TRIANGLE_STRIP, 0, 4); 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note If no stencil buffers are present and test is rendering to default framebuffer, test will always pass. 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_caseType == CASE_CLEAR_DEPTH || m_caseType == CASE_CLEAR_STENCIL) 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Draw pass-indicating primitives for depth and stencil clear cases 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glUniform4f (colorUnif, PASS_COLOR_BLUE.x(), PASS_COLOR_BLUE.y(), PASS_COLOR_BLUE.z(), PASS_COLOR_BLUE.w()); 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDrawArrays (m_drawMode, 0, (int)vertices.size() / 4); 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFinish (); 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDisable (GL_STENCIL_TEST); 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDisable (GL_DEPTH_TEST); 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDisable (GL_SCISSOR_TEST); 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Read and check pixel data 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface pixels(renderTarget.getWidth(), renderTarget.getHeight()); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, pixels.getAccess()); 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int width = pixels.getWidth(); 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int height = pixels.getHeight(); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < height; y++) 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < width; x++) 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pixels.getPixel(x,y).getBlue() != 0) 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry passColorFound = true; 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (pixels.getPixel(x,y).getRed() != 0) 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry failColorFound = true; 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (failColorFound) break; 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Delete FBO if created 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseOptions & CASEOPTION_FBO) 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deleteFramebufferObject(); 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Evaluate test result 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool testOk = passColorFound && !failColorFound; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!testOk) 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Image ("Result image", "Result image", pixels); 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Test result: " << (testOk ? "Passed!" : "Failed!") << TestLog::EndMessage; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!testOk) 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Primitive or buffer clear was not discarded." << TestLog::EndMessage << TestLog::EndSection; 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Primitive or buffer clear was discarded correctly." << TestLog::EndMessage << TestLog::EndSection; 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (++m_iterNdx < NUM_CASE_ITERATIONS) ? CONTINUE : STOP; 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4233c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizerDiscardTests::RasterizerDiscardTests (Context& context) 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "rasterizer_discard", "Rasterizer Discard Tests") 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizerDiscardTests::~RasterizerDiscardTests (void) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RasterizerDiscardTests::init (void) 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* basic = new tcu::TestCaseGroup(m_testCtx, "basic", "Rasterizer discard test for default framebuffer"); 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* scissor = new tcu::TestCaseGroup(m_testCtx, "scissor", "Rasterizer discard test for default framebuffer with scissor test enabled"); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* fbo = new tcu::TestCaseGroup(m_testCtx, "fbo", "Rasterizer discard test for framebuffer object"); 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(basic); 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(scissor); 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(fbo); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Default framebuffer cases 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_points", "points", 4, CASE_WRITE_DEPTH, 0, GL_POINTS)); 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_lines", "lines", 4, CASE_WRITE_DEPTH, 0, GL_LINES)); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_line_strip", "line_strip", 4, CASE_WRITE_DEPTH, 0, GL_LINE_STRIP)); 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_line_loop", "line_loop", 4, CASE_WRITE_DEPTH, 0, GL_LINE_LOOP)); 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangles", "triangles", 4, CASE_WRITE_DEPTH, 0, GL_TRIANGLES)); 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangle_strip", "triangle_strip", 4, CASE_WRITE_DEPTH, 0, GL_TRIANGLE_STRIP)); 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangle_fan", "triangle_fan", 4, CASE_WRITE_DEPTH, 0, GL_TRIANGLE_FAN)); 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_points", "points", 4, CASE_WRITE_STENCIL, 0, GL_POINTS)); 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_lines", "lines", 4, CASE_WRITE_STENCIL, 0, GL_LINES)); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_line_strip", "line_strip", 4, CASE_WRITE_STENCIL, 0, GL_LINE_STRIP)); 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_line_loop", "line_loop", 4, CASE_WRITE_STENCIL, 0, GL_LINE_LOOP)); 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangles", "triangles", 4, CASE_WRITE_STENCIL, 0, GL_TRIANGLES)); 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangle_strip", "triangle_strip", 4, CASE_WRITE_STENCIL, 0, GL_TRIANGLE_STRIP)); 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangle_fan", "triangle_fan", 4, CASE_WRITE_STENCIL, 0, GL_TRIANGLE_FAN)); 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "clear_color", "clear_color", 4, CASE_CLEAR_COLOR, 0)); 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "clear_depth", "clear_depth", 4, CASE_CLEAR_DEPTH, 0)); 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new RasterizerDiscardCase(m_context, "clear_stencil", "clear_stencil", 4, CASE_CLEAR_STENCIL, 0)); 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Default framebuffer cases with scissor test enabled 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_points", "points", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_POINTS)); 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_lines", "lines", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_LINES)); 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_line_strip", "line_strip", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_LINE_STRIP)); 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_line_loop", "line_loop", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_LINE_LOOP)); 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangles", "triangles", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_TRIANGLES)); 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangle_strip", "triangle_strip", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_TRIANGLE_STRIP)); 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangle_fan", "triangle_fan", 4, CASE_WRITE_DEPTH, CASEOPTION_SCISSOR, GL_TRIANGLE_FAN)); 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_points", "points", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_POINTS)); 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_lines", "lines", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_LINES)); 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_line_strip", "line_strip", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_LINE_STRIP)); 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_line_loop", "line_loop", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_LINE_LOOP)); 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangles", "triangles", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_TRIANGLES)); 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangle_strip", "triangle_strip", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_TRIANGLE_STRIP)); 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangle_fan", "triangle_fan", 4, CASE_WRITE_STENCIL, CASEOPTION_SCISSOR, GL_TRIANGLE_FAN)); 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "clear_color", "clear_color", 4, CASE_CLEAR_COLOR, CASEOPTION_SCISSOR)); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "clear_depth", "clear_depth", 4, CASE_CLEAR_DEPTH, CASEOPTION_SCISSOR)); 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scissor->addChild(new RasterizerDiscardCase(m_context, "clear_stencil", "clear_stencil", 4, CASE_CLEAR_STENCIL, CASEOPTION_SCISSOR)); 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // FBO cases 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_points", "points", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_POINTS)); 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_lines", "lines", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_LINES)); 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_line_strip", "line_strip", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_LINE_STRIP)); 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_line_loop", "line_loop", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_LINE_LOOP)); 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangles", "triangles", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_TRIANGLES)); 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangle_strip", "triangle_strip", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_TRIANGLE_STRIP)); 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_depth_triangle_fan", "triangle_fan", 4, CASE_WRITE_DEPTH, CASEOPTION_FBO, GL_TRIANGLE_FAN)); 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_points", "points", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_POINTS)); 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_lines", "lines", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_LINES)); 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_line_strip", "line_strip", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_LINE_STRIP)); 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_line_loop", "line_loop", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_LINE_LOOP)); 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangles", "triangles", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_TRIANGLES)); 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangle_strip", "triangle_strip", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_TRIANGLE_STRIP)); 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "write_stencil_triangle_fan", "triangle_fan", 4, CASE_WRITE_STENCIL, CASEOPTION_FBO, GL_TRIANGLE_FAN)); 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "clear_color", "clear_color", 4, CASE_CLEAR_COLOR, CASEOPTION_FBO)); 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "clear_depth", "clear_depth", 4, CASE_CLEAR_DEPTH, CASEOPTION_FBO)); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fbo->addChild(new RasterizerDiscardCase(m_context, "clear_stencil", "clear_stencil", 4, CASE_CLEAR_STENCIL, CASEOPTION_FBO)); 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles3 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 512