Home | History | Annotate | Download | only in gpu_shader5
      1 #ifndef _ESEXTCGPUSHADER5IMAGESARRAYINDEXING_HPP
      2 #define _ESEXTCGPUSHADER5IMAGESARRAYINDEXING_HPP
      3 /*-------------------------------------------------------------------------
      4  * OpenGL Conformance Test Suite
      5  * -----------------------------
      6  *
      7  * Copyright (c) 2014-2016 The Khronos Group Inc.
      8  *
      9  * Licensed under the Apache License, Version 2.0 (the "License");
     10  * you may not use this file except in compliance with the License.
     11  * You may obtain a copy of the License at
     12  *
     13  *      http://www.apache.org/licenses/LICENSE-2.0
     14  *
     15  * Unless required by applicable law or agreed to in writing, software
     16  * distributed under the License is distributed on an "AS IS" BASIS,
     17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     18  * See the License for the specific language governing permissions and
     19  * limitations under the License.
     20  *
     21  */ /*!
     22  * \file
     23  * \brief
     24  */ /*-------------------------------------------------------------------*/
     25 
     26 /*!
     27  * \file esextcGPUShader5ImagesArrayIndexing.hpp
     28  * \brief GPUShader5 Images Array Indexing (Test 2)
     29  */ /*-------------------------------------------------------------------*/
     30 
     31 #include "../esextcTestCaseBase.hpp"
     32 
     33 namespace glcts
     34 {
     35 /** "Test 2" from CTS_EXT_gpu_shader5. Description follows
     36  *
     37  *   Test whether indexing into an array of images using constant
     38  *   expressions works as expected.
     39  *
     40  *   Category:  API,
     41  *              Functional Test,
     42  *
     43  *   Get the maximum size of work group in x and y direction by computing:
     44  *
     45  *   unsigned int max_wgs_x = 0;
     46  *   glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 0, &max_wgs_x);
     47  *
     48  *   unsigned int max_wgs_y = 0;
     49  *   glGetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, 1, &max_wgs_y);
     50  *
     51  *   Write a compute shader with an array of 4 uimage2D image handlers.
     52  *   The work group size should be (max_wgs_x, max_wgs_y, 1).
     53  *
     54  *   For each of the uimage2D image handlers bind a (max_wgs_x, max_wgs_y)
     55  *   image texture with GL_RGBA32UI internal format. Data of the textures
     56  *   should be set to (1,1,1,1).
     57  *
     58  *   In the compute shader perform operations:
     59  *
     60  *   uvec4 texel0  = imageLoad(image[0], ivec2(gl_LocalInvocationID.x,
     61  *   gl_LocalInvocationID.y) );
     62  *
     63  *   uvec4 texel1  = imageLoad(image[1], ivec2(gl_LocalInvocationID.x,
     64  *   gl_LocalInvocationID.y) );
     65  *
     66  *   uvec4 texel2  = imageLoad(image[2], ivec2(gl_LocalInvocationID.x,
     67  *   gl_LocalInvocationID.y) );
     68  *
     69  *   uvec4 texel3  = imageLoad(image[3], ivec2(gl_LocalInvocationID.x,
     70  *   gl_LocalInvocationID.y) );
     71  *
     72  *   uvec4 addon = uvec4(gl_LocalInvocationID.x+gl_LocalInvocationID.y);
     73  *
     74  *   imageStore(image[0], ivec2( gl_LocalInvocationID.x,
     75  *   gl_LocalInvocationID.y), texel0  + addon);
     76  *
     77  *   imageStore(image[1], ivec2( gl_LocalInvocationID.x,
     78  *   gl_LocalInvocationID.y), texel1  + addon);
     79  *
     80  *   imageStore(image[2], ivec2( gl_LocalInvocationID.x,
     81  *   gl_LocalInvocationID.y), texel2  + addon);
     82  *
     83  *   imageStore(image[3], ivec2( gl_LocalInvocationID.x,
     84  *   gl_LocalInvocationID.y), texel3  + addon);
     85  *
     86  *   Create a program from the above compute shader, use it
     87  *   and call glDispatchCompute(1, 1, 1);
     88  *
     89  *   Read back the data from the textures corresponding to image units.
     90  *
     91  *   The test is successful if for each texture and for each texel
     92  *   in the texture we get (x,y) -> (x+y+1, x+y+1, x+y+1, x+y+1).
     93  */
     94 class GPUShader5ImagesArrayIndexing : public TestCaseBase
     95 {
     96 public:
     97 	/* Public methods */
     98 	GPUShader5ImagesArrayIndexing(Context& context, const ExtParameters& extParams, const char* name,
     99 								  const char* description);
    100 
    101 	virtual ~GPUShader5ImagesArrayIndexing()
    102 	{
    103 	}
    104 
    105 	virtual IterateResult iterate(void);
    106 	virtual void		  deinit(void);
    107 
    108 private:
    109 	/* Private methods */
    110 	void initTest(void);
    111 
    112 	/* Private static variables */
    113 	static const glw::GLuint m_array_size;
    114 	static const glw::GLint  m_texture_n_components;
    115 
    116 	/* Private variables */
    117 	glw::GLuint  m_compute_shader_id;
    118 	glw::GLuint* m_data_buffer;
    119 	glw::GLuint  m_program_id;
    120 	glw::GLint   m_texture_height;
    121 	glw::GLint   m_texture_width;
    122 	glw::GLuint* m_to_ids;
    123 	glw::GLuint  m_fbo_id;
    124 
    125 	/* Private functions */
    126 	std::string getComputeShaderCode(const std::string& layout_size_x, const std::string& layout_size_y);
    127 };
    128 
    129 } // namespace glcts
    130 
    131 #endif // _ESEXTCGPUSHADER5IMAGESARRAYINDEXING_HPP
    132