13c827367444ee418f129b2c238299f49d3264554Jarkko Poyry/*------------------------------------------------------------------------- 23c827367444ee418f129b2c238299f49d3264554Jarkko Poyry * drawElements Quality Program OpenGL ES 3.1 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 Vertex attribute binding stress tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es31sVertexAttributeBindingTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuVector.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuTestLog.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuRenderTarget.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "tcuSurface.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluCallLogWrapper.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluObjectWrapper.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluPixelTransfer.hpp" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluShaderProgram.hpp" 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluStrUtil.hpp" 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deStringUtil.hpp" 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles31 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Stress 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_vertexSource = "#version 310 es\n" 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_position;\n" 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_fragmentSource = "#version 310 es\n" 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 fragColor;\n" 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " fragColor = vec4(1.0, 1.0, 1.0, 1.0);\n" 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic const char* const s_colorFragmentShader = "#version 310 es\n" 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in mediump vec4 v_color;\n" 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "layout(location = 0) out mediump vec4 fragColor;\n" 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " fragColor = v_color;\n" 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// Verifies image contains only yellow or greeen, or a linear combination 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry// of these colors. 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystatic bool verifyImageYellowGreen (const tcu::Surface& image, tcu::TestLog& log, bool logImageOnSuccess) 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int colorThreshold = 20; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface error (image.getWidth(), image.getHeight()); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool isOk = true; 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Verifying image contents." << TestLog::EndMessage; 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < image.getHeight(); y++) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < image.getWidth(); x++) 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::RGBA pixel = image.getPixel(x, y); 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool pixelOk = true; 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Any pixel with !(G ~= 255) is faulty (not a linear combinations of green and yellow) 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (de::abs(pixel.getGreen() - 255) > colorThreshold) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixelOk = false; 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // Any pixel with !(B ~= 0) is faulty (not a linear combinations of green and yellow) 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (de::abs(pixel.getBlue() - 0) > colorThreshold) 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry pixelOk = false; 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry error.setPixel(x, y, (pixelOk) ? (tcu::RGBA(0, 255, 0, 255)) : (tcu::RGBA(255, 0, 0, 255))); 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry isOk = isOk && pixelOk; 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!isOk) 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Image verification failed." << TestLog::EndMessage; 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Verfication result", "Result of rendering") 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Result", image) 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("ErrorMask", "Error mask", error) 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::Message << "Image verification passed." << TestLog::EndMessage; 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (logImageOnSuccess) 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry log << TestLog::ImageSet("Verfication result", "Result of rendering") 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::Image("Result", "Result", image) 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << TestLog::EndImageSet; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return isOk; 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BindingRenderCase : public TestCase 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TEST_RENDER_SIZE = 64 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BindingRenderCase (Context& ctx, const char* name, const char* desc, bool unalignedData); 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual ~BindingRenderCase (void); 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void init (void); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void deinit (void); 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void renderTo (tcu::Surface& dst) = 0; 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createBuffers (void) = 0; 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry virtual void createShader (void) = 0; 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprotected: 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool m_unalignedData; 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_vao; 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1483c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindingRenderCase::BindingRenderCase (Context& ctx, const char* name, const char* desc, bool unalignedData) 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (ctx, name, desc) 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_unalignedData (unalignedData) 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_vao (0) 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_program (DE_NULL) 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1563c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindingRenderCase::~BindingRenderCase (void) 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindingRenderCase::init (void) 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // check requirements 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_context.getRenderTarget().getWidth() < TEST_RENDER_SIZE || m_context.getRenderTarget().getHeight() < TEST_RENDER_SIZE) 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::NotSupportedError("Test requires at least " + de::toString<int>(TEST_RENDER_SIZE) + "x" + de::toString<int>(TEST_RENDER_SIZE) + " render target"); 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // resources 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().genVertexArrays(1, &m_vao); 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_context.getRenderContext().getFunctions().getError() != GL_NO_ERROR) 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("could not gen vao"); 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createBuffers(); 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry createShader(); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindingRenderCase::deinit (void) 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_vao) 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteVertexArrays(1, &m_vao); 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_vao = 0; 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_program; 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = DE_NULL; 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1883c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindingRenderCase::IterateResult BindingRenderCase::iterate (void) 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface surface(TEST_RENDER_SIZE, TEST_RENDER_SIZE); 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // draw pattern 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry renderTo(surface); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // verify results 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (verifyImageYellowGreen(surface, m_testCtx.getLog(), false)) 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (m_unalignedData) 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_COMPATIBILITY_WARNING, "Failed to draw with unaligned data"); 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Image verification failed"); 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass SingleBindingCase : public BindingRenderCase 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum CaseFlag 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_ATTRIB_UNALIGNED = (1<<0), // !< unalign attributes with relativeOffset 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_ATTRIB_ALIGNED = (1<<1), // !< align attributes with relativeOffset to the buffer begin (and not buffer offset) 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_ATTRIBS_MULTIPLE_ELEMS = (1<<2), // !< use multiple attribute elements 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_ATTRIBS_SHARED_ELEMS = (1<<3), // !< use multiple shared attribute elements. xyzw & rgba stored as (x, y, zr, wg, b, a) 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_BUF_ALIGNED_OFFSET = (1<<4), // !< use aligned offset to the buffer object 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_BUF_UNALIGNED_OFFSET = (1<<5), // !< use unaligned offset to the buffer object 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry FLAG_BUF_UNALIGNED_STRIDE = (1<<6), // !< unalign buffer elements 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry SingleBindingCase (Context& ctx, const char* name, int flags); 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~SingleBindingCase (void); 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry struct TestSpec 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bufferOffset; 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bufferStride; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int positionAttrOffset; 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int colorAttrOffset; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bool hasColorAttr; 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry enum 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GRID_SIZE = 20 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void renderTo (tcu::Surface& dst); 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static TestSpec genTestSpec (int flags); 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static std::string genTestDescription (int flags); 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry static bool isDataUnaligned (int flags); 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void createBuffers (void); 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void createShader (void); 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::string genVertexSource (void); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const TestSpec m_spec; 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glw::GLuint m_buf; 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleBindingCase::SingleBindingCase (Context& ctx, const char* name, int flags) 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : BindingRenderCase (ctx, name, genTestDescription(flags).c_str(), isDataUnaligned(flags)) 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_spec (genTestSpec(flags)) 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_buf (0) 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!((flags & FLAG_ATTRIB_UNALIGNED) && (flags & FLAG_ATTRIB_ALIGNED))); 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!((flags & FLAG_ATTRIB_ALIGNED) && (flags & FLAG_BUF_UNALIGNED_STRIDE))); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(isDataUnaligned(flags)); 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2693c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleBindingCase::~SingleBindingCase (void) 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::init (void) 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // log what we are trying to do 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Rendering " << (int)GRID_SIZE << "x" << (int)GRID_SIZE << " grid.\n" 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Buffer format:\n" 2813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " bufferOffset: " << m_spec.bufferOffset << "\n" 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " bufferStride: " << m_spec.bufferStride << "\n" 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Vertex position format:\n" 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " type: float4\n" 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " offset: " << m_spec.positionAttrOffset << "\n" 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " total offset: " << m_spec.bufferOffset + m_spec.positionAttrOffset << "\n" 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_spec.hasColorAttr) 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << "Color:\n" 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " type: float4\n" 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " offset: " << m_spec.colorAttrOffset << "\n" 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << " total offset: " << m_spec.bufferOffset + m_spec.colorAttrOffset << "\n" 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry << tcu::TestLog::EndMessage; 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // init 2973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BindingRenderCase::init(); 2993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3013c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::deinit (void) 3023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_buf) 3043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_buf); 3063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_buf = 0; 3073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BindingRenderCase::deinit(); 3103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::renderTo (tcu::Surface& dst) 3133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 3153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int positionLoc = gl.glGetAttribLocation(m_program->getProgram(), "a_position"); 3163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int colorLoc = gl.glGetAttribLocation(m_program->getProgram(), "a_color"); 3173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int colorUniformLoc = gl.glGetUniformLocation(m_program->getProgram(), "u_color"); 3183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableLogging(true); 3203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 3223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glClear(GL_COLOR_BUFFER_BIT); 3233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glViewport(0, 0, dst.getWidth(), dst.getHeight()); 3243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexArray(m_vao); 3253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "set vao"); 3263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glUseProgram(m_program->getProgram()); 3283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "use program"); 3293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_spec.hasColorAttr) 3313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexBuffer(3, m_buf, m_spec.bufferOffset, m_spec.bufferStride); 3333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribBinding(positionLoc, 3); 3353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, m_spec.positionAttrOffset); 3363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glEnableVertexAttribArray(positionLoc); 3373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribBinding(colorLoc, 3); 3393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribFormat(colorLoc, 4, GL_FLOAT, GL_FALSE, m_spec.colorAttrOffset); 3403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glEnableVertexAttribArray(colorLoc); 3413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "set va"); 3433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glDrawArrays(GL_TRIANGLES, 0, GRID_SIZE*GRID_SIZE*6); 3453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "draw"); 3463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 3493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexBuffer(3, m_buf, m_spec.bufferOffset, m_spec.bufferStride); 3503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribBinding(positionLoc, 3); 3513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, m_spec.positionAttrOffset); 3523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glEnableVertexAttribArray(positionLoc); 3533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "set va"); 3553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glUniform4f(colorUniformLoc, 0.0f, 1.0f, 0.0f, 1.0f); 3563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glDrawArrays(GL_TRIANGLES, 0, GRID_SIZE*GRID_SIZE*6); 3583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "draw"); 3593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 3603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glFinish(); 3623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexArray(0); 3633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glUseProgram(0); 3643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "clean"); 3653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess()); 3673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 3683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3693c827367444ee418f129b2c238299f49d3264554Jarkko PoyrySingleBindingCase::TestSpec SingleBindingCase::genTestSpec (int flags) 3703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 3713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int datumSize = 4; 3723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferOffset = (flags & FLAG_BUF_ALIGNED_OFFSET) ? (32) : (flags & FLAG_BUF_UNALIGNED_OFFSET) ? (19) : (0); 3733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int attrBufAlignment = ((bufferOffset % datumSize) == 0) ? (0) : (datumSize - (bufferOffset % datumSize)); 3743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int positionAttrOffset = (flags & FLAG_ATTRIB_UNALIGNED) ? (3) : (flags & FLAG_ATTRIB_ALIGNED) ? (attrBufAlignment) : (0); 3753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool hasColorAttr = (flags & FLAG_ATTRIBS_SHARED_ELEMS) || (flags & FLAG_ATTRIBS_MULTIPLE_ELEMS); 3763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int colorAttrOffset = (flags & FLAG_ATTRIBS_SHARED_ELEMS) ? (2 * datumSize) : (flags & FLAG_ATTRIBS_MULTIPLE_ELEMS) ? (4 * datumSize) : (-1); 3773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferStrideBase = de::max(positionAttrOffset + 4 * datumSize, colorAttrOffset + 4 * datumSize); 3793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferStrideAlignment = ((bufferStrideBase % datumSize) == 0) ? (0) : (datumSize - (bufferStrideBase % datumSize)); 3803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int bufferStridePadding = ((flags & FLAG_BUF_UNALIGNED_STRIDE) && deIsAligned32(bufferStrideBase, datumSize)) ? (13) : (!(flags & FLAG_BUF_UNALIGNED_STRIDE) && !deIsAligned32(bufferStrideBase, datumSize)) ? (bufferStrideAlignment) : (0); 3813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry TestSpec spec; 3833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.bufferOffset = bufferOffset; 3853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.bufferStride = bufferStrideBase + bufferStridePadding; 3863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.positionAttrOffset = positionAttrOffset; 3873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.colorAttrOffset = colorAttrOffset; 3883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry spec.hasColorAttr = hasColorAttr; 3893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIB_UNALIGNED) 3913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!deIsAligned32(spec.bufferOffset + spec.positionAttrOffset, datumSize)); 3923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else if (flags & FLAG_ATTRIB_ALIGNED) 3933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(deIsAligned32(spec.bufferOffset + spec.positionAttrOffset, datumSize)); 3943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 3953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_BUF_UNALIGNED_STRIDE) 3963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(!deIsAligned32(spec.bufferStride, datumSize)); 3973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 3983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_ASSERT(deIsAligned32(spec.bufferStride, datumSize)); 3993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return spec; 4013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4033c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string SingleBindingCase::genTestDescription (int flags) 4043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream buf; 4063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << "draw test pattern"; 4073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIB_UNALIGNED) 4093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", attribute offset (unaligned)"; 4103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIB_ALIGNED) 4113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", attribute offset (aligned)"; 4123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIBS_MULTIPLE_ELEMS) 4143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", 2 attributes"; 4153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIBS_SHARED_ELEMS) 4163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", 2 attributes (some components shared)"; 4173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_BUF_ALIGNED_OFFSET) 4193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", buffer offset aligned"; 4203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_BUF_UNALIGNED_OFFSET) 4213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", buffer offset unaligned"; 4223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_BUF_UNALIGNED_STRIDE) 4233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << ", buffer stride unaligned"; 4243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return buf.str(); 4263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4283c827367444ee418f129b2c238299f49d3264554Jarkko Poyrybool SingleBindingCase::isDataUnaligned (int flags) 4293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIB_UNALIGNED) 4313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return true; 4323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (flags & FLAG_ATTRIB_ALIGNED) 4333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return false; 4343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return (flags & FLAG_BUF_UNALIGNED_OFFSET) || (flags & FLAG_BUF_UNALIGNED_STRIDE); 4363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4383c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::createBuffers (void) 4393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 4413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<deUint8> dataBuf (m_spec.bufferOffset + m_spec.bufferStride * GRID_SIZE * GRID_SIZE * 6); 4423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // In interleaved mode color rg and position zw are the same. Select "good" values for r and g 4443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 colorA (0.0f, 1.0f, 0.0f, 1.0f); 4453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 colorB (0.5f, 1.0f, 0.0f, 1.0f); 4463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int y = 0; y < GRID_SIZE; ++y) 4483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int x = 0; x < GRID_SIZE; ++x) 4493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4& color = ((x + y) % 2 == 0) ? (colorA) : (colorB); 4513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const tcu::Vec4 positions[6] = 4523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 4533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4((x+0) / float(GRID_SIZE) * 2.0f - 1.0f, (y+0) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f), 4543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4((x+0) / float(GRID_SIZE) * 2.0f - 1.0f, (y+1) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f), 4553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4((x+1) / float(GRID_SIZE) * 2.0f - 1.0f, (y+1) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f), 4563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4((x+0) / float(GRID_SIZE) * 2.0f - 1.0f, (y+0) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f), 4573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4((x+1) / float(GRID_SIZE) * 2.0f - 1.0f, (y+1) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f), 4583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Vec4((x+1) / float(GRID_SIZE) * 2.0f - 1.0f, (y+0) / float(GRID_SIZE) * 2.0f - 1.0f, 0.0f, 1.0f), 4593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 4603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // copy cell vertices to the buffer. 4623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int v = 0; v < 6; ++v) 4633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry memcpy(&dataBuf[m_spec.bufferOffset + m_spec.positionAttrOffset + m_spec.bufferStride * ((y * GRID_SIZE + x) * 6 + v)], positions[v].getPtr(), sizeof(positions[v])); 4643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // copy color to buffer 4663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_spec.hasColorAttr) 4673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int v = 0; v < 6; ++v) 4683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry memcpy(&dataBuf[m_spec.bufferOffset + m_spec.colorAttrOffset + m_spec.bufferStride * ((y * GRID_SIZE + x) * 6 + v)], color.getPtr(), sizeof(color)); 4693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 4703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_buf); 4723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_buf); 4733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, (glw::GLsizeiptr)dataBuf.size(), &dataBuf[0], GL_STATIC_DRAW); 4743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, 0); 4753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (gl.getError() != GL_NO_ERROR) 4773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("could not init buffer"); 4783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4803c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid SingleBindingCase::createShader (void) 4813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(genVertexSource()) << glu::FragmentSource(s_colorFragmentShader)); 4833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *m_program; 4843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_program->isOk()) 4863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("could not build shader"); 4873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 4883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4893c827367444ee418f129b2c238299f49d3264554Jarkko Poyrystd::string SingleBindingCase::genVertexSource (void) 4903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 4913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const bool useUniformColor = !m_spec.hasColorAttr; 4923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::ostringstream buf; 4933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << "#version 310 es\n" 4953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "in highp vec4 a_position;\n"; 4963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 4973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!useUniformColor) 4983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << "in highp vec4 a_color;\n"; 4993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry else 5003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << "uniform highp vec4 u_color;\n"; 5013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry buf << "out highp vec4 v_color;\n" 5033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "void main (void)\n" 5043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "{\n" 5053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " gl_Position = a_position;\n" 5063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry " v_color = " << ((useUniformColor) ? ("u_color") : ("a_color")) << ";\n" 5073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry "}\n"; 5083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return buf.str(); 5103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5123c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass BindVertexBufferCase : public TestCase 5133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5143c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 5153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry BindVertexBufferCase (Context& ctx, const char* name, const char* desc, int offset, int drawCount); 5163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry ~BindVertexBufferCase (void); 5173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void init (void); 5193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void deinit (void); 5203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry IterateResult iterate (void); 5213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5223c827367444ee418f129b2c238299f49d3264554Jarkko Poyryprivate: 5233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_offset; 5243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int m_drawCount; 5253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deUint32 m_buffer; 5263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::ShaderProgram* m_program; 5273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 5283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5293c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindVertexBufferCase::BindVertexBufferCase (Context& ctx, const char* name, const char* desc, int offset, int drawCount) 5303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCase (ctx, name, desc) 5313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_offset (offset) 5323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_drawCount (drawCount) 5333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_buffer (0) 5343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry , m_program (DE_NULL) 5353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5383c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindVertexBufferCase::~BindVertexBufferCase (void) 5393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry deinit(); 5413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5433c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindVertexBufferCase::init (void) 5443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 5463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry std::vector<tcu::Vec4> data (m_drawCount); // !< some junk data to make sure buffer is really allocated 5473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.genBuffers(1, &m_buffer); 5493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bindBuffer(GL_ARRAY_BUFFER, m_buffer); 5503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.bufferData(GL_ARRAY_BUFFER, int(m_drawCount * sizeof(tcu::Vec4)), &data[0], GL_STATIC_DRAW); 5513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.getError(), "buffer gen"); 5523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::ProgramSources() << glu::VertexSource(s_vertexSource) << glu::FragmentSource(s_fragmentSource)); 5543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!m_program->isOk()) 5553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << *m_program; 5573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry throw tcu::TestError("could not build program"); 5583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5613c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid BindVertexBufferCase::deinit (void) 5623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_buffer) 5643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 5653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_context.getRenderContext().getFunctions().deleteBuffers(1, &m_buffer); 5663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_buffer = 0; 5673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 5683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry delete m_program; 5703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_program = DE_NULL; 5713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 5723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5733c827367444ee418f129b2c238299f49d3264554Jarkko PoyryBindVertexBufferCase::IterateResult BindVertexBufferCase::iterate (void) 5743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 5753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::CallLogWrapper gl (m_context.getRenderContext().getFunctions(), m_testCtx.getLog()); 5763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deInt32 positionLoc = gl.glGetAttribLocation(m_program->getProgram(), "a_position"); 5773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::Surface dst (m_context.getRenderTarget().getWidth(), m_context.getRenderTarget().getHeight()); 5783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::VertexArray vao (m_context.getRenderContext()); 5793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.enableLogging(true); 5813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 5833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glClear(GL_COLOR_BUFFER_BIT); 5843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "setup"); 5853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glUseProgram(m_program->getProgram()); 5873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "use program"); 5883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexArray(*vao); 5903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glEnableVertexAttribArray(positionLoc); 5913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribFormat(positionLoc, 4, GL_FLOAT, GL_FALSE, 0); 5923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glVertexAttribBinding(positionLoc, 0); 5933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glBindVertexBuffer(0, m_buffer, m_offset, int(sizeof(tcu::Vec4))); 5943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLU_EXPECT_NO_ERROR(gl.glGetError(), "set buffer"); 5953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glDrawArrays(GL_POINTS, 0, m_drawCount); 5973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 5983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // allow errors after attempted out-of-bounds memory access 5993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const deUint32 error = gl.glGetError(); 6013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (error != GL_NO_ERROR) 6033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << tcu::TestLog::Message << "Got error: " << glu::getErrorStr(error) << ", ignoring..." << tcu::TestLog::EndMessage; 6043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // read pixels to wait for rendering 6073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glFinish(); 6083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glu::readPixels(m_context.getRenderContext(), 0, 0, dst.getAccess()); 6093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 6113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return STOP; 6123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 6153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6163c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexAttributeBindingTests::VertexAttributeBindingTests (Context& context) 6173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "vertex_attribute_binding", "Test vertex attribute binding stress tests") 6183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6213c827367444ee418f129b2c238299f49d3264554Jarkko PoyryVertexAttributeBindingTests::~VertexAttributeBindingTests (void) 6223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6253c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid VertexAttributeBindingTests::init (void) 6263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 6273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const unalignedGroup = new tcu::TestCaseGroup(m_testCtx, "unaligned", "Unaligned access"); 6283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry tcu::TestCaseGroup* const bufferRangeGroup = new tcu::TestCaseGroup(m_testCtx, "buffer_bounds", "Source data over buffer bounds"); 6293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(unalignedGroup); 6313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(bufferRangeGroup); 6323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .unaligned 6343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "elements_1_unaligned", SingleBindingCase::FLAG_ATTRIB_UNALIGNED)); 6363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "offset_elements_1_unaligned", SingleBindingCase::FLAG_BUF_ALIGNED_OFFSET | SingleBindingCase::FLAG_ATTRIB_UNALIGNED)); 6373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_1", SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET | 0)); 6393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_1_unaligned", SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET | SingleBindingCase::FLAG_ATTRIB_UNALIGNED)); 6403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_2", SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET | SingleBindingCase::FLAG_ATTRIBS_MULTIPLE_ELEMS)); 6413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_offset_elements_2_share_elements", SingleBindingCase::FLAG_BUF_UNALIGNED_OFFSET | SingleBindingCase::FLAG_ATTRIBS_SHARED_ELEMS)); 6423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_stride_elements_1", SingleBindingCase::FLAG_BUF_UNALIGNED_STRIDE | 0)); 6443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_stride_elements_2", SingleBindingCase::FLAG_BUF_UNALIGNED_STRIDE | SingleBindingCase::FLAG_ATTRIBS_MULTIPLE_ELEMS)); 6453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry unalignedGroup->addChild(new SingleBindingCase(m_context, "unaligned_stride_elements_2_share_elements", SingleBindingCase::FLAG_BUF_UNALIGNED_STRIDE | SingleBindingCase::FLAG_ATTRIBS_SHARED_ELEMS)); 6463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // .buffer_bounds 6493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 6503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // bind buffer offset cases 6513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_over_bounds_10", "Offset over buffer bounds", 0x00210000, 10)); 6523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_over_bounds_1000", "Offset over buffer bounds", 0x00210000, 1000)); 6533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_near_wrap_10", "Offset over buffer bounds, near wrapping", 0x7FFFFFF0, 10)); 6543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry bufferRangeGroup->addChild(new BindVertexBufferCase(m_context, "bind_vertex_buffer_offset_near_wrap_1000", "Offset over buffer bounds, near wrapping", 0x7FFFFFF0, 1000)); 6553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 6563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 6573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 6583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Stress 6593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles31 6603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 661