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 Rbo state query tests. 223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry *//*--------------------------------------------------------------------*/ 233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fRboStateQueryTests.hpp" 253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glsStateQueryUtil.hpp" 263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "es2fApiCase.hpp" 273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "gluRenderContext.hpp" 283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwEnums.hpp" 293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "glwFunctions.hpp" 303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deRandom.hpp" 313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry#include "deMath.h" 323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 333c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing namespace glw; // GLint and other GL types 343c827367444ee418f129b2c238299f49d3264554Jarkko Poyryusing deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard; 353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 373c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace deqp 383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 393c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace gles2 403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 413c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace Functional 423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 433c827367444ee418f129b2c238299f49d3264554Jarkko Poyrynamespace 443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 463c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkRenderbufferComponentSize (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, int r, int g, int b, int a, int d, int s) 473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int referenceSizes[] = {r, g, b, a, d, s}; 513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLenum paramNames[] = 523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER_RED_SIZE, 543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER_GREEN_SIZE, 553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER_BLUE_SIZE, 563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER_ALPHA_SIZE, 573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER_DEPTH_SIZE, 583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RENDERBUFFER_STENCIL_SIZE 593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(referenceSizes) == DE_LENGTH_OF_ARRAY(paramNames)); 623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceSizes); ++ndx) 643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (referenceSizes[ndx] == -1) 663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry continue; 673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StateQueryMemoryWriteGuard<GLint> state; 693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGetRenderbufferParameteriv(GL_RENDERBUFFER, paramNames[ndx], &state); 703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (!state.verifyValidity(testCtx)) 723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry return; 733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state < referenceSizes[ndx]) 753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testCtx.getLog() << TestLog::Message << "// ERROR: Expected greater or equal to " << referenceSizes[ndx] << "; got " << state << TestLog::EndMessage; 773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value"); 793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 833c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkIntEquals (tcu::TestContext& testCtx, GLint got, GLint expected) 843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (got != expected) 883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage; 903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value"); 923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 953c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid checkRenderbufferParam (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum pname, GLenum reference) 963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StateQueryMemoryWriteGuard<GLint> state; 983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry gl.glGetRenderbufferParameteriv(GL_RENDERBUFFER, pname, &state); 993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.verifyValidity(testCtx)) 1013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkIntEquals(testCtx, state, reference); 1023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 1033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1043c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RboSizeCase : public ApiCase 1053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1063c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RboSizeCase (Context& context, const char* name, const char* description) 1083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ApiCase(context, name, description) 1093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void test (void) 1133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry de::Random rnd(0xabcdef); 1153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint renderbufferID = 0; 1173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenRenderbuffers(1, &renderbufferID); 1183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID); 1193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_WIDTH, 0); 1223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_HEIGHT, 0); 1233c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1253c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int maxRenderbufferSize = 1; 1263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxRenderbufferSize); 1273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const int numIterations = 30; 1303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int i = 0; i < numIterations; ++i) 1313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint w = rnd.getInt(0, maxRenderbufferSize); 1333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLint h = rnd.getInt(0, maxRenderbufferSize); 1343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, w, h); 1363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_WIDTH, w); 1393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_HEIGHT, h); 1403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); 1433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteRenderbuffers(1, &renderbufferID); 1443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1473c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RboInternalFormatCase : public ApiCase 1483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1493c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RboInternalFormatCase (Context& context, const char* name, const char* description) 1513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ApiCase(context, name, description) 1523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void test (void) 1563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint renderbufferID = 0; 1583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenRenderbuffers(1, &renderbufferID); 1593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID); 1603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_INTERNAL_FORMAT, GL_RGBA4); 1633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const GLenum requiredColorformats[] = 1663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GL_RGBA4, GL_RGB5_A1, GL_RGB565 1683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 1693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredColorformats); ++ndx) 1713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glRenderbufferStorage(GL_RENDERBUFFER, requiredColorformats[ndx], 1, 1); 1733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferParam(m_testCtx, *this, GL_RENDERBUFFER_INTERNAL_FORMAT, requiredColorformats[ndx]); 1763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteRenderbuffers(1, &renderbufferID); 1793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 1813c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1823c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RboComponentSizeColorCase : public ApiCase 1833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 1843c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 1853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RboComponentSizeColorCase (Context& context, const char* name, const char* description) 1863c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ApiCase(context, name, description) 1873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 1893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void test (void) 1913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 1923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint renderbufferID = 0; 1933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenRenderbuffers(1, &renderbufferID); 1943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID); 1953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 1973c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferComponentSize(m_testCtx, *this, 0, 0, 0, 0, 0, 0); 1983c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 1993c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2003c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const struct ColorFormat 2013c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2023c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum internalFormat; 2033c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int bitsR, bitsG, bitsB, bitsA; 2043c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } requiredColorFormats[] = 2053c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2063c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGBA4, 4, 4, 4, 4 }, 2073c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB5_A1, 5, 5, 5, 1 }, 2083c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_RGB565, 5, 6, 5, 0 }, 2093c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2103c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2113c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredColorFormats); ++ndx) 2123c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2133c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glRenderbufferStorage(GL_RENDERBUFFER, requiredColorFormats[ndx].internalFormat, 1, 1); 2143c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 2153c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2163c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferComponentSize(m_testCtx, *this, requiredColorFormats[ndx].bitsR, requiredColorFormats[ndx].bitsG, requiredColorFormats[ndx].bitsB, requiredColorFormats[ndx].bitsA, -1, -1); 2173c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2183c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2193c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteRenderbuffers(1, &renderbufferID); 2203c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2213c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2223c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2233c827367444ee418f129b2c238299f49d3264554Jarkko Poyryclass RboComponentSizeDepthCase : public ApiCase 2243c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2253c827367444ee418f129b2c238299f49d3264554Jarkko Poyrypublic: 2263c827367444ee418f129b2c238299f49d3264554Jarkko Poyry RboComponentSizeDepthCase (Context& context, const char* name, const char* description) 2273c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : ApiCase(context, name, description) 2283c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2293c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2303c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2313c827367444ee418f129b2c238299f49d3264554Jarkko Poyry void test (void) 2323c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2333c827367444ee418f129b2c238299f49d3264554Jarkko Poyry using tcu::TestLog; 2343c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2353c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLuint renderbufferID = 0; 2363c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGenRenderbuffers(1, &renderbufferID); 2373c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID); 2383c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 2393c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2403c827367444ee418f129b2c238299f49d3264554Jarkko Poyry const struct DepthFormat 2413c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2423c827367444ee418f129b2c238299f49d3264554Jarkko Poyry GLenum internalFormat; 2433c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int dbits; 2443c827367444ee418f129b2c238299f49d3264554Jarkko Poyry int sbits; 2453c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } requiredDepthFormats[] = 2463c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2473c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { GL_DEPTH_COMPONENT16, 16, 0 }, 2483c827367444ee418f129b2c238299f49d3264554Jarkko Poyry }; 2493c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2503c827367444ee418f129b2c238299f49d3264554Jarkko Poyry for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredDepthFormats); ++ndx) 2513c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2523c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glRenderbufferStorage(GL_RENDERBUFFER, requiredDepthFormats[ndx].internalFormat, 1, 1); 2533c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 2543c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2553c827367444ee418f129b2c238299f49d3264554Jarkko Poyry checkRenderbufferComponentSize(m_testCtx, *this, -1, -1, -1, -1, requiredDepthFormats[ndx].dbits, requiredDepthFormats[ndx].sbits); 2563c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2573c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2583c827367444ee418f129b2c238299f49d3264554Jarkko Poyry // STENCIL_INDEX8 is required, in that case sBits >= 8 2593c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2603c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 1, 1); 2613c827367444ee418f129b2c238299f49d3264554Jarkko Poyry expectError(GL_NO_ERROR); 2623c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2633c827367444ee418f129b2c238299f49d3264554Jarkko Poyry StateQueryMemoryWriteGuard<GLint> state; 2643c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_STENCIL_SIZE, &state); 2653c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2663c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (state.verifyValidity(m_testCtx) && state < 8) 2673c827367444ee418f129b2c238299f49d3264554Jarkko Poyry { 2683c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.getLog() << TestLog::Message << "// ERROR: Expected greater or equal to 8; got " << state << TestLog::EndMessage; 2693c827367444ee418f129b2c238299f49d3264554Jarkko Poyry if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS) 2703c827367444ee418f129b2c238299f49d3264554Jarkko Poyry m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value"); 2713c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2723c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2733c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2743c827367444ee418f129b2c238299f49d3264554Jarkko Poyry glDeleteRenderbuffers(1, &renderbufferID); 2753c827367444ee418f129b2c238299f49d3264554Jarkko Poyry } 2763c827367444ee418f129b2c238299f49d3264554Jarkko Poyry}; 2773c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2783c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // anonymous 2793c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2803c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2813c827367444ee418f129b2c238299f49d3264554Jarkko PoyryRboStateQueryTests::RboStateQueryTests (Context& context) 2823c827367444ee418f129b2c238299f49d3264554Jarkko Poyry : TestCaseGroup(context, "rbo", "Rbo State Query tests") 2833c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2843c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2853c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2863c827367444ee418f129b2c238299f49d3264554Jarkko Poyryvoid RboStateQueryTests::init (void) 2873c827367444ee418f129b2c238299f49d3264554Jarkko Poyry{ 2883c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new RboSizeCase (m_context, "renderbuffer_size", "RENDERBUFFER_WIDTH and RENDERBUFFER_HEIGHT")); 2893c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new RboInternalFormatCase (m_context, "renderbuffer_internal_format", "RENDERBUFFER_INTERNAL_FORMAT")); 2903c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new RboComponentSizeColorCase (m_context, "renderbuffer_component_size_color", "RENDERBUFFER_x_SIZE")); 2913c827367444ee418f129b2c238299f49d3264554Jarkko Poyry addChild(new RboComponentSizeDepthCase (m_context, "renderbuffer_component_size_depth", "RENDERBUFFER_x_SIZE")); 2923c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} 2933c827367444ee418f129b2c238299f49d3264554Jarkko Poyry 2943c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // Functional 2953c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // gles2 2963c827367444ee418f129b2c238299f49d3264554Jarkko Poyry} // deqp 297