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#include "esextcGeometryShaderBlitting.hpp" 25e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp" 26e5c31af7Sopenharmony_ci#include "gluDefs.hpp" 27e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 28e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 29e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 30e5c31af7Sopenharmony_ci#include <cstring> 31e5c31af7Sopenharmony_ci 32e5c31af7Sopenharmony_ci/* 3d texture layers count */ 33e5c31af7Sopenharmony_ci#define TEXTURE_DEPTH (4) 34e5c31af7Sopenharmony_ci/* 3d texture width */ 35e5c31af7Sopenharmony_ci#define TEXTURE_WIDTH (4) 36e5c31af7Sopenharmony_ci/* 3d texture height */ 37e5c31af7Sopenharmony_ci#define TEXTURE_HEIGHT (4) 38e5c31af7Sopenharmony_ci/* texture texel components */ 39e5c31af7Sopenharmony_ci#define TEXTURE_TEXEL_COMPONENTS (4) 40e5c31af7Sopenharmony_ci 41e5c31af7Sopenharmony_cinamespace glcts 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 desricption 48e5c31af7Sopenharmony_ci **/ 49e5c31af7Sopenharmony_ciGeometryShaderBlitting::GeometryShaderBlitting(Context& context, const ExtParameters& extParams, const char* name, 50e5c31af7Sopenharmony_ci const char* description) 51e5c31af7Sopenharmony_ci : TestCaseBase(context, extParams, name, description) 52e5c31af7Sopenharmony_ci , m_draw_fbo_completeness(GL_NONE) 53e5c31af7Sopenharmony_ci , m_read_fbo_completeness(GL_NONE) 54e5c31af7Sopenharmony_ci , m_fbo_draw_id(0) 55e5c31af7Sopenharmony_ci , m_fbo_read_id(0) 56e5c31af7Sopenharmony_ci , m_to_draw(0) 57e5c31af7Sopenharmony_ci , m_to_read(0) 58e5c31af7Sopenharmony_ci , m_vao_id(0) 59e5c31af7Sopenharmony_ci{ 60e5c31af7Sopenharmony_ci /* Left blank on purpose */ 61e5c31af7Sopenharmony_ci} 62e5c31af7Sopenharmony_ci 63e5c31af7Sopenharmony_ci/** Executes the test. 64e5c31af7Sopenharmony_ci * Sets the test result to QP_TEST_RESULT_FAIL if the test failed, QP_TEST_RESULT_PASS otherwise. 65e5c31af7Sopenharmony_ci * @return STOP if the test has finished, CONTINUE to indicate iterate should be called once again. 66e5c31af7Sopenharmony_ci * Note the function throws exception should an error occur! 67e5c31af7Sopenharmony_ci **/ 68e5c31af7Sopenharmony_citcu::TestNode::IterateResult GeometryShaderBlitting::iterate(void) 69e5c31af7Sopenharmony_ci{ 70e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 71e5c31af7Sopenharmony_ci 72e5c31af7Sopenharmony_ci if (!m_is_geometry_shader_extension_supported) 73e5c31af7Sopenharmony_ci { 74e5c31af7Sopenharmony_ci throw tcu::NotSupportedError(GEOMETRY_SHADER_EXTENSION_NOT_SUPPORTED, "", __FILE__, __LINE__); 75e5c31af7Sopenharmony_ci } 76e5c31af7Sopenharmony_ci 77e5c31af7Sopenharmony_ci /* Generate and bind a vertex array object */ 78e5c31af7Sopenharmony_ci gl.genVertexArrays(1, &m_vao_id); 79e5c31af7Sopenharmony_ci gl.bindVertexArray(m_vao_id); 80e5c31af7Sopenharmony_ci 81e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up vertex array object"); 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ci /* Generate texture objects */ 84e5c31af7Sopenharmony_ci gl.genTextures(1, &m_to_draw); 85e5c31af7Sopenharmony_ci gl.genTextures(1, &m_to_read); 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error generating texture objects"); 88e5c31af7Sopenharmony_ci 89e5c31af7Sopenharmony_ci /* Generate framebuffer objects */ 90e5c31af7Sopenharmony_ci gl.genFramebuffers(1, &m_fbo_draw_id); 91e5c31af7Sopenharmony_ci gl.genFramebuffers(1, &m_fbo_read_id); 92e5c31af7Sopenharmony_ci 93e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up framebuffer objects"); 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci /* Configure texture storage */ 96e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_3D, m_to_draw); 97e5c31af7Sopenharmony_ci gl.texImage3D(GL_TEXTURE_3D, 0 /* level */, GL_RGBA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_DEPTH, 0 /* border */, 98e5c31af7Sopenharmony_ci GL_RGBA, GL_UNSIGNED_BYTE, NULL); 99e5c31af7Sopenharmony_ci 100e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up texture objects"); 101e5c31af7Sopenharmony_ci 102e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_3D, m_to_read); 103e5c31af7Sopenharmony_ci gl.texImage3D(GL_TEXTURE_3D, 0 /* level */, GL_RGBA8, TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_DEPTH, 0 /* border */, 104e5c31af7Sopenharmony_ci GL_RGBA, GL_UNSIGNED_BYTE, NULL); 105e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up texture objects"); 106e5c31af7Sopenharmony_ci 107e5c31af7Sopenharmony_ci unsigned char layer_source1[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 108e5c31af7Sopenharmony_ci unsigned char layer_source2[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 109e5c31af7Sopenharmony_ci unsigned char layer_source3[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 110e5c31af7Sopenharmony_ci unsigned char layer_source4[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 111e5c31af7Sopenharmony_ci unsigned char layer_target[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 112e5c31af7Sopenharmony_ci unsigned char result_data[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_ci memset(layer_source1, 0, sizeof(layer_source1)); 115e5c31af7Sopenharmony_ci memset(layer_source2, 0, sizeof(layer_source2)); 116e5c31af7Sopenharmony_ci memset(layer_source3, 0, sizeof(layer_source3)); 117e5c31af7Sopenharmony_ci memset(layer_source4, 0, sizeof(layer_source4)); 118e5c31af7Sopenharmony_ci memset(layer_target, 0, sizeof(layer_target)); 119e5c31af7Sopenharmony_ci 120e5c31af7Sopenharmony_ci for (unsigned int n = 0; n < TEXTURE_WIDTH * TEXTURE_HEIGHT; ++n) 121e5c31af7Sopenharmony_ci { 122e5c31af7Sopenharmony_ci layer_source1[n * TEXTURE_TEXEL_COMPONENTS + 0] = 255; 123e5c31af7Sopenharmony_ci layer_source2[n * TEXTURE_TEXEL_COMPONENTS + 1] = 255; 124e5c31af7Sopenharmony_ci layer_source3[n * TEXTURE_TEXEL_COMPONENTS + 2] = 255; 125e5c31af7Sopenharmony_ci layer_source4[n * TEXTURE_TEXEL_COMPONENTS + 3] = 255; 126e5c31af7Sopenharmony_ci } /* for (all pixels) */ 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ci /* Set up draw FBO */ 129e5c31af7Sopenharmony_ci setUpFramebuffersForRendering(m_fbo_draw_id, m_fbo_read_id, m_to_draw, m_to_read); 130e5c31af7Sopenharmony_ci 131e5c31af7Sopenharmony_ci /* Fill texture objects with data */ 132e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_3D, m_to_read); 133e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 0 /* layer */, TEXTURE_WIDTH, 134e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_source1); 135e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 1 /* layer */, TEXTURE_WIDTH, 136e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_source2); 137e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 2 /* layer */, TEXTURE_WIDTH, 138e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_source3); 139e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 3 /* layer */, TEXTURE_WIDTH, 140e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_source4); 141e5c31af7Sopenharmony_ci 142e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_3D, m_to_draw); 143e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 0 /* layer */, TEXTURE_WIDTH, 144e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_target); 145e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 1 /* layer */, TEXTURE_WIDTH, 146e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_target); 147e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 2 /* layer */, TEXTURE_WIDTH, 148e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_target); 149e5c31af7Sopenharmony_ci gl.texSubImage3D(GL_TEXTURE_3D, 0 /* level */, 0 /* xoffset */, 0 /* yoffset */, 3 /* layer */, TEXTURE_WIDTH, 150e5c31af7Sopenharmony_ci TEXTURE_HEIGHT, 1 /* depth */, GL_RGBA, GL_UNSIGNED_BYTE, layer_target); 151e5c31af7Sopenharmony_ci 152e5c31af7Sopenharmony_ci /* Check FB completeness */ 153e5c31af7Sopenharmony_ci m_draw_fbo_completeness = gl.checkFramebufferStatus(GL_DRAW_FRAMEBUFFER); 154e5c31af7Sopenharmony_ci m_read_fbo_completeness = gl.checkFramebufferStatus(GL_READ_FRAMEBUFFER); 155e5c31af7Sopenharmony_ci 156e5c31af7Sopenharmony_ci if (m_draw_fbo_completeness != GL_FRAMEBUFFER_COMPLETE) 157e5c31af7Sopenharmony_ci { 158e5c31af7Sopenharmony_ci TCU_FAIL("Draw framebuffer is reported as incomplete, though expected it to be complete"); 159e5c31af7Sopenharmony_ci } 160e5c31af7Sopenharmony_ci 161e5c31af7Sopenharmony_ci if (m_read_fbo_completeness != GL_FRAMEBUFFER_COMPLETE) 162e5c31af7Sopenharmony_ci { 163e5c31af7Sopenharmony_ci TCU_FAIL("Read framebuffer is reported as incomplete, though expected it to be complete"); 164e5c31af7Sopenharmony_ci } 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_ci /* Blit! */ 167e5c31af7Sopenharmony_ci gl.blitFramebuffer(0 /* srcX0 */, 0 /* srcY0 */, TEXTURE_WIDTH, TEXTURE_HEIGHT, 0 /* dstX0 */, 0 /* dstY0 */, 168e5c31af7Sopenharmony_ci TEXTURE_WIDTH, TEXTURE_HEIGHT, GL_COLOR_BUFFER_BIT, GL_NEAREST); 169e5c31af7Sopenharmony_ci 170e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error blitting"); 171e5c31af7Sopenharmony_ci 172e5c31af7Sopenharmony_ci for (unsigned int n = 0; n < TEXTURE_DEPTH /* layers */; ++n) 173e5c31af7Sopenharmony_ci { 174e5c31af7Sopenharmony_ci unsigned char expected_result_data[TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS]; 175e5c31af7Sopenharmony_ci memset(expected_result_data, 0, sizeof(expected_result_data)); 176e5c31af7Sopenharmony_ci 177e5c31af7Sopenharmony_ci if (n == 0) 178e5c31af7Sopenharmony_ci { 179e5c31af7Sopenharmony_ci memcpy(expected_result_data, layer_source1, sizeof(expected_result_data)); 180e5c31af7Sopenharmony_ci } 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_ci /* Set up read FBO */ 183e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_draw_id); 184e5c31af7Sopenharmony_ci 185e5c31af7Sopenharmony_ci gl.framebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_to_draw, 0, n); 186e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up FBOs setUpFramebuffersForReading"); 187e5c31af7Sopenharmony_ci 188e5c31af7Sopenharmony_ci /* Read the rendered data */ 189e5c31af7Sopenharmony_ci gl.readPixels(0 /* x */, 0 /* y */, TEXTURE_WIDTH, TEXTURE_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, result_data); 190e5c31af7Sopenharmony_ci 191e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Failed to read rendered pixel data"); 192e5c31af7Sopenharmony_ci 193e5c31af7Sopenharmony_ci /* Compare the rendered data with reference data */ 194e5c31af7Sopenharmony_ci for (unsigned int index = 0; index < TEXTURE_WIDTH * TEXTURE_HEIGHT * TEXTURE_TEXEL_COMPONENTS; 195e5c31af7Sopenharmony_ci index += TEXTURE_TEXEL_COMPONENTS) 196e5c31af7Sopenharmony_ci { 197e5c31af7Sopenharmony_ci if (memcmp(&expected_result_data[index], &result_data[index], TEXTURE_TEXEL_COMPONENTS) != 0) 198e5c31af7Sopenharmony_ci { 199e5c31af7Sopenharmony_ci m_testCtx.getLog() << tcu::TestLog::Message << "Rendered data [" << (int)result_data[index + 0] << ", " 200e5c31af7Sopenharmony_ci << (int)result_data[index + 1] << ", " << (int)result_data[index + 2] << ", " 201e5c31af7Sopenharmony_ci << (int)result_data[index + 3] << "] is different from reference data [" 202e5c31af7Sopenharmony_ci << (int)expected_result_data[index + 0] << ", " 203e5c31af7Sopenharmony_ci << (int)expected_result_data[index + 1] << ", " 204e5c31af7Sopenharmony_ci << (int)expected_result_data[index + 2] << ", " 205e5c31af7Sopenharmony_ci << (int)expected_result_data[index + 3] << "] !" << tcu::TestLog::EndMessage; 206e5c31af7Sopenharmony_ci 207e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 208e5c31af7Sopenharmony_ci return STOP; 209e5c31af7Sopenharmony_ci } 210e5c31af7Sopenharmony_ci } /* for (each index) */ 211e5c31af7Sopenharmony_ci } /* for (all layers) */ 212e5c31af7Sopenharmony_ci 213e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); 214e5c31af7Sopenharmony_ci return STOP; 215e5c31af7Sopenharmony_ci} 216e5c31af7Sopenharmony_ci 217e5c31af7Sopenharmony_ci/** Deinitializes GLES objects created during the test. 218e5c31af7Sopenharmony_ci * 219e5c31af7Sopenharmony_ci */ 220e5c31af7Sopenharmony_civoid GeometryShaderBlitting::deinit(void) 221e5c31af7Sopenharmony_ci{ 222e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 223e5c31af7Sopenharmony_ci 224e5c31af7Sopenharmony_ci /* Reset OpenGL ES state */ 225e5c31af7Sopenharmony_ci gl.bindTexture(GL_TEXTURE_3D, 0); 226e5c31af7Sopenharmony_ci gl.bindVertexArray(0); 227e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); 228e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_READ_FRAMEBUFFER, 0); 229e5c31af7Sopenharmony_ci 230e5c31af7Sopenharmony_ci /* Clean up */ 231e5c31af7Sopenharmony_ci if (m_fbo_draw_id != 0) 232e5c31af7Sopenharmony_ci { 233e5c31af7Sopenharmony_ci gl.deleteFramebuffers(1, &m_fbo_draw_id); 234e5c31af7Sopenharmony_ci } 235e5c31af7Sopenharmony_ci 236e5c31af7Sopenharmony_ci if (m_fbo_read_id != 0) 237e5c31af7Sopenharmony_ci { 238e5c31af7Sopenharmony_ci gl.deleteFramebuffers(1, &m_fbo_read_id); 239e5c31af7Sopenharmony_ci } 240e5c31af7Sopenharmony_ci 241e5c31af7Sopenharmony_ci if (m_to_draw != 0) 242e5c31af7Sopenharmony_ci { 243e5c31af7Sopenharmony_ci gl.deleteTextures(1, &m_to_draw); 244e5c31af7Sopenharmony_ci } 245e5c31af7Sopenharmony_ci 246e5c31af7Sopenharmony_ci if (m_to_read != 0) 247e5c31af7Sopenharmony_ci { 248e5c31af7Sopenharmony_ci gl.deleteTextures(1, &m_to_read); 249e5c31af7Sopenharmony_ci } 250e5c31af7Sopenharmony_ci 251e5c31af7Sopenharmony_ci if (m_vao_id != 0) 252e5c31af7Sopenharmony_ci { 253e5c31af7Sopenharmony_ci gl.deleteVertexArrays(1, &m_vao_id); 254e5c31af7Sopenharmony_ci } 255e5c31af7Sopenharmony_ci 256e5c31af7Sopenharmony_ci /* Release base class */ 257e5c31af7Sopenharmony_ci TestCaseBase::deinit(); 258e5c31af7Sopenharmony_ci} 259e5c31af7Sopenharmony_ci 260e5c31af7Sopenharmony_ci/** Constructor 261e5c31af7Sopenharmony_ci * 262e5c31af7Sopenharmony_ci * @param context Test context 263e5c31af7Sopenharmony_ci * @param name Test case's name 264e5c31af7Sopenharmony_ci * @param description Test case's desricption 265e5c31af7Sopenharmony_ci **/ 266e5c31af7Sopenharmony_ciGeometryShaderBlittingLayeredToNonLayered::GeometryShaderBlittingLayeredToNonLayered(Context& context, 267e5c31af7Sopenharmony_ci const ExtParameters& extParams, 268e5c31af7Sopenharmony_ci const char* name, 269e5c31af7Sopenharmony_ci const char* description) 270e5c31af7Sopenharmony_ci : GeometryShaderBlitting(context, extParams, name, description) 271e5c31af7Sopenharmony_ci{ 272e5c31af7Sopenharmony_ci /* Left blank on purpose */ 273e5c31af7Sopenharmony_ci} 274e5c31af7Sopenharmony_ci 275e5c31af7Sopenharmony_ci/** Setup framebuffers for rendering 276e5c31af7Sopenharmony_ci * 277e5c31af7Sopenharmony_ci */ 278e5c31af7Sopenharmony_civoid GeometryShaderBlittingLayeredToNonLayered::setUpFramebuffersForRendering(glw::GLuint fbo_draw_id, 279e5c31af7Sopenharmony_ci glw::GLuint fbo_read_id, 280e5c31af7Sopenharmony_ci glw::GLint to_draw, glw::GLint to_read) 281e5c31af7Sopenharmony_ci{ 282e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 283e5c31af7Sopenharmony_ci 284e5c31af7Sopenharmony_ci /* Bind framebuffers */ 285e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_READ_FRAMEBUFFER, fbo_read_id); 286e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_draw_id); 287e5c31af7Sopenharmony_ci 288e5c31af7Sopenharmony_ci /* Blitting from a layered read framebuffer to a non-layered draw framebuffer*/ 289e5c31af7Sopenharmony_ci gl.framebufferTexture(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to_read, 0 /* level */); 290e5c31af7Sopenharmony_ci gl.framebufferTextureLayer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to_draw, 0, 0); 291e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up FBOs setUpFramebuffersForRendering"); 292e5c31af7Sopenharmony_ci} 293e5c31af7Sopenharmony_ci 294e5c31af7Sopenharmony_ci/** Constructor 295e5c31af7Sopenharmony_ci * 296e5c31af7Sopenharmony_ci * @param context Test context 297e5c31af7Sopenharmony_ci * @param name Test case's name 298e5c31af7Sopenharmony_ci * @param description Test case's desricption 299e5c31af7Sopenharmony_ci **/ 300e5c31af7Sopenharmony_ciGeometryShaderBlittingNonLayeredToLayered::GeometryShaderBlittingNonLayeredToLayered(Context& context, 301e5c31af7Sopenharmony_ci const ExtParameters& extParams, 302e5c31af7Sopenharmony_ci const char* name, 303e5c31af7Sopenharmony_ci const char* description) 304e5c31af7Sopenharmony_ci : GeometryShaderBlitting(context, extParams, name, description) 305e5c31af7Sopenharmony_ci{ 306e5c31af7Sopenharmony_ci /* Left blank on purpose */ 307e5c31af7Sopenharmony_ci} 308e5c31af7Sopenharmony_ci 309e5c31af7Sopenharmony_ci/** Setup framebuffers for rendering 310e5c31af7Sopenharmony_ci * 311e5c31af7Sopenharmony_ci */ 312e5c31af7Sopenharmony_civoid GeometryShaderBlittingNonLayeredToLayered::setUpFramebuffersForRendering(glw::GLuint fbo_draw_id, 313e5c31af7Sopenharmony_ci glw::GLuint fbo_read_id, 314e5c31af7Sopenharmony_ci glw::GLint to_draw, glw::GLint to_read) 315e5c31af7Sopenharmony_ci{ 316e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 317e5c31af7Sopenharmony_ci 318e5c31af7Sopenharmony_ci /* Bind framebuffers */ 319e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_READ_FRAMEBUFFER, fbo_read_id); 320e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_draw_id); 321e5c31af7Sopenharmony_ci 322e5c31af7Sopenharmony_ci /* Blitting from a non-layered read framebuffer to a layered draw framebuffer */ 323e5c31af7Sopenharmony_ci gl.framebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to_read, 0, 0); 324e5c31af7Sopenharmony_ci gl.framebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to_draw, 0 /* level */); 325e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up FBOs setUpFramebuffersForRendering"); 326e5c31af7Sopenharmony_ci} 327e5c31af7Sopenharmony_ci 328e5c31af7Sopenharmony_ci/** Constructor 329e5c31af7Sopenharmony_ci * 330e5c31af7Sopenharmony_ci * @param context Test context 331e5c31af7Sopenharmony_ci * @param name Test case's name 332e5c31af7Sopenharmony_ci * @param description Test case's desricption 333e5c31af7Sopenharmony_ci **/ 334e5c31af7Sopenharmony_ciGeometryShaderBlittingLayeredToLayered::GeometryShaderBlittingLayeredToLayered(Context& context, 335e5c31af7Sopenharmony_ci const ExtParameters& extParams, 336e5c31af7Sopenharmony_ci const char* name, 337e5c31af7Sopenharmony_ci const char* description) 338e5c31af7Sopenharmony_ci : GeometryShaderBlitting(context, extParams, name, description) 339e5c31af7Sopenharmony_ci{ 340e5c31af7Sopenharmony_ci /* Left blank on purpose */ 341e5c31af7Sopenharmony_ci} 342e5c31af7Sopenharmony_ci 343e5c31af7Sopenharmony_ci/** Setup framebuffers for rendering 344e5c31af7Sopenharmony_ci * 345e5c31af7Sopenharmony_ci */ 346e5c31af7Sopenharmony_civoid GeometryShaderBlittingLayeredToLayered::setUpFramebuffersForRendering(glw::GLuint fbo_draw_id, 347e5c31af7Sopenharmony_ci glw::GLuint fbo_read_id, glw::GLint to_draw, 348e5c31af7Sopenharmony_ci glw::GLint to_read) 349e5c31af7Sopenharmony_ci{ 350e5c31af7Sopenharmony_ci const glw::Functions& gl = m_context.getRenderContext().getFunctions(); 351e5c31af7Sopenharmony_ci 352e5c31af7Sopenharmony_ci /* Bind framebuffers */ 353e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_READ_FRAMEBUFFER, fbo_read_id); 354e5c31af7Sopenharmony_ci gl.bindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo_draw_id); 355e5c31af7Sopenharmony_ci 356e5c31af7Sopenharmony_ci /* Blitting from a layered read framebuffer to a layered draw framebuffer */ 357e5c31af7Sopenharmony_ci gl.framebufferTexture(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to_read, 0 /* level */); 358e5c31af7Sopenharmony_ci gl.framebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, to_draw, 0 /* level */); 359e5c31af7Sopenharmony_ci GLU_EXPECT_NO_ERROR(gl.getError(), "Error setting up FBOs setUpFramebuffersForRendering"); 360e5c31af7Sopenharmony_ci} 361e5c31af7Sopenharmony_ci 362e5c31af7Sopenharmony_ci} // namespace glcts 363