1e5c31af7Sopenharmony_ci#ifndef _ESEXTCTEXTUREBUFFERTEXTUREBUFFERRANGE_HPP 2e5c31af7Sopenharmony_ci#define _ESEXTCTEXTUREBUFFERTEXTUREBUFFERRANGE_HPP 3e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 4e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite 5e5c31af7Sopenharmony_ci * ----------------------------- 6e5c31af7Sopenharmony_ci * 7e5c31af7Sopenharmony_ci * Copyright (c) 2014-2016 The Khronos Group Inc. 8e5c31af7Sopenharmony_ci * 9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License. 11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at 12e5c31af7Sopenharmony_ci * 13e5c31af7Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 14e5c31af7Sopenharmony_ci * 15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and 19e5c31af7Sopenharmony_ci * limitations under the License. 20e5c31af7Sopenharmony_ci * 21e5c31af7Sopenharmony_ci */ /*! 22e5c31af7Sopenharmony_ci * \file 23e5c31af7Sopenharmony_ci * \brief 24e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/ 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci/*! 27e5c31af7Sopenharmony_ci * \file esextcTextureBufferTextureBufferRange.hpp 28e5c31af7Sopenharmony_ci * \brief Texture Buffer Range Test (Test 3) 29e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/ 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ci#include "../esextcTestCaseBase.hpp" 32e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 33e5c31af7Sopenharmony_ci#include <map> 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_cinamespace glcts 36e5c31af7Sopenharmony_ci{ 37e5c31af7Sopenharmony_ci 38e5c31af7Sopenharmony_ci/** Implementation of (Test 3) from CTS_EXT_texture_buffer. Description follows 39e5c31af7Sopenharmony_ci * 40e5c31af7Sopenharmony_ci * Test whether using the function TexBufferRangeEXT sub-ranges of 41e5c31af7Sopenharmony_ci * the buffer's object data store can be correctly attached to 42e5c31af7Sopenharmony_ci * texture buffers. The test should take into account that the offset value 43e5c31af7Sopenharmony_ci * should be an integer multiple of TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT value. 44e5c31af7Sopenharmony_ci * 45e5c31af7Sopenharmony_ci * Category: API, Functional Test. 46e5c31af7Sopenharmony_ci * 47e5c31af7Sopenharmony_ci * The test should create a texture object and bind it to TEXTURE_BUFFER_EXT 48e5c31af7Sopenharmony_ci * texture target at texture unit 0. 49e5c31af7Sopenharmony_ci * 50e5c31af7Sopenharmony_ci * It should create a buffer object and bind it to TEXTURE_BUFFER_EXT target. 51e5c31af7Sopenharmony_ci * 52e5c31af7Sopenharmony_ci * It should then query for the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 53e5c31af7Sopenharmony_ci * using GetIntegerv function. 54e5c31af7Sopenharmony_ci * 55e5c31af7Sopenharmony_ci * The test should allocate a memory block of the size equal to the sum of 56e5c31af7Sopenharmony_ci * aligned texel sizes calculated for each format supported by texture buffer 57e5c31af7Sopenharmony_ci * listed in table texbo.1 58e5c31af7Sopenharmony_ci * 59e5c31af7Sopenharmony_ci * Texel size for each format supported by texture buffer should be aligned 60e5c31af7Sopenharmony_ci * taking into consideration the value of TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT. 61e5c31af7Sopenharmony_ci * 62e5c31af7Sopenharmony_ci * The memory block should then be filled with values up to its size. 63e5c31af7Sopenharmony_ci * 64e5c31af7Sopenharmony_ci * Use glBufferData to initialize a buffer object's data store. 65e5c31af7Sopenharmony_ci * glBufferData should be given a pointer to allocated memory that will be 66e5c31af7Sopenharmony_ci * copied into the data store for initialization. 67e5c31af7Sopenharmony_ci * 68e5c31af7Sopenharmony_ci * The test should iterate over all formats supported by texture buffer and 69e5c31af7Sopenharmony_ci * use the buffer object as texture buffer's data store by calling 70e5c31af7Sopenharmony_ci * 71e5c31af7Sopenharmony_ci * TexBufferRangeEXT(TEXTURE_BUFFER_EXT, format_name, buffer_id, offset, 72e5c31af7Sopenharmony_ci * not_aligned_texel_size_for_format ); 73e5c31af7Sopenharmony_ci * 74e5c31af7Sopenharmony_ci * offset += aligned_texel_size_for_format; 75e5c31af7Sopenharmony_ci * 76e5c31af7Sopenharmony_ci * Write a vertex shader that defines texture sampler of the type compatible 77e5c31af7Sopenharmony_ci * with used format. Bind the sampler location to texture unit 0. 78e5c31af7Sopenharmony_ci * 79e5c31af7Sopenharmony_ci * The vertex shader should also define an output variable outValue of the type 80e5c31af7Sopenharmony_ci * compatible with used format and int outTextureSize output variable. 81e5c31af7Sopenharmony_ci * Configure transform feedback to capture the value of outValue and 82e5c31af7Sopenharmony_ci * outTextureSize. 83e5c31af7Sopenharmony_ci * 84e5c31af7Sopenharmony_ci * In the shader execute: 85e5c31af7Sopenharmony_ci * 86e5c31af7Sopenharmony_ci * outValue = texelFetch( sampler_buffer, 0 ); 87e5c31af7Sopenharmony_ci * outTextureSize = textureSize( sampler_buffer ); 88e5c31af7Sopenharmony_ci * 89e5c31af7Sopenharmony_ci * Create a program from the above vertex shader and a boilerplate fragment 90e5c31af7Sopenharmony_ci * shader and use it. 91e5c31af7Sopenharmony_ci * 92e5c31af7Sopenharmony_ci * Execute a draw call and copy captured outValue and outTextureSize from the 93e5c31af7Sopenharmony_ci * buffer objects bound to transform feedback binding points to client's 94e5c31af7Sopenharmony_ci * address space. 95e5c31af7Sopenharmony_ci * 96e5c31af7Sopenharmony_ci * This phase of the test is successful if for each format supported by texture 97e5c31af7Sopenharmony_ci * buffer outValue is equal to the value stored originally in the 98e5c31af7Sopenharmony_ci * buffer object that is being used as texture buffer's data store and 99e5c31af7Sopenharmony_ci * the value of outTextureSize is equal to 1. 100e5c31af7Sopenharmony_ci * 101e5c31af7Sopenharmony_ci * Write a compute shader that defines image sampler of the type compatible 102e5c31af7Sopenharmony_ci * with used format. Bind the texture buffer to image unit 0. 103e5c31af7Sopenharmony_ci * 104e5c31af7Sopenharmony_ci * Work group size should be equal to 1 x 1 x 1. 105e5c31af7Sopenharmony_ci * 106e5c31af7Sopenharmony_ci * The shader should also define shader storage buffer objects 107e5c31af7Sopenharmony_ci * 108e5c31af7Sopenharmony_ci * layout(binding = 0) buffer ComputeSSBOSize 109e5c31af7Sopenharmony_ci * { 110e5c31af7Sopenharmony_ci * int outImageSize; 111e5c31af7Sopenharmony_ci * } computeSSBOSize; 112e5c31af7Sopenharmony_ci * 113e5c31af7Sopenharmony_ci * layout(binding = 1) buffer ComputeSSBOValue 114e5c31af7Sopenharmony_ci * { 115e5c31af7Sopenharmony_ci * compatible_type outValue; 116e5c31af7Sopenharmony_ci * } computeSSBOValue; 117e5c31af7Sopenharmony_ci 118e5c31af7Sopenharmony_ci * Initialize two buffer objects to be assigned as ssbos' data stores. 119e5c31af7Sopenharmony_ci * 120e5c31af7Sopenharmony_ci * In the compute shader execute: 121e5c31af7Sopenharmony_ci * 122e5c31af7Sopenharmony_ci * computeSSBOSize.outImageSize = imageSize( image_buffer ); 123e5c31af7Sopenharmony_ci * computeSSBOValue.outValue = imageLoad( image_buffer, 0 ); 124e5c31af7Sopenharmony_ci * 125e5c31af7Sopenharmony_ci * Call: 126e5c31af7Sopenharmony_ci * 127e5c31af7Sopenharmony_ci * glDispatchCompute(1, 1, 1); 128e5c31af7Sopenharmony_ci * glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT); 129e5c31af7Sopenharmony_ci * 130e5c31af7Sopenharmony_ci * Map the ssbos' buffer objects' data stores to client's address space and 131e5c31af7Sopenharmony_ci * fetch the values of outImageSize and outValue. 132e5c31af7Sopenharmony_ci * 133e5c31af7Sopenharmony_ci * This phase of the test is successful if for each format supported by texture 134e5c31af7Sopenharmony_ci * buffer outValue is equal to the value stored originally in the 135e5c31af7Sopenharmony_ci * buffer object that is being used as texture buffer's data store and 136e5c31af7Sopenharmony_ci * the value of outImageSize is equal to 1. 137e5c31af7Sopenharmony_ci */ 138e5c31af7Sopenharmony_ci 139e5c31af7Sopenharmony_ci/* Helper class containing test configuration for specific internal format */ 140e5c31af7Sopenharmony_ciclass FormatInfo 141e5c31af7Sopenharmony_ci{ 142e5c31af7Sopenharmony_cipublic: 143e5c31af7Sopenharmony_ci /* Public methods */ 144e5c31af7Sopenharmony_ci FormatInfo(); 145e5c31af7Sopenharmony_ci FormatInfo(glw::GLenum internalFormat, glw::GLuint offsetAlignment); 146e5c31af7Sopenharmony_ci 147e5c31af7Sopenharmony_ci glw::GLuint get_aligned_size() 148e5c31af7Sopenharmony_ci { 149e5c31af7Sopenharmony_ci return m_aligned_size; 150e5c31af7Sopenharmony_ci } 151e5c31af7Sopenharmony_ci glw::GLuint get_not_aligned_size() 152e5c31af7Sopenharmony_ci { 153e5c31af7Sopenharmony_ci return m_not_aligned_size; 154e5c31af7Sopenharmony_ci } 155e5c31af7Sopenharmony_ci glw::GLuint get_ssbo_value_size() 156e5c31af7Sopenharmony_ci { 157e5c31af7Sopenharmony_ci return m_ssbo_value_size; 158e5c31af7Sopenharmony_ci } 159e5c31af7Sopenharmony_ci glw::GLenum get_internal_format() 160e5c31af7Sopenharmony_ci { 161e5c31af7Sopenharmony_ci return m_internal_format; 162e5c31af7Sopenharmony_ci } 163e5c31af7Sopenharmony_ci glw::GLuint get_n_components() 164e5c31af7Sopenharmony_ci { 165e5c31af7Sopenharmony_ci return m_n_components; 166e5c31af7Sopenharmony_ci } 167e5c31af7Sopenharmony_ci glw::GLenum get_input_type() 168e5c31af7Sopenharmony_ci { 169e5c31af7Sopenharmony_ci return m_input_type; 170e5c31af7Sopenharmony_ci } 171e5c31af7Sopenharmony_ci glw::GLenum get_output_type() 172e5c31af7Sopenharmony_ci { 173e5c31af7Sopenharmony_ci return m_output_type; 174e5c31af7Sopenharmony_ci } 175e5c31af7Sopenharmony_ci glw::GLboolean get_is_image_supported() 176e5c31af7Sopenharmony_ci { 177e5c31af7Sopenharmony_ci return m_is_image_supported; 178e5c31af7Sopenharmony_ci } 179e5c31af7Sopenharmony_ci std::string get_image_format_name() 180e5c31af7Sopenharmony_ci { 181e5c31af7Sopenharmony_ci return m_image_format_name; 182e5c31af7Sopenharmony_ci } 183e5c31af7Sopenharmony_ci std::string get_image_type_name() 184e5c31af7Sopenharmony_ci { 185e5c31af7Sopenharmony_ci return m_image_type_name; 186e5c31af7Sopenharmony_ci } 187e5c31af7Sopenharmony_ci std::string get_sampler_type_name() 188e5c31af7Sopenharmony_ci { 189e5c31af7Sopenharmony_ci return m_sampler_type_name; 190e5c31af7Sopenharmony_ci } 191e5c31af7Sopenharmony_ci std::string get_output_type_name() 192e5c31af7Sopenharmony_ci { 193e5c31af7Sopenharmony_ci return m_output_type_name; 194e5c31af7Sopenharmony_ci } 195e5c31af7Sopenharmony_ci std::string get_value_selector() 196e5c31af7Sopenharmony_ci { 197e5c31af7Sopenharmony_ci return m_value_selector; 198e5c31af7Sopenharmony_ci } 199e5c31af7Sopenharmony_ci 200e5c31af7Sopenharmony_ciprivate: 201e5c31af7Sopenharmony_ci /* Private methods */ 202e5c31af7Sopenharmony_ci glw::GLuint countAlignedSize(glw::GLuint offsetAlignment, glw::GLuint totalSize); 203e5c31af7Sopenharmony_ci void configure(void); 204e5c31af7Sopenharmony_ci 205e5c31af7Sopenharmony_ci /* Private Variables */ 206e5c31af7Sopenharmony_ci glw::GLuint m_aligned_size; 207e5c31af7Sopenharmony_ci glw::GLuint m_not_aligned_size; 208e5c31af7Sopenharmony_ci glw::GLuint m_ssbo_value_size; 209e5c31af7Sopenharmony_ci glw::GLenum m_internal_format; 210e5c31af7Sopenharmony_ci glw::GLuint m_offset_alignment; 211e5c31af7Sopenharmony_ci glw::GLuint m_n_components; 212e5c31af7Sopenharmony_ci glw::GLenum m_input_type; 213e5c31af7Sopenharmony_ci glw::GLenum m_output_type; 214e5c31af7Sopenharmony_ci glw::GLboolean m_is_image_supported; 215e5c31af7Sopenharmony_ci std::string m_image_format_name; 216e5c31af7Sopenharmony_ci std::string m_image_type_name; 217e5c31af7Sopenharmony_ci std::string m_sampler_type_name; 218e5c31af7Sopenharmony_ci std::string m_output_type_name; 219e5c31af7Sopenharmony_ci std::string m_value_selector; 220e5c31af7Sopenharmony_ci}; 221e5c31af7Sopenharmony_ci 222e5c31af7Sopenharmony_ci/* Test Case Class */ 223e5c31af7Sopenharmony_ciclass TextureBufferTextureBufferRange : public TestCaseBase 224e5c31af7Sopenharmony_ci{ 225e5c31af7Sopenharmony_cipublic: 226e5c31af7Sopenharmony_ci /* Public methods */ 227e5c31af7Sopenharmony_ci TextureBufferTextureBufferRange(Context& context, const ExtParameters& extParams, const char* name, 228e5c31af7Sopenharmony_ci const char* description); 229e5c31af7Sopenharmony_ci 230e5c31af7Sopenharmony_ci virtual ~TextureBufferTextureBufferRange() 231e5c31af7Sopenharmony_ci { 232e5c31af7Sopenharmony_ci } 233e5c31af7Sopenharmony_ci 234e5c31af7Sopenharmony_ci virtual void deinit(void); 235e5c31af7Sopenharmony_ci virtual IterateResult iterate(void); 236e5c31af7Sopenharmony_ci 237e5c31af7Sopenharmony_ciprivate: 238e5c31af7Sopenharmony_ci /* Private methods */ 239e5c31af7Sopenharmony_ci virtual void initTest(void); 240e5c31af7Sopenharmony_ci std::string getComputeShaderCode(FormatInfo& info) const; 241e5c31af7Sopenharmony_ci std::string getFragmentShaderCode(FormatInfo& info) const; 242e5c31af7Sopenharmony_ci std::string getVertexShaderCode(FormatInfo& info) const; 243e5c31af7Sopenharmony_ci 244e5c31af7Sopenharmony_ci void fillInputData(glw::GLubyte* buffer, glw::GLuint offset, FormatInfo& info); 245e5c31af7Sopenharmony_ci void fillOutputData(glw::GLubyte* buffer, FormatInfo& info); 246e5c31af7Sopenharmony_ci void cleanIteration(); 247e5c31af7Sopenharmony_ci 248e5c31af7Sopenharmony_ci bool checkResult(FormatInfo& info, const char* phase, bool transformFeedback); 249e5c31af7Sopenharmony_ci void logError(const char* phase, const char* internalFormat, glw::GLuint component, const char* exptectedValue, 250e5c31af7Sopenharmony_ci const char* resultValue); 251e5c31af7Sopenharmony_ci 252e5c31af7Sopenharmony_ci /* Variables for general usage */ 253e5c31af7Sopenharmony_ci glw::GLuint m_cs_id; 254e5c31af7Sopenharmony_ci glw::GLuint m_cs_po_id; 255e5c31af7Sopenharmony_ci glw::GLuint m_ssbo_size_id; 256e5c31af7Sopenharmony_ci glw::GLuint m_ssbo_value_id; 257e5c31af7Sopenharmony_ci glw::GLuint m_tbo_id; 258e5c31af7Sopenharmony_ci glw::GLuint m_tbo_tex_id; 259e5c31af7Sopenharmony_ci glw::GLint m_texture_buffer_offset_alignment; 260e5c31af7Sopenharmony_ci glw::GLuint m_vao_id; 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ci glw::GLuint m_vs_id; 263e5c31af7Sopenharmony_ci glw::GLuint m_fs_id; 264e5c31af7Sopenharmony_ci glw::GLuint m_vsfs_po_id; 265e5c31af7Sopenharmony_ci glw::GLuint m_tf_size_buffer_id; 266e5c31af7Sopenharmony_ci glw::GLuint m_tf_value_buffer_id; 267e5c31af7Sopenharmony_ci 268e5c31af7Sopenharmony_ci std::map<glw::GLenum, FormatInfo> m_configurations; 269e5c31af7Sopenharmony_ci glw::GLuint m_buffer_total_size; 270e5c31af7Sopenharmony_ci}; 271e5c31af7Sopenharmony_ci 272e5c31af7Sopenharmony_ci} // namespace glcts 273e5c31af7Sopenharmony_ci 274e5c31af7Sopenharmony_ci#endif // _ESEXTCTEXTUREBUFFERTEXTUREBUFFERRANGE_HPP 275