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 Functional rasterization tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fRasterizationTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsRasterizationTestUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVectorUtil.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuStringTemplate.hpp" 302306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry#include "tcuResultCollector.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include <vector> 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace gls::RasterizationTestUtil; 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_shaderVertexTemplate = "attribute highp vec4 a_position;\n" 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "attribute highp vec4 a_color;\n" 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "varying highp vec4 v_color;\n" 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "uniform highp float u_pointSize;\n" 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main ()\n" 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_PointSize = u_pointSize;\n" 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " v_color = a_color;\n" 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_shaderFragmentTemplate = "varying mediump vec4 v_color;\n" 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main ()\n" 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_FragColor = v_color;\n" 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum InterpolationCaseFlags 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INTERPOLATIONFLAGS_NONE = 0, 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry INTERPOLATIONFLAGS_PROJECTED = (1 << 1), 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryenum PrimitiveWideness 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVEWIDENESS_NARROW = 0, 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVEWIDENESS_WIDE, 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PRIMITIVEWIDENESS_LAST 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BaseRenderingCase : public TestCase 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BaseRenderingCase (Context& context, const char* name, const char* desc, int renderSize = 256); 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BaseRenderingCase (void); 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawPrimitives (tcu::Surface& result, const std::vector<tcu::Vec4>& vertexData, glw::GLenum primitiveType); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void drawPrimitives (tcu::Surface& result, const std::vector<tcu::Vec4>& vertexData, const std::vector<tcu::Vec4>& coloDrata, glw::GLenum primitiveType); 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_renderSize; 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_numSamples; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_subpixelBits; 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float m_pointSize; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float m_lineWidth; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_shader; 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseRenderingCase::BaseRenderingCase (Context& context, const char* name, const char* desc, int renderSize) 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (context, name, desc) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_renderSize (renderSize) 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_numSamples (-1) 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_subpixelBits (-1) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_pointSize (1.0f) 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_lineWidth (1.0f) 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_shader (DE_NULL) 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1153c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseRenderingCase::~BaseRenderingCase (void) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BaseRenderingCase::init (void) 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int width = m_context.getRenderTarget().getWidth(); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int height = m_context.getRenderTarget().getHeight(); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Requirements 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (width < m_renderSize || height < m_renderSize) 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError(std::string("Render target size must be at least ") + de::toString(m_renderSize) + "x" + de::toString(m_renderSize)); 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_lineWidth != 1.0f) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float range[2] = { 0.0f, 0.0f }; 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().getFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_lineWidth < range[0] || m_lineWidth > range[1]) 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError(std::string("Support for line width ") + de::toString(m_lineWidth) + " is required."); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "ALIASED_LINE_WIDTH_RANGE = [" << range[0] << ", " << range[1] << "]" << tcu::TestLog::EndMessage; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_pointSize != 1.0f) 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float range[2] = { 0.0f, 0.0f }; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().getFloatv(GL_ALIASED_POINT_SIZE_RANGE, range); 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_pointSize < range[0] || m_pointSize > range[1]) 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError(std::string("Support for point size ") + de::toString(m_pointSize) + " is required."); 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "ALIASED_POINT_SIZE_RANGE = [" << range[0] << ", " << range[1] << "]" << tcu::TestLog::EndMessage; 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Query info 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_numSamples = m_context.getRenderTarget().getNumSamples(); 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().getIntegerv(GL_SUBPIXEL_BITS, &m_subpixelBits); 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Sample count = " << m_numSamples << tcu::TestLog::EndMessage; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "SUBPIXEL_BITS = " << m_subpixelBits << tcu::TestLog::EndMessage; 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Gen shader 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::StringTemplate vertexSource (s_shaderVertexTemplate); 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::StringTemplate fragmentSource (s_shaderFragmentTemplate); 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::map<std::string, std::string> params; 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_shader = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(vertexSource.specialize(params)) << glu::FragmentSource(fragmentSource.specialize(params))); 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_shader->isOk()) 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("could not create shader"); 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BaseRenderingCase::deinit (void) 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_shader) 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_shader; 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_shader = DE_NULL; 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BaseRenderingCase::drawPrimitives (tcu::Surface& result, const std::vector<tcu::Vec4>& vertexData, glw::GLenum primitiveType) 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // default to color white 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<tcu::Vec4> colorData(vertexData.size(), tcu::Vec4(1.0f, 1.0f, 1.0f, 1.0f)); 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(result, vertexData, colorData, primitiveType); 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BaseRenderingCase::drawPrimitives (tcu::Surface& result, const std::vector<tcu::Vec4>& vertexData, const std::vector<tcu::Vec4>& colorData, glw::GLenum primitiveType) 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLint positionLoc = gl.getAttribLocation(m_shader->getProgram(), "a_position"); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLint colorLoc = gl.getAttribLocation(m_shader->getProgram(), "a_color"); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLint pointSizeLoc = gl.getUniformLocation(m_shader->getProgram(), "u_pointSize"); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clearColor (0, 0, 0, 1); 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.clear (GL_COLOR_BUFFER_BIT); 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.viewport (0, 0, m_renderSize, m_renderSize); 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.useProgram (m_shader->getProgram()); 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray (positionLoc); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer (positionLoc, 4, GL_FLOAT, GL_FALSE, 0, &vertexData[0]); 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableVertexAttribArray (colorLoc); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.vertexAttribPointer (colorLoc, 4, GL_FLOAT, GL_FALSE, 0, &colorData[0]); 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.uniform1f (pointSizeLoc, m_pointSize); 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.lineWidth (m_lineWidth); 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.drawArrays (primitiveType, 0, (glw::GLsizei)vertexData.size()); 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.disableVertexAttribArray (colorLoc); 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.disableVertexAttribArray (positionLoc); 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.useProgram (0); 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.finish (); 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR (gl.getError(), "draw primitives"); 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, result.getAccess()); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BaseTriangleCase : public BaseRenderingCase 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BaseTriangleCase (Context& context, const char* name, const char* desc, glw::GLenum primitiveDrawType); 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BaseTriangleCase (void); 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles) = DE_NULL; 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_iterationCount; 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum m_primitiveDrawType; 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_allIterationsPassed; 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2333c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseTriangleCase::BaseTriangleCase (Context& context, const char* name, const char* desc, glw::GLenum primitiveDrawType) 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseRenderingCase (context, name, desc) 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (3) 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitiveDrawType (primitiveDrawType) 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_allIterationsPassed (true) 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2423c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseTriangleCase::~BaseTriangleCase (void) 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseTriangleCase::IterateResult BaseTriangleCase::iterate (void) 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDescription = "Test iteration " + de::toString(m_iteration+1) + " / " + de::toString(m_iterationCount); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (m_testCtx.getLog(), iterationDescription, iterationDescription); 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage (m_renderSize, m_renderSize); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<TriangleSceneSpec::SceneTriangle> triangles; 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateTriangles(m_iteration, drawBuffer, triangles); 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, m_primitiveDrawType); 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool compareOk; 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizationArguments args; 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec scene; 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.numSamples = m_numSamples; 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.subpixelBits = m_subpixelBits; 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.redBits = m_context.getRenderTarget().getPixelFormat().redBits; 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.greenBits = m_context.getRenderTarget().getPixelFormat().greenBits; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.blueBits = m_context.getRenderTarget().getPixelFormat().blueBits; 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.triangles.swap(triangles); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compareOk = verifyTriangleGroupRasterization(resultImage, scene, args, m_testCtx.getLog()); 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!compareOk) 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allIterationsPassed = false; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // result 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration == m_iterationCount) 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_allIterationsPassed) 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect rasterization"); 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BaseLineCase : public BaseRenderingCase 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BaseLineCase (Context& context, const char* name, const char* desc, glw::GLenum primitiveDrawType, PrimitiveWideness wideness); 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BaseLineCase (void); 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines) = DE_NULL; 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_iterationCount; 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum m_primitiveDrawType; 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PrimitiveWideness m_primitiveWideness; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_allIterationsPassed; 308f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry bool m_multisampleRelaxationRequired; 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float s_wideSize; 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst float BaseLineCase::s_wideSize = 5.0f; 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3153c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseLineCase::BaseLineCase (Context& context, const char* name, const char* desc, glw::GLenum primitiveDrawType, PrimitiveWideness wideness) 316f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry : BaseRenderingCase (context, name, desc) 317f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_iteration (0) 318f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_iterationCount (3) 319f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_primitiveDrawType (primitiveDrawType) 320f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_primitiveWideness (wideness) 321f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_allIterationsPassed (true) 322f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry , m_multisampleRelaxationRequired (false) 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(m_primitiveWideness < PRIMITIVEWIDENESS_LAST); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_lineWidth = (m_primitiveWideness == PRIMITIVEWIDENESS_WIDE) ? (s_wideSize) : (1.0f); 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3283c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseLineCase::~BaseLineCase (void) 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBaseLineCase::IterateResult BaseLineCase::iterate (void) 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDescription = "Test iteration " + de::toString(m_iteration+1) + " / " + de::toString(m_iterationCount); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (m_testCtx.getLog(), iterationDescription, iterationDescription); 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage (m_renderSize, m_renderSize); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<LineSceneSpec::SceneLine> lines; 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // last iteration, max out size 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_primitiveWideness == PRIMITIVEWIDENESS_WIDE && 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iteration+1 == m_iterationCount) 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float range[2] = { 0.0f, 0.0f }; 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().getFloatv(GL_ALIASED_LINE_WIDTH_RANGE, range); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_lineWidth = range[1]; 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // gen data 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateLines(m_iteration, drawBuffer, lines); 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, m_primitiveDrawType); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool compareOk; 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizationArguments args; 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineSceneSpec scene; 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.numSamples = m_numSamples; 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.subpixelBits = m_subpixelBits; 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.redBits = m_context.getRenderTarget().getPixelFormat().redBits; 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.greenBits = m_context.getRenderTarget().getPixelFormat().greenBits; 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.blueBits = m_context.getRenderTarget().getPixelFormat().blueBits; 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.lines.swap(lines); 3693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.lineWidth = m_lineWidth; 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compareOk = verifyLineGroupRasterization(resultImage, scene, args, m_testCtx.getLog()); 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry // multisampled wide lines might not be supported 374f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry if (scene.lineWidth != 1.0f && m_numSamples > 1 && !compareOk) 375f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry { 376f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_multisampleRelaxationRequired = true; 377f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry compareOk = true; 378f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry } 379f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!compareOk) 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allIterationsPassed = false; 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // result 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration == m_iterationCount) 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 387f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry if (m_allIterationsPassed && m_multisampleRelaxationRequired) 388f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Rasterization of multisampled wide lines failed"); 389f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry else if (m_allIterationsPassed) 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect rasterization"); 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass PointCase : public BaseRenderingCase 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PointCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness); 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~PointCase (void); 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generatePoints (int iteration, std::vector<tcu::Vec4>& outData, std::vector<PointSceneSpec::ScenePoint>& outPoints); 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_iterationCount; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const PrimitiveWideness m_primitiveWideness; 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_allIterationsPassed; 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const float s_wideSize; 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryconst float PointCase::s_wideSize = 10.0f; 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4203c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPointCase::PointCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness) 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseRenderingCase (context, name, desc) 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (3) 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitiveWideness (wideness) 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_allIterationsPassed (true) 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pointSize = (m_primitiveWideness == PRIMITIVEWIDENESS_WIDE) ? (s_wideSize) : (1.0f); 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4303c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPointCase::~PointCase (void) 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4343c827367444ee418f129b2c238299f49d3264554Jarkko PoyryPointCase::IterateResult PointCase::iterate (void) 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDescription = "Test iteration " + de::toString(m_iteration+1) + " / " + de::toString(m_iterationCount); 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (m_testCtx.getLog(), iterationDescription, iterationDescription); 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage (m_renderSize, m_renderSize); 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<PointSceneSpec::ScenePoint> points; 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // last iteration, max out size 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_primitiveWideness == PRIMITIVEWIDENESS_WIDE && 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_iteration+1 == m_iterationCount) 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry float range[2] = { 0.0f, 0.0f }; 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().getFloatv(GL_ALIASED_POINT_SIZE_RANGE, range); 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_pointSize = range[1]; 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // gen data 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generatePoints(m_iteration, drawBuffer, points); 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, GL_POINTS); 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool compareOk; 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizationArguments args; 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry PointSceneSpec scene; 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.numSamples = m_numSamples; 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.subpixelBits = m_subpixelBits; 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.redBits = m_context.getRenderTarget().getPixelFormat().redBits; 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.greenBits = m_context.getRenderTarget().getPixelFormat().greenBits; 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.blueBits = m_context.getRenderTarget().getPixelFormat().blueBits; 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.points.swap(points); 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry compareOk = verifyPointGroupRasterization(resultImage, scene, args, m_testCtx.getLog()); 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!compareOk) 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allIterationsPassed = false; 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // result 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration == m_iterationCount) 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_allIterationsPassed) 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect rasterization"); 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid PointCase::generatePoints (int iteration, std::vector<tcu::Vec4>& outData, std::vector<PointSceneSpec::ScenePoint>& outPoints) 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(6); 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( 0.2f, 0.8f, 0.0f, 1.0f); 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.5f, 0.2f, 0.0f, 1.0f); 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.5f, 0.3f, 0.0f, 1.0f); 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.5f, 0.2f, 0.0f, 1.0f); 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4(-0.2f, -0.4f, 0.0f, 1.0f); 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4(-0.4f, 0.2f, 0.0f, 1.0f); 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.128f, 0.0f, 1.0f); 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.9f, 0.0f, 1.0f); 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( 0.4f, 1.2f, 0.0f, 1.0f); 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.3f, -0.9f, 0.0f, 1.0f); 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( -0.4f, -0.1f, 0.0f, 1.0f); 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.11f, 0.2f, 0.0f, 1.0f); 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.7f, 0.0f, 1.0f); 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( -0.4f, 0.4f, 0.0f, 1.0f); 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outPoints.resize(outData.size()); 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pointNdx = 0; pointNdx < (int)outPoints.size(); ++pointNdx) 5293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outPoints[pointNdx].position = outData[pointNdx]; 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outPoints[pointNdx].pointSize = m_pointSize; 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering " << outPoints.size() << " point(s): (point size = " << m_pointSize << ")" << tcu::TestLog::EndMessage; 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int pointNdx = 0; pointNdx < (int)outPoints.size(); ++pointNdx) 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Point " << (pointNdx+1) << ":\t" << outPoints[pointNdx].position << tcu::TestLog::EndMessage; 5383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TrianglesCase : public BaseTriangleCase 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TrianglesCase (Context& context, const char* name, const char* desc); 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TrianglesCase (void); 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles); 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTrianglesCase::TrianglesCase (Context& context, const char* name, const char* desc) 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseTriangleCase(context, name, desc, GL_TRIANGLES) 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5543c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTrianglesCase::~TrianglesCase (void) 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TrianglesCase::generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles) 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(6); 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( 0.2f, 0.8f, 0.0f, 1.0f); 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.5f, 0.2f, 0.0f, 1.0f); 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.5f, 0.3f, 0.0f, 1.0f); 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.5f, 0.2f, 0.0f, 1.0f); 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4(-1.5f, -0.4f, 0.0f, 1.0f); 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4(-0.4f, 0.2f, 0.0f, 1.0f); 5733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.128f, 0.0f, 1.0f); 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.9f, 0.0f, 1.0f); 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( 0.4f, 1.2f, 0.0f, 1.0f); 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 1.1f, -0.9f, 0.0f, 1.0f); 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( -1.1f, -0.1f, 0.0f, 1.0f); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.11f, 0.2f, 0.0f, 1.0f); 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.7f, 0.0f, 1.0f); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( -0.4f, 0.4f, 0.0f, 1.0f); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.resize(2); 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[0] = outData[0]; outTriangles[0].sharedEdge[0] = false; 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[1] = outData[1]; outTriangles[0].sharedEdge[1] = false; 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[2] = outData[2]; outTriangles[0].sharedEdge[2] = false; 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[0] = outData[3]; outTriangles[1].sharedEdge[0] = false; 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[1] = outData[4]; outTriangles[1].sharedEdge[1] = false; 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[2] = outData[5]; outTriangles[1].sharedEdge[2] = false; 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering " << outTriangles.size() << " triangle(s):" << tcu::TestLog::EndMessage; 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int triangleNdx = 0; triangleNdx < (int)outTriangles.size(); ++triangleNdx) 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Triangle " << (triangleNdx+1) << ":" 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\t" << outTriangles[triangleNdx].positions[0] 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\t" << outTriangles[triangleNdx].positions[1] 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\t" << outTriangles[triangleNdx].positions[2] 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleStripCase : public BaseTriangleCase 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleStripCase (Context& context, const char* name, const char* desc); 6213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles); 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6253c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleStripCase::TriangleStripCase (Context& context, const char* name, const char* desc) 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseTriangleCase(context, name, desc, GL_TRIANGLE_STRIP) 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleStripCase::generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles) 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(5); 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.504f, 0.8f, 0.0f, 1.0f); 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.2f, -0.2f, 0.0f, 1.0f); 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4(-0.2f, 0.199f, 0.0f, 1.0f); 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.5f, 0.201f, 0.0f, 1.0f); 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 1.5f, 0.4f, 0.0f, 1.0f); 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.129f, 0.0f, 1.0f); 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, -0.31f, 0.0f, 1.0f); 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.9f, 0.0f, 1.0f); 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 1.1f, -0.9f, 0.0f, 1.0f); 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4(-0.87f, -0.1f, 0.0f, 1.0f); 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.11f, 0.19f, 0.0f, 1.0f); 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.7f, 0.0f, 1.0f); 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.resize(3); 6633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[0] = outData[0]; outTriangles[0].sharedEdge[0] = false; 6643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[1] = outData[1]; outTriangles[0].sharedEdge[1] = true; 6653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[2] = outData[2]; outTriangles[0].sharedEdge[2] = false; 6663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[0] = outData[2]; outTriangles[1].sharedEdge[0] = true; 6683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[1] = outData[1]; outTriangles[1].sharedEdge[1] = false; 6693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[2] = outData[3]; outTriangles[1].sharedEdge[2] = true; 6703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[2].positions[0] = outData[2]; outTriangles[2].sharedEdge[0] = true; 6723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[2].positions[1] = outData[3]; outTriangles[2].sharedEdge[1] = false; 6733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[2].positions[2] = outData[4]; outTriangles[2].sharedEdge[2] = false; 6743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 6763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering triangle strip, " << outData.size() << " vertices." << tcu::TestLog::EndMessage; 6773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outData.size(); ++vtxNdx) 6783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 6803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 6813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\t" << outData[vtxNdx] 6823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 6833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleFanCase : public BaseTriangleCase 6873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 6893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleFanCase (Context& context, const char* name, const char* desc); 6903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles); 6923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 6933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6943c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleFanCase::TriangleFanCase (Context& context, const char* name, const char* desc) 6953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseTriangleCase(context, name, desc, GL_TRIANGLE_FAN) 6963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6993c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleFanCase::generateTriangles (int iteration, std::vector<tcu::Vec4>& outData, std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles) 7003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(5); 7023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 7043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 7063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 7073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( 0.01f, 0.0f, 0.0f, 1.0f); 7083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.5f, 0.2f, 0.0f, 1.0f); 7093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.46f, 0.3f, 0.0f, 1.0f); 7103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.5f, 0.2f, 0.0f, 1.0f); 7113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4(-1.5f, -0.4f, 0.0f, 1.0f); 7123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 7133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 7153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.128f, 0.0f, 1.0f); 7163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 7173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 7183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 7193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.9f, 0.0f, 1.0f); 7203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 7213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 7233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 7243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 1.1f, -0.9f, 0.0f, 1.0f); 7253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.7f, -0.1f, 0.0f, 1.0f); 7263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 7273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.7f, 0.0f, 1.0f); 7283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 7293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.resize(3); 7323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[0] = outData[0]; outTriangles[0].sharedEdge[0] = false; 7333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[1] = outData[1]; outTriangles[0].sharedEdge[1] = false; 7343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[0].positions[2] = outData[2]; outTriangles[0].sharedEdge[2] = true; 7353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[0] = outData[0]; outTriangles[1].sharedEdge[0] = true; 7373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[1] = outData[2]; outTriangles[1].sharedEdge[1] = false; 7383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[1].positions[2] = outData[3]; outTriangles[1].sharedEdge[2] = true; 7393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[2].positions[0] = outData[0]; outTriangles[2].sharedEdge[0] = true; 7413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[2].positions[1] = outData[3]; outTriangles[2].sharedEdge[1] = false; 7423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles[2].positions[2] = outData[4]; outTriangles[2].sharedEdge[2] = false; 7433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 7453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering triangle fan, " << outData.size() << " vertices." << tcu::TestLog::EndMessage; 7463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outData.size(); ++vtxNdx) 7473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 7493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 7503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\t" << outData[vtxNdx] 7513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 7523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 7533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7553c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LinesCase : public BaseLineCase 7563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7573c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 7583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LinesCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness); 7593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines); 7613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 7623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7633c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLinesCase::LinesCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness) 7643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseLineCase(context, name, desc, GL_LINES, wideness) 7653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 7673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7683c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LinesCase::generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines) 7693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 7703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(6); 7713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 7733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 7743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 7753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 7763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( 0.01f, 0.0f, 0.0f, 1.0f); 7773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.5f, 0.2f, 0.0f, 1.0f); 7783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.46f, 0.3f, 0.0f, 1.0f); 7793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.3f, 0.2f, 0.0f, 1.0f); 7803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4(-1.5f, -0.4f, 0.0f, 1.0f); 7813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( 0.1f, 0.5f, 0.0f, 1.0f); 7823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 7833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 7853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.128f, 0.0f, 1.0f); 7863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 7873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 7883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 7893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.9f, 0.0f, 1.0f); 7903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( 0.18f, -0.2f, 0.0f, 1.0f); 7913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 7923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 7933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 7943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 7953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 1.1f, -0.9f, 0.0f, 1.0f); 7963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.7f, -0.1f, 0.0f, 1.0f); 7973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 7983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4( 0.88f, 0.7f, 0.0f, 1.0f); 7993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4( 0.8f, -0.7f, 0.0f, 1.0f); 8003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 8013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines.resize(3); 8043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[0].positions[0] = outData[0]; 8053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[0].positions[1] = outData[1]; 8063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[1].positions[0] = outData[2]; 8073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[1].positions[1] = outData[3]; 8083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[2].positions[0] = outData[4]; 8093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[2].positions[1] = outData[5]; 8103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 8123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering " << outLines.size() << " lines(s): (width = " << m_lineWidth << ")" << tcu::TestLog::EndMessage; 8133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int lineNdx = 0; lineNdx < (int)outLines.size(); ++lineNdx) 8143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 8163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 8173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Line " << (lineNdx+1) << ":" 8183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\t" << outLines[lineNdx].positions[0] 8193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\n\t" << outLines[lineNdx].positions[1] 8203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 8213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8243c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LineStripCase : public BaseLineCase 8253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8263c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineStripCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness); 8283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines); 8303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineStripCase::LineStripCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness) 8333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseLineCase(context, name, desc, GL_LINE_STRIP, wideness) 8343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineStripCase::generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines) 8383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(4); 8403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 8423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 8443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 8453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( 0.01f, 0.0f, 0.0f, 1.0f); 8463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.5f, 0.2f, 0.0f, 1.0f); 8473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.46f, 0.3f, 0.0f, 1.0f); 8483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.5f, 0.2f, 0.0f, 1.0f); 8493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 8503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 8523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.128f, 0.0f, 1.0f); 8533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 8543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 8553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 8563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 8573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 8593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 8603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 1.1f, -0.9f, 0.0f, 1.0f); 8613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.7f, -0.1f, 0.0f, 1.0f); 8623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 8633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 8643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines.resize(3); 8673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[0].positions[0] = outData[0]; 8683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[0].positions[1] = outData[1]; 8693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[1].positions[0] = outData[1]; 8703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[1].positions[1] = outData[2]; 8713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[2].positions[0] = outData[2]; 8723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[2].positions[1] = outData[3]; 8733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 8753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering line strip, width = " << m_lineWidth << ", " << outData.size() << " vertices." << tcu::TestLog::EndMessage; 8763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outData.size(); ++vtxNdx) 8773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 8783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 8793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 8803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\t" << outData[vtxNdx] 8813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 8823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 8833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8853c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LineLoopCase : public BaseLineCase 8863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8873c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 8883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineLoopCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness); 8893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines); 8913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 8923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineLoopCase::LineLoopCase (Context& context, const char* name, const char* desc, PrimitiveWideness wideness) 8943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseLineCase(context, name, desc, GL_LINE_LOOP, wideness) 8953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 8963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 8973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 8983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineLoopCase::generateLines (int iteration, std::vector<tcu::Vec4>& outData, std::vector<LineSceneSpec::SceneLine>& outLines) 8993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(4); 9013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (iteration) 9033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 0: 9053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // \note: these values are chosen arbitrarily 9063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( 0.01f, 0.0f, 0.0f, 1.0f); 9073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 0.5f, 0.2f, 0.0f, 1.0f); 9083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.46f, 0.3f, 0.0f, 1.0f); 9093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(-0.5f, 0.2f, 0.0f, 1.0f); 9103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 9113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 1: 9133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(-0.499f, 0.128f, 0.0f, 1.0f); 9143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(-0.501f, -0.3f, 0.0f, 1.0f); 9153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.11f, -0.2f, 0.0f, 1.0f); 9163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 9173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 9183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case 2: 9203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4( -0.9f, -0.3f, 0.0f, 1.0f); 9213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4( 1.1f, -0.9f, 0.0f, 1.0f); 9223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4( 0.7f, -0.1f, 0.0f, 1.0f); 9233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4( 0.11f, 0.2f, 0.0f, 1.0f); 9243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 9253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines.resize(4); 9283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[0].positions[0] = outData[0]; 9293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[0].positions[1] = outData[1]; 9303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[1].positions[0] = outData[1]; 9313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[1].positions[1] = outData[2]; 9323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[2].positions[0] = outData[2]; 9333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[2].positions[1] = outData[3]; 9343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[3].positions[0] = outData[3]; 9353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines[3].positions[1] = outData[0]; 9363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 9383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Rendering line loop, width = " << m_lineWidth << ", " << outData.size() << " vertices." << tcu::TestLog::EndMessage; 9393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outData.size(); ++vtxNdx) 9403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() 9423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Message 9433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "\t" << outData[vtxNdx] 9443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 9453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 9463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9483c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass FillRuleCase : public BaseRenderingCase 9493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9503c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 9513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum FillRuleCaseType 9523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 9533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILLRULECASE_BASIC = 0, 9543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILLRULECASE_REVERSED, 9553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILLRULECASE_CLIPPED_FULL, 9563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILLRULECASE_CLIPPED_PARTIAL, 9573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILLRULECASE_PROJECTED, 9583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FILLRULECASE_LAST 9603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 9613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FillRuleCase (Context& ctx, const char* name, const char* desc, FillRuleCaseType type); 9633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~FillRuleCase (void); 9643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 9653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9663c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 9673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getRenderSize (FillRuleCase::FillRuleCaseType type) const; 9683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int getNumIterations (FillRuleCase::FillRuleCaseType type) const; 9693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateTriangles (int iteration, std::vector<tcu::Vec4>& outData) const; 9703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const FillRuleCaseType m_caseType; 9723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 9733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_iterationCount; 9743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_allIterationsPassed; 9753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 9773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9783c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFillRuleCase::FillRuleCase (Context& ctx, const char* name, const char* desc, FillRuleCaseType type) 9793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseRenderingCase (ctx, name, desc, getRenderSize(type)) 9803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_caseType (type) 9813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 9823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (getNumIterations(type)) 9833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_allIterationsPassed (true) 9843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(type < FILLRULECASE_LAST); 9863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9883c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFillRuleCase::~FillRuleCase (void) 9893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 9913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 9923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 9933c827367444ee418f129b2c238299f49d3264554Jarkko PoyryFillRuleCase::IterateResult FillRuleCase::iterate (void) 9943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 9953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDescription = "Test iteration " + de::toString(m_iteration+1) + " / " + de::toString(m_iterationCount); 9963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (m_testCtx.getLog(), iterationDescription, iterationDescription); 9973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int thresholdRed = 1 << (8 - m_context.getRenderTarget().getPixelFormat().redBits); 9983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int thresholdGreen = 1 << (8 - m_context.getRenderTarget().getPixelFormat().greenBits); 9993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int thresholdBlue = 1 << (8 - m_context.getRenderTarget().getPixelFormat().blueBits); 10003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage (m_renderSize, m_renderSize); 10013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 10023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool imageShown = false; 10033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateTriangles(m_iteration, drawBuffer); 10053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 10073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 10093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::vector<tcu::Vec4> colorBuffer (drawBuffer.size(), tcu::Vec4(0.5f, 0.5f, 0.5f, 1.0f)); 10103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Drawing gray triangles with shared edges.\nEnabling additive blending to detect overlapping fragments." << tcu::TestLog::EndMessage; 10123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enable(GL_BLEND); 10143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.blendEquation(GL_FUNC_ADD); 10153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.blendFunc(GL_ONE, GL_ONE); 10163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, colorBuffer, GL_TRIANGLES); 10173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // verify no overdraw 10203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA triangleColor = tcu::RGBA(127, 127, 127, 255); 10223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool overdraw = false; 10233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Verifying result." << tcu::TestLog::EndMessage; 10253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < resultImage.getHeight(); ++y) 10273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < resultImage.getWidth(); ++x) 10283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA color = resultImage.getPixel(x, y); 10303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // color values are greater than triangle color? Allow lower values for multisampled edges and background. 10323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if ((color.getRed() - triangleColor.getRed()) > thresholdRed || 10333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (color.getGreen() - triangleColor.getGreen()) > thresholdGreen || 10343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry (color.getBlue() - triangleColor.getBlue()) > thresholdBlue) 10353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry overdraw = true; 10363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // results 10393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!overdraw) 10403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "No overlapping fragments detected." << tcu::TestLog::EndMessage; 10413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Overlapping fragments detected, image is not valid." << tcu::TestLog::EndMessage; 10443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::ImageSet("Result of rendering", "Result of rendering") 10453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Image("Result", "Result", resultImage) 10463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndImageSet; 10473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry imageShown = true; 10493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allIterationsPassed = false; 10503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // verify no missing fragments in the full viewport case 10543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == FILLRULECASE_CLIPPED_FULL) 10553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool missingFragments = false; 10573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Searching missing fragments." << tcu::TestLog::EndMessage; 10593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < resultImage.getHeight(); ++y) 10613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < resultImage.getWidth(); ++x) 10623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA color = resultImage.getPixel(x, y); 10643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // black? (background) 10663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (color.getRed() <= thresholdRed || 10673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry color.getGreen() <= thresholdGreen || 10683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry color.getBlue() <= thresholdBlue) 10693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry missingFragments = true; 10703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // results 10733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!missingFragments) 10743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "No missing fragments detected." << tcu::TestLog::EndMessage; 10753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Missing fragments detected, image is not valid." << tcu::TestLog::EndMessage; 10783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!imageShown) 10803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::ImageSet("Result of rendering", "Result of rendering") 10823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::Image("Result", "Result", resultImage) 10833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndImageSet; 10843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allIterationsPassed = false; 10873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 10893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // result 10913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration == m_iterationCount) 10923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 10933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_allIterationsPassed) 10943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 10953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 10963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Found invalid pixels"); 10973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 10983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 10993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 11013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 11023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint FillRuleCase::getRenderSize (FillRuleCase::FillRuleCaseType type) const 11053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (type == FILLRULECASE_CLIPPED_FULL || type == FILLRULECASE_CLIPPED_PARTIAL) 11073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return 64; 11083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 11093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return 256; 11103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryint FillRuleCase::getNumIterations (FillRuleCase::FillRuleCaseType type) const 11133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (type == FILLRULECASE_CLIPPED_FULL || type == FILLRULECASE_CLIPPED_PARTIAL) 11153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return 15; 11163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 11173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return 2; 11183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 11193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid FillRuleCase::generateTriangles (int iteration, std::vector<tcu::Vec4>& outData) const 11213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 11223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_caseType) 11233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case FILLRULECASE_BASIC: 11253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case FILLRULECASE_REVERSED: 11263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case FILLRULECASE_PROJECTED: 11273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numRows = 4; 11293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numColumns = 4; 11303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float quadSide = 0.15f; 11313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd (0xabcd); 11323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(6 * numRows * numColumns); 11343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int col = 0; col < numColumns; ++col) 11363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int row = 0; row < numRows; ++row) 11373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 center = tcu::Vec2((row + 0.5f) / numRows * 2.0f - 1.0f, (col + 0.5f) / numColumns * 2.0f - 1.0f); 11393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float rotation = (iteration * numColumns * numRows + col * numRows + row) / (float)(m_iterationCount * numColumns * numRows) * DE_PI / 2.0f; 11403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 sideH = quadSide * tcu::Vec2(deFloatCos(rotation), deFloatSin(rotation)); 11413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 sideV = tcu::Vec2(sideH.y(), -sideH.x()); 11423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 quad[4] = 11433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center + sideH + sideV, 11453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center + sideH - sideV, 11463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center - sideH - sideV, 11473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center - sideH + sideV, 11483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 11493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_caseType == FILLRULECASE_BASIC) 11513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 0] = tcu::Vec4(quad[0].x(), quad[0].y(), 0.0f, 1.0f); 11533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 1] = tcu::Vec4(quad[1].x(), quad[1].y(), 0.0f, 1.0f); 11543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 2] = tcu::Vec4(quad[2].x(), quad[2].y(), 0.0f, 1.0f); 11553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 3] = tcu::Vec4(quad[2].x(), quad[2].y(), 0.0f, 1.0f); 11563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 4] = tcu::Vec4(quad[0].x(), quad[0].y(), 0.0f, 1.0f); 11573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 5] = tcu::Vec4(quad[3].x(), quad[3].y(), 0.0f, 1.0f); 11583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_caseType == FILLRULECASE_REVERSED) 11603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 0] = tcu::Vec4(quad[0].x(), quad[0].y(), 0.0f, 1.0f); 11623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 1] = tcu::Vec4(quad[1].x(), quad[1].y(), 0.0f, 1.0f); 11633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 2] = tcu::Vec4(quad[2].x(), quad[2].y(), 0.0f, 1.0f); 11643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 3] = tcu::Vec4(quad[0].x(), quad[0].y(), 0.0f, 1.0f); 11653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 4] = tcu::Vec4(quad[2].x(), quad[2].y(), 0.0f, 1.0f); 11663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 5] = tcu::Vec4(quad[3].x(), quad[3].y(), 0.0f, 1.0f); 11673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_caseType == FILLRULECASE_PROJECTED) 11693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w0 = rnd.getFloat(0.1f, 4.0f); 11713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w1 = rnd.getFloat(0.1f, 4.0f); 11723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w2 = rnd.getFloat(0.1f, 4.0f); 11733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w3 = rnd.getFloat(0.1f, 4.0f); 11743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 0] = tcu::Vec4(quad[0].x() * w0, quad[0].y() * w0, 0.0f, w0); 11763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 1] = tcu::Vec4(quad[1].x() * w1, quad[1].y() * w1, 0.0f, w1); 11773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 2] = tcu::Vec4(quad[2].x() * w2, quad[2].y() * w2, 0.0f, w2); 11783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 3] = tcu::Vec4(quad[2].x() * w2, quad[2].y() * w2, 0.0f, w2); 11793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 4] = tcu::Vec4(quad[0].x() * w0, quad[0].y() * w0, 0.0f, w0); 11803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[6 * (col * numRows + row) + 5] = tcu::Vec4(quad[3].x() * w3, quad[3].y() * w3, 0.0f, w3); 11813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 11833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 11843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 11873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 11883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 11893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case FILLRULECASE_CLIPPED_PARTIAL: 11903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case FILLRULECASE_CLIPPED_FULL: 11913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float quadSide = (m_caseType == FILLRULECASE_CLIPPED_PARTIAL) ? (1.0f) : (2.0f); 11933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 center = (m_caseType == FILLRULECASE_CLIPPED_PARTIAL) ? (tcu::Vec2(0.5f, 0.5f)) : (tcu::Vec2(0.0f, 0.0f)); 11943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float rotation = (iteration) / (float)(m_iterationCount - 1) * DE_PI / 2.0f; 11953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 sideH = quadSide * tcu::Vec2(deFloatCos(rotation), deFloatSin(rotation)); 11963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 sideV = tcu::Vec2(sideH.y(), -sideH.x()); 11973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 quad[4] = 11983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 11993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center + sideH + sideV, 12003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center + sideH - sideV, 12013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center - sideH - sideV, 12023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry center - sideH + sideV, 12033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 12043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(6); 12063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[0] = tcu::Vec4(quad[0].x(), quad[0].y(), 0.0f, 1.0f); 12073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[1] = tcu::Vec4(quad[1].x(), quad[1].y(), 0.0f, 1.0f); 12083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[2] = tcu::Vec4(quad[2].x(), quad[2].y(), 0.0f, 1.0f); 12093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[3] = tcu::Vec4(quad[2].x(), quad[2].y(), 0.0f, 1.0f); 12103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[4] = tcu::Vec4(quad[0].x(), quad[0].y(), 0.0f, 1.0f); 12113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[5] = tcu::Vec4(quad[3].x(), quad[3].y(), 0.0f, 1.0f); 12123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 12133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 12163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(DE_FALSE); 12173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12203c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass CullingTest : public BaseRenderingCase 12213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12223c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 12233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry CullingTest (Context& ctx, const char* name, const char* desc, glw::GLenum cullMode, glw::GLenum primitive, glw::GLenum faceOrder); 12243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~CullingTest (void); 12253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 12263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12273c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 12283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateVertices (std::vector<tcu::Vec4>& outData) const; 12293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void extractTriangles (std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles, const std::vector<tcu::Vec4>& vertices) const; 12303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool triangleOrder (const tcu::Vec4& v0, const tcu::Vec4& v1, const tcu::Vec4& v2) const; 12313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum m_cullMode; 12333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum m_primitive; 12343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum m_faceOrder; 12353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 12363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12373c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCullingTest::CullingTest (Context& ctx, const char* name, const char* desc, glw::GLenum cullMode, glw::GLenum primitive, glw::GLenum faceOrder) 12383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseRenderingCase (ctx, name, desc) 12393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_cullMode (cullMode) 12403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitive (primitive) 12413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_faceOrder (faceOrder) 12423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12453c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCullingTest::~CullingTest (void) 12463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12493c827367444ee418f129b2c238299f49d3264554Jarkko PoyryCullingTest::IterateResult CullingTest::iterate (void) 12503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage(m_renderSize, m_renderSize); 12523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 12533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<TriangleSceneSpec::SceneTriangle> triangles; 12543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generate scene 12563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateVertices(drawBuffer); 12573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry extractTriangles(triangles, drawBuffer); 12583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 12603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 12623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enable(GL_CULL_FACE); 12643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.cullFace(m_cullMode); 12653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.frontFace(m_faceOrder); 12663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Setting front face to " << glu::getWindingName(m_faceOrder) << tcu::TestLog::EndMessage; 12683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Setting cull face to " << glu::getFaceName(m_cullMode) << tcu::TestLog::EndMessage; 12693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Drawing test pattern (" << glu::getPrimitiveTypeName(m_primitive) << ")" << tcu::TestLog::EndMessage; 12703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, m_primitive); 12723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 12753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 12763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizationArguments args; 12773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec scene; 12783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.numSamples = m_numSamples; 12803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.subpixelBits = m_subpixelBits; 12813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.redBits = m_context.getRenderTarget().getPixelFormat().redBits; 12823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.greenBits = m_context.getRenderTarget().getPixelFormat().greenBits; 12833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.blueBits = m_context.getRenderTarget().getPixelFormat().blueBits; 12843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.triangles.swap(triangles); 12863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (verifyTriangleGroupRasterization(resultImage, scene, args, m_testCtx.getLog(), VERIFICATIONMODE_WEAK)) 12883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 12893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 12903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect rendering"); 12913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 12923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 12943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 12953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 12963c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CullingTest::generateVertices (std::vector<tcu::Vec4>& outData) const 12973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 12983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(543210); 12993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData.resize(6); 13013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outData.size(); ++vtxNdx) 13023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[vtxNdx].x() = rnd.getFloat(-0.9f, 0.9f); 13043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[vtxNdx].y() = rnd.getFloat(-0.9f, 0.9f); 13053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[vtxNdx].z() = 0.0f; 13063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outData[vtxNdx].w() = 1.0f; 13073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13103c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid CullingTest::extractTriangles (std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles, const std::vector<tcu::Vec4>& vertices) const 13113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool cullDirection = (m_cullMode == GL_FRONT) ^ (m_faceOrder == GL_CCW); 13133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // No triangles 13153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_cullMode == GL_FRONT_AND_BACK) 13163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 13173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_primitive) 13193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLES: 13213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size() - 2; vtxNdx += 3) 13233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v0 = vertices[vtxNdx + 0]; 13253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v1 = vertices[vtxNdx + 1]; 13263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v2 = vertices[vtxNdx + 2]; 13273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (triangleOrder(v0, v1, v2) != cullDirection) 13293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec::SceneTriangle tri; 13313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[0] = v0; tri.sharedEdge[0] = false; 13323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[1] = v1; tri.sharedEdge[1] = false; 13333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[2] = v2; tri.sharedEdge[2] = false; 13343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.push_back(tri); 13363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLE_STRIP: 13423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size() - 2; ++vtxNdx) 13443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v0 = vertices[vtxNdx + 0]; 13463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v1 = vertices[vtxNdx + 1]; 13473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v2 = vertices[vtxNdx + 2]; 13483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (triangleOrder(v0, v1, v2) != (cullDirection ^ (vtxNdx % 2 != 0))) 13503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec::SceneTriangle tri; 13523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[0] = v0; tri.sharedEdge[0] = false; 13533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[1] = v1; tri.sharedEdge[1] = false; 13543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[2] = v2; tri.sharedEdge[2] = false; 13553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.push_back(tri); 13573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLE_FAN: 13633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 1; vtxNdx < (int)vertices.size() - 1; ++vtxNdx) 13653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v0 = vertices[0]; 13673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v1 = vertices[vtxNdx + 0]; 13683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& v2 = vertices[vtxNdx + 1]; 13693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (triangleOrder(v0, v1, v2) != cullDirection) 13713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 13723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec::SceneTriangle tri; 13733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[0] = v0; tri.sharedEdge[0] = false; 13743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[1] = v1; tri.sharedEdge[1] = false; 13753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[2] = v2; tri.sharedEdge[2] = false; 13763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.push_back(tri); 13783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 13813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 13843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 13853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 13863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13883c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool CullingTest::triangleOrder (const tcu::Vec4& v0, const tcu::Vec4& v1, const tcu::Vec4& v2) const 13893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 13903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 s0 = v0.swizzle(0, 1) / v0.w(); 13913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 s1 = v1.swizzle(0, 1) / v1.w(); 13923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec2 s2 = v2.swizzle(0, 1) / v2.w(); 13933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // cross 13953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return ((s1.x() - s0.x()) * (s2.y() - s0.y()) - (s2.x() - s0.x()) * (s1.y() - s0.y())) < 0; 13963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 13973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 13983c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass TriangleInterpolationTest : public BaseRenderingCase 13993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14003c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 14013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleInterpolationTest (Context& ctx, const char* name, const char* desc, glw::GLenum primitive, int flags); 14023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~TriangleInterpolationTest (void); 14033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 14043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14053c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 14063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void generateVertices (int iteration, std::vector<tcu::Vec4>& outVertices, std::vector<tcu::Vec4>& outColors) const; 14073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void extractTriangles (std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles, const std::vector<tcu::Vec4>& vertices, const std::vector<tcu::Vec4>& colors) const; 14083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::GLenum m_primitive; 14103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_projective; 14113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_iterationCount; 14123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int m_iteration; 14143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool m_allIterationsPassed; 14153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 14163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14173c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleInterpolationTest::TriangleInterpolationTest (Context& ctx, const char* name, const char* desc, glw::GLenum primitive, int flags) 14183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseRenderingCase (ctx, name, desc) 14193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitive (primitive) 14203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_projective ((flags & INTERPOLATIONFLAGS_PROJECTED) != 0) 14213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (3) 14223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 14233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_allIterationsPassed (true) 14243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14273c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleInterpolationTest::~TriangleInterpolationTest (void) 14283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 14303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14323c827367444ee418f129b2c238299f49d3264554Jarkko PoyryTriangleInterpolationTest::IterateResult TriangleInterpolationTest::iterate (void) 14333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDescription = "Test iteration " + de::toString(m_iteration+1) + " / " + de::toString(m_iterationCount); 14353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (m_testCtx.getLog(), "Iteration" + de::toString(m_iteration+1), iterationDescription); 14363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage (m_renderSize, m_renderSize); 14373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 14383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> colorBuffer; 14393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<TriangleSceneSpec::SceneTriangle> triangles; 14403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generate scene 14423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateVertices(m_iteration, drawBuffer, colorBuffer); 14433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry extractTriangles(triangles, drawBuffer, colorBuffer); 14443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 14463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Generated vertices:" << tcu::TestLog::EndMessage; 14483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)drawBuffer.size(); ++vtxNdx) 14493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "\t" << drawBuffer[vtxNdx] << ",\tcolor= " << colorBuffer[vtxNdx] << tcu::TestLog::EndMessage; 14503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 14533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, colorBuffer, m_primitive); 14543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 14563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizationArguments args; 14583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec scene; 14593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.numSamples = m_numSamples; 14613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.subpixelBits = m_subpixelBits; 14623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.redBits = m_context.getRenderTarget().getPixelFormat().redBits; 14633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.greenBits = m_context.getRenderTarget().getPixelFormat().greenBits; 14643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.blueBits = m_context.getRenderTarget().getPixelFormat().blueBits; 14653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.triangles.swap(triangles); 14673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!verifyTriangleGroupInterpolation(resultImage, scene, args, m_testCtx.getLog())) 14693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_allIterationsPassed = false; 14703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // result 14733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration == m_iterationCount) 14743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_allIterationsPassed) 14763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 14773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 14783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Found invalid pixel values"); 14793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 14813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 14823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 14833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 14843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 14853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleInterpolationTest::generateVertices (int iteration, std::vector<tcu::Vec4>& outVertices, std::vector<tcu::Vec4>& outColors) const 14873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 14883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // use only red, green and blue 14893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 colors[] = 14903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 14913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), 14923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), 14933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), 14943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 14953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(123 + iteration * 1000 + (int)m_primitive); 14973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 14983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices.resize(6); 14993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outColors.resize(6); 15003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outVertices.size(); ++vtxNdx) 15023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].x() = rnd.getFloat(-0.9f, 0.9f); 15043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].y() = rnd.getFloat(-0.9f, 0.9f); 15053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].z() = 0.0f; 15063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_projective) 15083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].w() = 1.0f; 15093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 15103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w = rnd.getFloat(0.2f, 4.0f); 15123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].x() *= w; 15143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].y() *= w; 15153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].z() *= w; 15163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].w() = w; 15173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outColors[vtxNdx] = colors[vtxNdx % DE_LENGTH_OF_ARRAY(colors)]; 15203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 15223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid TriangleInterpolationTest::extractTriangles (std::vector<TriangleSceneSpec::SceneTriangle>& outTriangles, const std::vector<tcu::Vec4>& vertices, const std::vector<tcu::Vec4>& colors) const 15243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 15253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_primitive) 15263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLES: 15283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size() - 2; vtxNdx += 3) 15303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec::SceneTriangle tri; 15323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[0] = vertices[vtxNdx + 0]; 15333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[1] = vertices[vtxNdx + 1]; 15343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[2] = vertices[vtxNdx + 2]; 15353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[0] = false; 15363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[1] = false; 15373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[2] = false; 15383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[0] = colors[vtxNdx + 0]; 15403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[1] = colors[vtxNdx + 1]; 15413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[2] = colors[vtxNdx + 2]; 15423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.push_back(tri); 15443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 15463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLE_STRIP: 15493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size() - 2; ++vtxNdx) 15513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec::SceneTriangle tri; 15533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[0] = vertices[vtxNdx + 0]; 15543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[1] = vertices[vtxNdx + 1]; 15553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[2] = vertices[vtxNdx + 2]; 15563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[0] = false; 15573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[1] = false; 15583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[2] = false; 15593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[0] = colors[vtxNdx + 0]; 15613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[1] = colors[vtxNdx + 1]; 15623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[2] = colors[vtxNdx + 2]; 15633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.push_back(tri); 15653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 15673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_TRIANGLE_FAN: 15703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 1; vtxNdx < (int)vertices.size() - 1; ++vtxNdx) 15723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 15733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TriangleSceneSpec::SceneTriangle tri; 15743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[0] = vertices[0]; 15753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[1] = vertices[vtxNdx + 0]; 15763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.positions[2] = vertices[vtxNdx + 1]; 15773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[0] = false; 15783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[1] = false; 15793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.sharedEdge[2] = false; 15803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[0] = colors[0]; 15823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[1] = colors[vtxNdx + 0]; 15833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tri.colors[2] = colors[vtxNdx + 1]; 15843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outTriangles.push_back(tri); 15863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 15883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 15913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 15923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 15933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 15943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 15953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass LineInterpolationTest : public BaseRenderingCase 15963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 15973c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 15982306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry LineInterpolationTest (Context& ctx, const char* name, const char* desc, glw::GLenum primitive, int flags, float lineWidth); 15992306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry ~LineInterpolationTest (void); 16002306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry IterateResult iterate (void); 16013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16023c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 16032306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry void generateVertices (int iteration, std::vector<tcu::Vec4>& outVertices, std::vector<tcu::Vec4>& outColors) const; 16042306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry void extractLines (std::vector<LineSceneSpec::SceneLine>& outLines, const std::vector<tcu::Vec4>& vertices, const std::vector<tcu::Vec4>& colors) const; 16053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16062306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry const glw::GLenum m_primitive; 16072306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry const bool m_projective; 16082306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry const int m_iterationCount; 16093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16102306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry int m_iteration; 16112306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry tcu::ResultCollector m_result; 16123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 16133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineInterpolationTest::LineInterpolationTest (Context& ctx, const char* name, const char* desc, glw::GLenum primitive, int flags, float lineWidth) 16153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BaseRenderingCase (ctx, name, desc) 16163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_primitive (primitive) 16173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_projective ((flags & INTERPOLATIONFLAGS_PROJECTED) != 0) 16183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iterationCount (3) 16193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_iteration (0) 16203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 16213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_lineWidth = lineWidth; 16223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 16233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16243c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineInterpolationTest::~LineInterpolationTest (void) 16253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 16263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 16273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 16283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16293c827367444ee418f129b2c238299f49d3264554Jarkko PoyryLineInterpolationTest::IterateResult LineInterpolationTest::iterate (void) 16303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 16313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string iterationDescription = "Test iteration " + de::toString(m_iteration+1) + " / " + de::toString(m_iterationCount); 16323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::ScopedLogSection section (m_testCtx.getLog(), "Iteration" + de::toString(m_iteration+1), iterationDescription); 16333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface resultImage (m_renderSize, m_renderSize); 16343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> drawBuffer; 16353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> colorBuffer; 16363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<LineSceneSpec::SceneLine> lines; 16373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // generate scene 16393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry generateVertices(m_iteration, drawBuffer, colorBuffer); 16403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry extractLines(lines, drawBuffer, colorBuffer); 16413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log 16433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Generated vertices:" << tcu::TestLog::EndMessage; 16453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)drawBuffer.size(); ++vtxNdx) 16463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "\t" << drawBuffer[vtxNdx] << ",\tcolor= " << colorBuffer[vtxNdx] << tcu::TestLog::EndMessage; 16473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 16483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw image 16503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry drawPrimitives(resultImage, drawBuffer, colorBuffer, m_primitive); 16513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // compare 16533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 16543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RasterizationArguments args; 16553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineSceneSpec scene; 16562306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry LineInterpolationMethod iterationResult; 16573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.numSamples = m_numSamples; 16593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.subpixelBits = m_subpixelBits; 16603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.redBits = m_context.getRenderTarget().getPixelFormat().redBits; 16613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.greenBits = m_context.getRenderTarget().getPixelFormat().greenBits; 16623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry args.blueBits = m_context.getRenderTarget().getPixelFormat().blueBits; 16633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.lines.swap(lines); 16653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry scene.lineWidth = m_lineWidth; 16663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 16672306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry iterationResult = verifyLineGroupInterpolation(resultImage, scene, args, m_testCtx.getLog()); 16682306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry switch (iterationResult) 16692306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry { 16702306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry case LINEINTERPOLATION_STRICTLY_CORRECT: 16712306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry // line interpolation matches the specification 16722306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry m_result.addResult(QP_TEST_RESULT_PASS, "Pass"); 16732306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry break; 16742306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry 16752306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry case LINEINTERPOLATION_PROJECTED: 16762306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry // line interpolation weights are otherwise correct, but they are projected onto major axis 16772306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry m_testCtx.getLog() << tcu::TestLog::Message 16782306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry << "Interpolation was calculated using coordinates projected onto major axis. " 16792306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry "This method does not produce the same values as the non-projecting method defined in the specification." 16802306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry << tcu::TestLog::EndMessage; 16812306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry m_result.addResult(QP_TEST_RESULT_QUALITY_WARNING, "Interpolation was calculated using projected coordinateds"); 16822306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry break; 16832306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry 16842306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry case LINEINTERPOLATION_INCORRECT: 1685f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry if (scene.lineWidth != 1.0f && m_numSamples > 1) 1686f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry { 1687f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry // multisampled wide lines might not be supported 1688f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_result.addResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Interpolation of multisampled wide lines failed"); 1689f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry } 1690f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry else 1691f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry { 1692f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry // line interpolation is incorrect 1693f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry m_result.addResult(QP_TEST_RESULT_FAIL, "Found invalid pixel values"); 1694f0ca13a370eeeff83ecf3c4d76a13d51dabf4297Jarkko Pöyry } 16952306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry break; 16962306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry 16972306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry default: 16982306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry DE_ASSERT(false); 16992306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry break; 17002306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry } 17013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // result 17043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (++m_iteration == m_iterationCount) 17053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17062306a3bf8214ab2c51d8023ca1ccd979fb8d31bbJarkko Pöyry m_result.setTestContextResult(m_testCtx); 17073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 17083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 17103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return CONTINUE; 17113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 17123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17133c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineInterpolationTest::generateVertices (int iteration, std::vector<tcu::Vec4>& outVertices, std::vector<tcu::Vec4>& outColors) const 17143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 17153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // use only red, green and blue 17163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 colors[] = 17173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f), 17193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f), 17203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f), 17213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 17223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(123 + iteration * 1000 + (int)m_primitive); 17243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices.resize(6); 17263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outColors.resize(6); 17273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)outVertices.size(); ++vtxNdx) 17293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].x() = rnd.getFloat(-0.9f, 0.9f); 17313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].y() = rnd.getFloat(-0.9f, 0.9f); 17323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].z() = 0.0f; 17333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_projective) 17353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].w() = 1.0f; 17363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 17373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const float w = rnd.getFloat(0.2f, 4.0f); 17393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].x() *= w; 17413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].y() *= w; 17423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].z() *= w; 17433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outVertices[vtxNdx].w() = w; 17443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outColors[vtxNdx] = colors[vtxNdx % DE_LENGTH_OF_ARRAY(colors)]; 17473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 17493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17503c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid LineInterpolationTest::extractLines (std::vector<LineSceneSpec::SceneLine>& outLines, const std::vector<tcu::Vec4>& vertices, const std::vector<tcu::Vec4>& colors) const 17513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 17523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry switch (m_primitive) 17533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_LINES: 17553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size() - 1; vtxNdx += 2) 17573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineSceneSpec::SceneLine line; 17593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.positions[0] = vertices[vtxNdx + 0]; 17603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.positions[1] = vertices[vtxNdx + 1]; 17613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.colors[0] = colors[vtxNdx + 0]; 17633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.colors[1] = colors[vtxNdx + 1]; 17643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines.push_back(line); 17663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 17683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_LINE_STRIP: 17713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size() - 1; ++vtxNdx) 17733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineSceneSpec::SceneLine line; 17753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.positions[0] = vertices[vtxNdx + 0]; 17763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.positions[1] = vertices[vtxNdx + 1]; 17773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.colors[0] = colors[vtxNdx + 0]; 17793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.colors[1] = colors[vtxNdx + 1]; 17803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines.push_back(line); 17823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 17843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry case GL_LINE_LOOP: 17873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int vtxNdx = 0; vtxNdx < (int)vertices.size(); ++vtxNdx) 17893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 17903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry LineSceneSpec::SceneLine line; 17913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.positions[0] = vertices[(vtxNdx + 0) % (int)vertices.size()]; 17923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.positions[1] = vertices[(vtxNdx + 1) % (int)vertices.size()]; 17933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.colors[0] = colors[(vtxNdx + 0) % (int)vertices.size()]; 17953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry line.colors[1] = colors[(vtxNdx + 1) % (int)vertices.size()]; 17963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 17973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry outLines.push_back(line); 17983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 17993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry break; 18003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry default: 18033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(false); 18043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 18083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18093c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizationTests::RasterizationTests (Context& context) 18103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "rasterization", "Rasterization Tests") 18113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18143c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRasterizationTests::~RasterizationTests (void) 18153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 18173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18183c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RasterizationTests::init (void) 18193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 18203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .primitives 18213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const primitives = new tcu::TestCaseGroup(m_testCtx, "primitives", "Primitive rasterization"); 18233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(primitives); 18253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new TrianglesCase (m_context, "triangles", "Render primitives as GL_TRIANGLES, verify rasterization result")); 18273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new TriangleStripCase (m_context, "triangle_strip", "Render primitives as GL_TRIANGLE_STRIP, verify rasterization result")); 18283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new TriangleFanCase (m_context, "triangle_fan", "Render primitives as GL_TRIANGLE_FAN, verify rasterization result")); 18293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new LinesCase (m_context, "lines", "Render primitives as GL_LINES, verify rasterization result", PRIMITIVEWIDENESS_NARROW)); 18303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new LineStripCase (m_context, "line_strip", "Render primitives as GL_LINE_STRIP, verify rasterization result", PRIMITIVEWIDENESS_NARROW)); 18313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new LineLoopCase (m_context, "line_loop", "Render primitives as GL_LINE_LOOP, verify rasterization result", PRIMITIVEWIDENESS_NARROW)); 18323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new LinesCase (m_context, "lines_wide", "Render primitives as GL_LINES with wide lines, verify rasterization result", PRIMITIVEWIDENESS_WIDE)); 18333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new LineStripCase (m_context, "line_strip_wide", "Render primitives as GL_LINE_STRIP with wide lines, verify rasterization result", PRIMITIVEWIDENESS_WIDE)); 18343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new LineLoopCase (m_context, "line_loop_wide", "Render primitives as GL_LINE_LOOP with wide lines, verify rasterization result", PRIMITIVEWIDENESS_WIDE)); 18353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry primitives->addChild(new PointCase (m_context, "points", "Render primitives as GL_POINTS, verify rasterization result", PRIMITIVEWIDENESS_WIDE)); 18363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .fill_rules 18393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const fillRules = new tcu::TestCaseGroup(m_testCtx, "fill_rules", "Primitive fill rules"); 18413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(fillRules); 18433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fillRules->addChild(new FillRuleCase(m_context, "basic_quad", "Verify fill rules", FillRuleCase::FILLRULECASE_BASIC)); 18453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fillRules->addChild(new FillRuleCase(m_context, "basic_quad_reverse", "Verify fill rules", FillRuleCase::FILLRULECASE_REVERSED)); 18463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fillRules->addChild(new FillRuleCase(m_context, "clipped_full", "Verify fill rules", FillRuleCase::FILLRULECASE_CLIPPED_FULL)); 18473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fillRules->addChild(new FillRuleCase(m_context, "clipped_partly", "Verify fill rules", FillRuleCase::FILLRULECASE_CLIPPED_PARTIAL)); 18483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry fillRules->addChild(new FillRuleCase(m_context, "projected", "Verify fill rules", FillRuleCase::FILLRULECASE_PROJECTED)); 18493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .culling 18523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct CullMode 18543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum mode; 18563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* prefix; 18573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } cullModes[] = 18583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_FRONT, "front_" }, 18603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_BACK, "back_" }, 18613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_FRONT_AND_BACK, "both_" }, 18623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct PrimitiveType 18643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum type; 18663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* name; 18673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } primitiveTypes[] = 18683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_TRIANGLES, "triangles" }, 18703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_TRIANGLE_STRIP, "triangle_strip" }, 18713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_TRIANGLE_FAN, "triangle_fan" }, 18723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static const struct FrontFaceOrder 18743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLenum mode; 18763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const char* postfix; 18773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } frontOrders[] = 18783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_CCW, "" }, 18803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_CW, "_reverse" }, 18813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 18823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const culling = new tcu::TestCaseGroup(m_testCtx, "culling", "Culling"); 18843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(culling); 18863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int cullModeNdx = 0; cullModeNdx < DE_LENGTH_OF_ARRAY(cullModes); ++cullModeNdx) 18883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int primitiveNdx = 0; primitiveNdx < DE_LENGTH_OF_ARRAY(primitiveTypes); ++primitiveNdx) 18893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int frontOrderNdx = 0; frontOrderNdx < DE_LENGTH_OF_ARRAY(frontOrders); ++frontOrderNdx) 18903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const std::string name = std::string(cullModes[cullModeNdx].prefix) + primitiveTypes[primitiveNdx].name + frontOrders[frontOrderNdx].postfix; 18923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry culling->addChild(new CullingTest(m_context, name.c_str(), "Test primitive culling.", cullModes[cullModeNdx].mode, primitiveTypes[primitiveNdx].type, frontOrders[frontOrderNdx].mode)); 18943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 18963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 18973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .interpolation 18983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 18993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const interpolation = new tcu::TestCaseGroup(m_testCtx, "interpolation", "Test interpolation"); 19003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(interpolation); 19023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .basic 19043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const basic = new tcu::TestCaseGroup(m_testCtx, "basic", "Non-projective interpolation"); 19063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry interpolation->addChild(basic); 19083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new TriangleInterpolationTest (m_context, "triangles", "Verify triangle interpolation", GL_TRIANGLES, INTERPOLATIONFLAGS_NONE)); 19103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new TriangleInterpolationTest (m_context, "triangle_strip", "Verify triangle strip interpolation", GL_TRIANGLE_STRIP, INTERPOLATIONFLAGS_NONE)); 19113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new TriangleInterpolationTest (m_context, "triangle_fan", "Verify triangle fan interpolation", GL_TRIANGLE_FAN, INTERPOLATIONFLAGS_NONE)); 19123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new LineInterpolationTest (m_context, "lines", "Verify line interpolation", GL_LINES, INTERPOLATIONFLAGS_NONE, 1.0f)); 19133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new LineInterpolationTest (m_context, "line_strip", "Verify line strip interpolation", GL_LINE_STRIP, INTERPOLATIONFLAGS_NONE, 1.0f)); 19143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new LineInterpolationTest (m_context, "line_loop", "Verify line loop interpolation", GL_LINE_LOOP, INTERPOLATIONFLAGS_NONE, 1.0f)); 19153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new LineInterpolationTest (m_context, "lines_wide", "Verify wide line interpolation", GL_LINES, INTERPOLATIONFLAGS_NONE, 5.0f)); 19163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new LineInterpolationTest (m_context, "line_strip_wide", "Verify wide line strip interpolation", GL_LINE_STRIP, INTERPOLATIONFLAGS_NONE, 5.0f)); 19173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry basic->addChild(new LineInterpolationTest (m_context, "line_loop_wide", "Verify wide line loop interpolation", GL_LINE_LOOP, INTERPOLATIONFLAGS_NONE, 5.0f)); 19183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .projected 19213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 19223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const projected = new tcu::TestCaseGroup(m_testCtx, "projected", "Projective interpolation"); 19233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry interpolation->addChild(projected); 19253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new TriangleInterpolationTest (m_context, "triangles", "Verify triangle interpolation", GL_TRIANGLES, INTERPOLATIONFLAGS_PROJECTED)); 19273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new TriangleInterpolationTest (m_context, "triangle_strip", "Verify triangle strip interpolation", GL_TRIANGLE_STRIP, INTERPOLATIONFLAGS_PROJECTED)); 19283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new TriangleInterpolationTest (m_context, "triangle_fan", "Verify triangle fan interpolation", GL_TRIANGLE_FAN, INTERPOLATIONFLAGS_PROJECTED)); 19293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new LineInterpolationTest (m_context, "lines", "Verify line interpolation", GL_LINES, INTERPOLATIONFLAGS_PROJECTED, 1.0f)); 19303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new LineInterpolationTest (m_context, "line_strip", "Verify line strip interpolation", GL_LINE_STRIP, INTERPOLATIONFLAGS_PROJECTED, 1.0f)); 19313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new LineInterpolationTest (m_context, "line_loop", "Verify line loop interpolation", GL_LINE_LOOP, INTERPOLATIONFLAGS_PROJECTED, 1.0f)); 19323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new LineInterpolationTest (m_context, "lines_wide", "Verify wide line interpolation", GL_LINES, INTERPOLATIONFLAGS_PROJECTED, 5.0f)); 19333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new LineInterpolationTest (m_context, "line_strip_wide", "Verify wide line strip interpolation", GL_LINE_STRIP, INTERPOLATIONFLAGS_PROJECTED, 5.0f)); 19343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry projected->addChild(new LineInterpolationTest (m_context, "line_loop_wide", "Verify wide line loop interpolation", GL_LINE_LOOP, INTERPOLATIONFLAGS_PROJECTED, 5.0f)); 19353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 19373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 19383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 19393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 19403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 19413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 1942