1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite 3e5c31af7Sopenharmony_ci * ----------------------------- 4e5c31af7Sopenharmony_ci * 5e5c31af7Sopenharmony_ci * Copyright (c) 2014-2016 The Khronos Group Inc. 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 10e5c31af7Sopenharmony_ci * 11e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 17e5c31af7Sopenharmony_ci * limitations under the License. 18e5c31af7Sopenharmony_ci * 19e5c31af7Sopenharmony_ci */ /*! 20e5c31af7Sopenharmony_ci * \file 21e5c31af7Sopenharmony_ci * \brief 22e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci/*! 25e5c31af7Sopenharmony_ci * \file esextcTextureBufferParameters.cpp 26e5c31af7Sopenharmony_ci * \brief Texture Buffer GetTexLevelParameter and GetIntegerv test (Test 6) 27e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/ 28e5c31af7Sopenharmony_ci 29e5c31af7Sopenharmony_ci#include "esextcTextureBufferParameters.hpp" 30e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp" 31e5c31af7Sopenharmony_ci#include "gluDefs.hpp" 32e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 33e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 34e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 35e5c31af7Sopenharmony_ci#include <stddef.h> 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_cinamespace glcts 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_ciconst glw::GLuint TextureBufferParameters::m_n_texels_phase_one = 128; 41e5c31af7Sopenharmony_ciconst glw::GLuint TextureBufferParameters::m_n_texels_phase_two = 256; 42e5c31af7Sopenharmony_ci 43e5c31af7Sopenharmony_ci/** Constructor 44e5c31af7Sopenharmony_ci * 45e5c31af7Sopenharmony_ci * @param context Test context 46e5c31af7Sopenharmony_ci * @param name Test case's name 47e5c31af7Sopenharmony_ci * @param description Test case's description 48e5c31af7Sopenharmony_ci **/ 49e5c31af7Sopenharmony_ciTextureBufferParameters::TextureBufferParameters(Context& context, const ExtParameters& extParams, const char* name, 50e5c31af7Sopenharmony_ci const char* description) 51e5c31af7Sopenharmony_ci : TestCaseBase(context, extParams, name, description), m_tbo_id(0), m_to_id(0) 52e5c31af7Sopenharmony_ci{ 53e5c31af7Sopenharmony_ci} 54e5c31af7Sopenharmony_ci 55e5c31af7Sopenharmony_ci/** Initializes all GLES objects and reference values for the test. */ 56e5c31af7Sopenharmony_civoid TextureBufferParameters::initTest(void) 57e5c31af7Sopenharmony_ci{ 58e5c31af7Sopenharmony_ci /* Skip if required extensions are not supported. */ 59e5c31af7Sopenharmony_ci if (!m_is_texture_buffer_supported) 60e5c31af7Sopenharmony_ci { 61e5c31af7Sopenharmony_ci throw tcu::NotSupportedError(TEXTURE_BUFFER_EXTENSION_NOT_SUPPORTED, "", __FILE__, __LINE__); 62e5c31af7Sopenharmony_ci } 63e5c31af7Sopenharmony_ci 64e5c31af7Sopenharmony_ci m_internal_formats[GL_R8] = sizeof(glw::GLubyte) * 1 /* components */; 65e5c31af7Sopenharmony_ci m_internal_formats[GL_R16F] = sizeof(glw::GLhalf) * 1 /* components */; 66e5c31af7Sopenharmony_ci m_internal_formats[GL_R32F] = sizeof(glw::GLfloat) * 1 /* components */; 67e5c31af7Sopenharmony_ci m_internal_formats[GL_R8I] = sizeof(glw::GLbyte) * 1 /* components */; 68e5c31af7Sopenharmony_ci m_internal_formats[GL_R16I] = sizeof(glw::GLshort) * 1 /* components */; 69e5c31af7Sopenharmony_ci m_internal_formats[GL_R32I] = sizeof(glw::GLint) * 1 /* components */; 70e5c31af7Sopenharmony_ci m_internal_formats[GL_R8UI] = sizeof(glw::GLubyte) * 1 /* components */; 71e5c31af7Sopenharmony_ci m_internal_formats[GL_R16UI] = sizeof(glw::GLushort) * 1 /* components */; 72e5c31af7Sopenharmony_ci m_internal_formats[GL_R32UI] = sizeof(glw::GLuint) * 1 /* components */; 73e5c31af7Sopenharmony_ci m_internal_formats[GL_RG8] = sizeof(glw::GLubyte) * 2 /* components */; 74e5c31af7Sopenharmony_ci m_internal_formats[GL_RG16F] = sizeof(glw::GLhalf) * 2 /* components */; 75e5c31af7Sopenharmony_ci m_internal_formats[GL_RG32F] = sizeof(glw::GLfloat) * 2 /* components */; 76e5c31af7Sopenharmony_ci m_internal_formats[GL_RG8I] = sizeof(glw::GLbyte) * 2 /* components */; 77e5c31af7Sopenharmony_ci m_internal_formats[GL_RG16I] = sizeof(glw::GLshort) * 2 /* components */; 78e5c31af7Sopenharmony_ci m_internal_formats[GL_RG32I] = sizeof(glw::GLint) * 2 /* components */; 79e5c31af7Sopenharmony_ci m_internal_formats[GL_RG8UI] = sizeof(glw::GLubyte) * 2 /* components */; 80e5c31af7Sopenharmony_ci m_internal_formats[GL_RG16UI] = sizeof(glw::GLushort) * 2 /* components */; 81e5c31af7Sopenharmony_ci m_internal_formats[GL_RG32UI] = sizeof(glw::GLuint) * 2 /* components */; 82e5c31af7Sopenharmony_ci m_internal_formats[GL_RGB32F] = sizeof(glw::GLfloat) * 3 /* components */; 83e5c31af7Sopenharmony_ci m_internal_formats[GL_RGB32I] = sizeof(glw::GLint) * 3 /* components */; 84e5c31af7Sopenharmony_ci m_internal_formats[GL_RGB32UI] = sizeof(glw::GLuint) * 3 /* components */; 85e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA8] = sizeof(glw::GLubyte) * 4 /* components */; 86e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA16F] = sizeof(glw::GLhalf) * 4 /* components */; 87e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA32F] = sizeof(glw::GLfloat) * 4 /* components */; 88e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA8I] = sizeof(glw::GLbyte) * 4 /* components */; 89e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA16I] = sizeof(glw::GLshort) * 4 /* components */; 90e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA32I] = sizeof(glw::GLint) * 4 /* components */; 91e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA8UI] = sizeof(glw::GLubyte) * 4 /* components */; 92e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA16UI] = sizeof(glw::GLushort) * 4 /* components */; 93e5c31af7Sopenharmony_ci m_internal_formats[GL_RGBA32UI] = sizeof(glw::GLuint) * 4 /* components */; 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 96e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 97e5c31af7Sopenharmony_ci 98e5c31af7Sopenharmony_ci gl.genTextures(1, &m_to_id); 99e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not generate texture object!"); 100e5c31af7Sopenharmony_ci 101e5c31af7Sopenharmony_ci gl.bindTexture(m_glExtTokens.TEXTURE_BUFFER, m_to_id); 102e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not bind texture object!"); 103e5c31af7Sopenharmony_ci 104e5c31af7Sopenharmony_ci gl.genBuffers(1, &m_tbo_id); 105e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not generate buffer object!"); 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ci gl.bindBuffer(m_glExtTokens.TEXTURE_BUFFER, m_tbo_id); 108e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not bind buffer object!"); 109e5c31af7Sopenharmony_ci} 110e5c31af7Sopenharmony_ci 111e5c31af7Sopenharmony_ci/** Deinitializes GLES objects created during the test */ 112e5c31af7Sopenharmony_civoid TextureBufferParameters::deinit(void) 113e5c31af7Sopenharmony_ci{ 114e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 115e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 116e5c31af7Sopenharmony_ci 117e5c31af7Sopenharmony_ci /* Reset GLES state */ 118e5c31af7Sopenharmony_ci gl.bindTexture(m_glExtTokens.TEXTURE_BUFFER, 0); 119e5c31af7Sopenharmony_ci gl.bindBuffer(m_glExtTokens.TEXTURE_BUFFER, 0); 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ci /* Delete GLEs objects */ 122e5c31af7Sopenharmony_ci if (m_to_id != 0) 123e5c31af7Sopenharmony_ci { 124e5c31af7Sopenharmony_ci gl.deleteTextures(1, &m_to_id); 125e5c31af7Sopenharmony_ci m_to_id = 0; 126e5c31af7Sopenharmony_ci } 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ci if (m_tbo_id != 0) 129e5c31af7Sopenharmony_ci { 130e5c31af7Sopenharmony_ci gl.deleteBuffers(1, &m_tbo_id); 131e5c31af7Sopenharmony_ci m_tbo_id = 0; 132e5c31af7Sopenharmony_ci } 133e5c31af7Sopenharmony_ci 134e5c31af7Sopenharmony_ci /* Deinitialize base class */ 135e5c31af7Sopenharmony_ci TestCaseBase::deinit(); 136e5c31af7Sopenharmony_ci} 137e5c31af7Sopenharmony_ci 138e5c31af7Sopenharmony_ci/** Executes the test. 139e5c31af7Sopenharmony_ci * 140e5c31af7Sopenharmony_ci * Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise. 141e5c31af7Sopenharmony_ci * 142e5c31af7Sopenharmony_ci * Note the function throws exception should an error occur! 143e5c31af7Sopenharmony_ci * 144e5c31af7Sopenharmony_ci * @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again. 145e5c31af7Sopenharmony_ci **/ 146e5c31af7Sopenharmony_citcu::TestNode::IterateResult TextureBufferParameters::iterate(void) 147e5c31af7Sopenharmony_ci{ 148e5c31af7Sopenharmony_ci /* Initialization */ 149e5c31af7Sopenharmony_ci initTest(); 150e5c31af7Sopenharmony_ci 151e5c31af7Sopenharmony_ci /* Retrieve GLEs entry points. */ 152e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 155e5c31af7Sopenharmony_ci 156e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BINDING_BUFFER_EXT */ 157e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferBinding(m_to_id); 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_BINDING_EXT */ 160e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBindingBuffer(m_tbo_id); 161e5c31af7Sopenharmony_ci 162e5c31af7Sopenharmony_ci /* For each GL_TEXTURE_INTERNAL_FORMAT */ 163e5c31af7Sopenharmony_ci for (InternalFormatsMap::iterator iter = m_internal_formats.begin(); iter != m_internal_formats.end(); ++iter) 164e5c31af7Sopenharmony_ci { 165e5c31af7Sopenharmony_ci std::vector<glw::GLubyte> data_phase_one(m_n_texels_phase_one * iter->second, 0); 166e5c31af7Sopenharmony_ci gl.bufferData(m_glExtTokens.TEXTURE_BUFFER, m_n_texels_phase_one * iter->second, &data_phase_one[0], 167e5c31af7Sopenharmony_ci GL_STATIC_READ); 168e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not allocate buffer object's data store!"); 169e5c31af7Sopenharmony_ci 170e5c31af7Sopenharmony_ci gl.texBuffer(m_glExtTokens.TEXTURE_BUFFER, iter->first, m_tbo_id); 171e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not set buffer object as data source for texture buffer!"); 172e5c31af7Sopenharmony_ci 173e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT */ 174e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferDataStoreBinding(m_tbo_id); 175e5c31af7Sopenharmony_ci 176e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_INTERNAL_FORMAT */ 177e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureInternalFormat(iter->first); 178e5c31af7Sopenharmony_ci 179e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_OFFSET_EXT */ 180e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferOffset(0); 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_ci /* Ckeck GL_TEXTURE_BUFFER_SIZE_EXT */ 183e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferSize(m_n_texels_phase_one * iter->second); 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ci /* Ckeck wrong lod level */ 186e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureInvalidLevel(); 187e5c31af7Sopenharmony_ci 188e5c31af7Sopenharmony_ci /* Get texture buffer offset alignment */ 189e5c31af7Sopenharmony_ci glw::GLint offset_alignment = 0; 190e5c31af7Sopenharmony_ci gl.getIntegerv(m_glExtTokens.TEXTURE_BUFFER_OFFSET_ALIGNMENT, &offset_alignment); 191e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not get texture buffer offset alignment!"); 192e5c31af7Sopenharmony_ci 193e5c31af7Sopenharmony_ci /* Resize buffer object */ 194e5c31af7Sopenharmony_ci std::vector<glw::GLubyte> data_phase_two(m_n_texels_phase_two * iter->second + offset_alignment, 0); 195e5c31af7Sopenharmony_ci gl.bufferData(m_glExtTokens.TEXTURE_BUFFER, m_n_texels_phase_two * iter->second + offset_alignment, 196e5c31af7Sopenharmony_ci &data_phase_two[0], GL_STATIC_READ); 197e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not allocate buffer object's data store!"); 198e5c31af7Sopenharmony_ci 199e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_OFFSET_EXT */ 200e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferOffset(0); 201e5c31af7Sopenharmony_ci 202e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_SIZE_EXT */ 203e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferSize(m_n_texels_phase_two * iter->second + offset_alignment); 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ci gl.texBufferRange(m_glExtTokens.TEXTURE_BUFFER, iter->first, m_tbo_id, offset_alignment, 206e5c31af7Sopenharmony_ci m_n_texels_phase_two * iter->second); 207e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not set buffer object as data source for texture buffer!"); 208e5c31af7Sopenharmony_ci 209e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_OFFSET_EXT */ 210e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferOffset(offset_alignment); 211e5c31af7Sopenharmony_ci 212e5c31af7Sopenharmony_ci /* Check GL_TEXTURE_BUFFER_SIZE_EXT */ 213e5c31af7Sopenharmony_ci test_passed = test_passed && queryTextureBufferSize(m_n_texels_phase_two * iter->second); 214e5c31af7Sopenharmony_ci 215e5c31af7Sopenharmony_ci gl.texBuffer(m_glExtTokens.TEXTURE_BUFFER, iter->first, 0); 216e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not reset buffer object binding!"); 217e5c31af7Sopenharmony_ci } 218e5c31af7Sopenharmony_ci 219e5c31af7Sopenharmony_ci if (test_passed) 220e5c31af7Sopenharmony_ci { 221e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 222e5c31af7Sopenharmony_ci } 223e5c31af7Sopenharmony_ci else 224e5c31af7Sopenharmony_ci { 225e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 226e5c31af7Sopenharmony_ci } 227e5c31af7Sopenharmony_ci 228e5c31af7Sopenharmony_ci return STOP; 229e5c31af7Sopenharmony_ci} 230e5c31af7Sopenharmony_ci 231e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_BUFFER_BINDING_EXT and compare with the expected value. 232e5c31af7Sopenharmony_ci * 233e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 234e5c31af7Sopenharmony_ci * 235e5c31af7Sopenharmony_ci * @param expected Expected value used for comparison. 236e5c31af7Sopenharmony_ci * 237e5c31af7Sopenharmony_ci * @return true if the comparison has passed, 238e5c31af7Sopenharmony_ci * false if the comparison has failed. 239e5c31af7Sopenharmony_ci **/ 240e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureBindingBuffer(glw::GLint expected) 241e5c31af7Sopenharmony_ci{ 242e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 243e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 244e5c31af7Sopenharmony_ci 245e5c31af7Sopenharmony_ci glw::GLint result = -1; 246e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 247e5c31af7Sopenharmony_ci 248e5c31af7Sopenharmony_ci gl.getIntegerv(m_glExtTokens.TEXTURE_BUFFER_BINDING, &result); 249e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query value of GL_TEXTURE_BUFFER_BINDING_EXT"); 250e5c31af7Sopenharmony_ci 251e5c31af7Sopenharmony_ci if (result != expected) 252e5c31af7Sopenharmony_ci { 253e5c31af7Sopenharmony_ci test_passed = false; 254e5c31af7Sopenharmony_ci 255e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message << "glGetIntegerv(GL_TEXTURE_BINDING_BUFFER_EXT) returned " 256e5c31af7Sopenharmony_ci << result << " which is not equal to expected buffer object id == " << expected << ".\n" 257e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 258e5c31af7Sopenharmony_ci } 259e5c31af7Sopenharmony_ci 260e5c31af7Sopenharmony_ci return test_passed; 261e5c31af7Sopenharmony_ci} 262e5c31af7Sopenharmony_ci 263e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_BINDING_BUFFER_EXT and compare with the expected value. 264e5c31af7Sopenharmony_ci * 265e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 266e5c31af7Sopenharmony_ci * 267e5c31af7Sopenharmony_ci * @param expected Expected value used for comparison. 268e5c31af7Sopenharmony_ci * 269e5c31af7Sopenharmony_ci * @return true if the comparison has passed, 270e5c31af7Sopenharmony_ci * false if the comparison has failed. 271e5c31af7Sopenharmony_ci **/ 272e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureBufferBinding(glw::GLint expected) 273e5c31af7Sopenharmony_ci{ 274e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 275e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 276e5c31af7Sopenharmony_ci 277e5c31af7Sopenharmony_ci glw::GLint result = -1; 278e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 279e5c31af7Sopenharmony_ci 280e5c31af7Sopenharmony_ci gl.getIntegerv(m_glExtTokens.TEXTURE_BINDING_BUFFER, &result); 281e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query value of GL_TEXTURE_BINDING_BUFFER_EXT"); 282e5c31af7Sopenharmony_ci 283e5c31af7Sopenharmony_ci if (result != expected) 284e5c31af7Sopenharmony_ci { 285e5c31af7Sopenharmony_ci test_passed = false; 286e5c31af7Sopenharmony_ci 287e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message << "glGetIntegerv(GL_TEXTURE_BUFFER_BINDING_EXT) returned " 288e5c31af7Sopenharmony_ci << result << " which is not equal to expected texture object id == " << expected << ".\n" 289e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 290e5c31af7Sopenharmony_ci } 291e5c31af7Sopenharmony_ci 292e5c31af7Sopenharmony_ci return test_passed; 293e5c31af7Sopenharmony_ci} 294e5c31af7Sopenharmony_ci 295e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT and compare with the expected value. 296e5c31af7Sopenharmony_ci * 297e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 298e5c31af7Sopenharmony_ci * 299e5c31af7Sopenharmony_ci * @param expected Expected value used for comparison. 300e5c31af7Sopenharmony_ci * 301e5c31af7Sopenharmony_ci * @return true if the comparison has passed, 302e5c31af7Sopenharmony_ci * false if the comparison has failed. 303e5c31af7Sopenharmony_ci **/ 304e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureBufferDataStoreBinding(glw::GLint expected) 305e5c31af7Sopenharmony_ci{ 306e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 307e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 308e5c31af7Sopenharmony_ci 309e5c31af7Sopenharmony_ci glw::GLint result = -1; 310e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 311e5c31af7Sopenharmony_ci 312e5c31af7Sopenharmony_ci gl.getTexLevelParameteriv(m_glExtTokens.TEXTURE_BUFFER, 0, m_glExtTokens.TEXTURE_BUFFER_DATA_STORE_BINDING, 313e5c31af7Sopenharmony_ci &result); 314e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query value of GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT"); 315e5c31af7Sopenharmony_ci 316e5c31af7Sopenharmony_ci if (result != expected) 317e5c31af7Sopenharmony_ci { 318e5c31af7Sopenharmony_ci test_passed = false; 319e5c31af7Sopenharmony_ci 320e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message 321e5c31af7Sopenharmony_ci << "glGetTexLevelParameteriv(GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT) returned " << result 322e5c31af7Sopenharmony_ci << " which is not equal to expected buffer object id == " << expected << ".\n" 323e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 324e5c31af7Sopenharmony_ci } 325e5c31af7Sopenharmony_ci 326e5c31af7Sopenharmony_ci return test_passed; 327e5c31af7Sopenharmony_ci} 328e5c31af7Sopenharmony_ci 329e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_BUFFER_OFFSET_EXT and compare with the expected value. 330e5c31af7Sopenharmony_ci * 331e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 332e5c31af7Sopenharmony_ci * 333e5c31af7Sopenharmony_ci * @param expected Expected value used for comparison. 334e5c31af7Sopenharmony_ci * 335e5c31af7Sopenharmony_ci * @return true if the comparison has passed, 336e5c31af7Sopenharmony_ci * false if the comparison has failed. 337e5c31af7Sopenharmony_ci **/ 338e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureBufferOffset(glw::GLint expected) 339e5c31af7Sopenharmony_ci{ 340e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 341e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 342e5c31af7Sopenharmony_ci 343e5c31af7Sopenharmony_ci glw::GLint result = -1; 344e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 345e5c31af7Sopenharmony_ci 346e5c31af7Sopenharmony_ci gl.getTexLevelParameteriv(m_glExtTokens.TEXTURE_BUFFER, 0, m_glExtTokens.TEXTURE_BUFFER_OFFSET, &result); 347e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query value of GL_TEXTURE_BUFFER_OFFSET_EXT"); 348e5c31af7Sopenharmony_ci 349e5c31af7Sopenharmony_ci if (result != expected) 350e5c31af7Sopenharmony_ci { 351e5c31af7Sopenharmony_ci test_passed = false; 352e5c31af7Sopenharmony_ci 353e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message 354e5c31af7Sopenharmony_ci << "glGetTexLevelParameteriv(GL_TEXTURE_BUFFER_OFFSET_EXT) returned " << result 355e5c31af7Sopenharmony_ci << " which is not equal to expected offset " << expected << ".\n" 356e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 357e5c31af7Sopenharmony_ci } 358e5c31af7Sopenharmony_ci 359e5c31af7Sopenharmony_ci return test_passed; 360e5c31af7Sopenharmony_ci} 361e5c31af7Sopenharmony_ci 362e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_BUFFER_SIZE_EXT and compare with the expected value. 363e5c31af7Sopenharmony_ci * 364e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 365e5c31af7Sopenharmony_ci * 366e5c31af7Sopenharmony_ci * @param expected Expected value used for comparison. 367e5c31af7Sopenharmony_ci * 368e5c31af7Sopenharmony_ci * @return true if the comparison has passed, 369e5c31af7Sopenharmony_ci * false if the comparison has failed. 370e5c31af7Sopenharmony_ci **/ 371e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureBufferSize(glw::GLint expected) 372e5c31af7Sopenharmony_ci{ 373e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 374e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 375e5c31af7Sopenharmony_ci 376e5c31af7Sopenharmony_ci glw::GLint result = -1; 377e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 378e5c31af7Sopenharmony_ci 379e5c31af7Sopenharmony_ci gl.getTexLevelParameteriv(m_glExtTokens.TEXTURE_BUFFER, 0, m_glExtTokens.TEXTURE_BUFFER_SIZE, &result); 380e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query value of GL_TEXTURE_BUFFER_SIZE_EXT"); 381e5c31af7Sopenharmony_ci 382e5c31af7Sopenharmony_ci if (result != expected) 383e5c31af7Sopenharmony_ci { 384e5c31af7Sopenharmony_ci test_passed = false; 385e5c31af7Sopenharmony_ci 386e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv(GL_TEXTURE_BUFFER_SIZE_EXT) returned " 387e5c31af7Sopenharmony_ci << result << " which is not equal to expected size " << expected << ".\n" 388e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 389e5c31af7Sopenharmony_ci } 390e5c31af7Sopenharmony_ci 391e5c31af7Sopenharmony_ci return test_passed; 392e5c31af7Sopenharmony_ci} 393e5c31af7Sopenharmony_ci 394e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_INTERNAL_FORMAT and compare with the expected value. 395e5c31af7Sopenharmony_ci * 396e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 397e5c31af7Sopenharmony_ci * 398e5c31af7Sopenharmony_ci * @param expected Expected value used for comparison. 399e5c31af7Sopenharmony_ci * 400e5c31af7Sopenharmony_ci * @return true if the comparison has passed, 401e5c31af7Sopenharmony_ci * false if the comparison has failed. 402e5c31af7Sopenharmony_ci **/ 403e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureInternalFormat(glw::GLint expected) 404e5c31af7Sopenharmony_ci{ 405e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 406e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 407e5c31af7Sopenharmony_ci 408e5c31af7Sopenharmony_ci glw::GLint result = -1; 409e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 410e5c31af7Sopenharmony_ci 411e5c31af7Sopenharmony_ci gl.getTexLevelParameteriv(m_glExtTokens.TEXTURE_BUFFER, 0, GL_TEXTURE_INTERNAL_FORMAT, &result); 412e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Could not query value of GL_TEXTURE_INTERNAL_FORMAT"); 413e5c31af7Sopenharmony_ci 414e5c31af7Sopenharmony_ci if (result != expected) 415e5c31af7Sopenharmony_ci { 416e5c31af7Sopenharmony_ci test_passed = false; 417e5c31af7Sopenharmony_ci 418e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message << "glGetTexLevelParameteriv(GL_TEXTURE_INTERNAL_FORMAT) returned " 419e5c31af7Sopenharmony_ci << result << " which is not equal to expected internal format " << expected 420e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 421e5c31af7Sopenharmony_ci } 422e5c31af7Sopenharmony_ci 423e5c31af7Sopenharmony_ci return test_passed; 424e5c31af7Sopenharmony_ci} 425e5c31af7Sopenharmony_ci 426e5c31af7Sopenharmony_ci/** Query GL_TEXTURE_BUFFER_SIZE_EXT with invalid texture level 427e5c31af7Sopenharmony_ci * and checks for GL_INVALID_VALUE error. 428e5c31af7Sopenharmony_ci * 429e5c31af7Sopenharmony_ci * Note - the function throws exception should an error occur! 430e5c31af7Sopenharmony_ci * 431e5c31af7Sopenharmony_ci * @return true if the GL_INVALID_VALUE error was generated, 432e5c31af7Sopenharmony_ci * false if the GL_INVALID_VALUE error was not generated. 433e5c31af7Sopenharmony_ci **/ 434e5c31af7Sopenharmony_ciglw::GLboolean TextureBufferParameters::queryTextureInvalidLevel() 435e5c31af7Sopenharmony_ci{ 436e5c31af7Sopenharmony_ci /* Retrieve GLES entry points. */ 437e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 438e5c31af7Sopenharmony_ci 439e5c31af7Sopenharmony_ci glw::GLint result = -1; 440e5c31af7Sopenharmony_ci glw::GLboolean test_passed = true; 441e5c31af7Sopenharmony_ci 442e5c31af7Sopenharmony_ci gl.getTexLevelParameteriv(m_glExtTokens.TEXTURE_BUFFER, 1, m_glExtTokens.TEXTURE_BUFFER_SIZE, &result); 443e5c31af7Sopenharmony_ci glw::GLenum error_code = gl.getError(); 444e5c31af7Sopenharmony_ci 445e5c31af7Sopenharmony_ci if (error_code != GL_INVALID_VALUE) 446e5c31af7Sopenharmony_ci { 447e5c31af7Sopenharmony_ci test_passed = false; 448e5c31af7Sopenharmony_ci 449e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message 450e5c31af7Sopenharmony_ci << "glGetTexLevelParameteriv() called for GL_TEXTURE_BUFFER_EXT texture target " 451e5c31af7Sopenharmony_ci << "with lod level different than 0 did not generate an GL_INVALID_VALUE error.\n" 452e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 453e5c31af7Sopenharmony_ci } 454e5c31af7Sopenharmony_ci 455e5c31af7Sopenharmony_ci return test_passed; 456e5c31af7Sopenharmony_ci} 457e5c31af7Sopenharmony_ci 458e5c31af7Sopenharmony_ci} /* namespace glcts */ 459