1 #ifndef _ESEXTCTEXTUREBUFFERMAXSIZEVALIDATION_HPP
2 #define _ESEXTCTEXTUREBUFFERMAXSIZEVALIDATION_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  esextcTextureBufferMAXSizeValidation.hpp
28  * \brief Texture Buffer Max Size Validation (Test 2)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "../esextcTestCaseBase.hpp"
32 
33 namespace glcts
34 {
35 
36 /** Implementation of (Test 2) from CTS_EXT_texture_buffer. Description follows:
37  *
38  *   Test whether texture buffer can have the maximum texture size specified for
39  *   this type of texture.
40  *
41  *   Category: API, Functional Test.
42  *
43  *   The test should create a texture object and bind it to TEXTURE_BUFFER_EXT
44  *   texture target at texture unit 0. It should also create buffer object and
45  *   bind it to TEXTURE_BUFFER_EXT target.
46  *
47  *   Query for the value of MAX_TEXTURE_BUFFER_SIZE_EXT using GetIntegerv function.
48  *   Call glBufferData with NULL data pointer to allocate storage for the buffer
49  *   object. The size of the storage should be equal to value of
50  *   value(MAX_TEXTURE_BUFFER_SIZE_EXT) * sizeof(GLubyte).
51  *
52  *   Map the buffer object's data store to client's address space by using
53  *   glMapBufferRange function (map the whole data store). The data store should
54  *   then be filled with unsigned byte values up to the size of the data store
55  *   using the algorithm:
56  *
57  *   data[index] = (GLubyte)(index % 256);
58  *
59  *   The data store should be unmapped using glUnmapBuffer function.
60  *
61  *   The buffer object should be used as texture buffer's data store by calling
62  *
63  *   TexBufferEXT(TEXTURE_BUFFER_EXT, GL_R8UI, buffer_id );
64  *
65  *   Query the value of TEXTURE_BUFFER_OFFSET_EXT and TEXTURE_BUFFER_SIZE_EXT by
66  *   calling the GetTexLevelParameter function.
67  *
68  *   The value of TEXTURE_BUFFER_OFFSET_EXT should be equal to 0 and the value of
69  *   TEXTURE_BUFFER_SIZE_EXT should be equal to value(MAX_TEXTURE_BUFFER_SIZE_EXT)
70  *   * sizeof(GLubyte).
71  *
72  *   Write a compute shader that defines
73  *
74  *   uniform highp usamplerBuffer sampler_buffer;
75  *
76  *   The shader should also define a shader storage buffer object
77  *
78  *   buffer ComputeSSBO
79  *   {
80  *     uvec3 outValue;
81  *
82  *   } computeSSBO;
83  *
84  *   Work group size should be 1 x 1 x 1.
85  *
86  *   Initialize a buffer object to be assigned as ssbo's data store.
87  *   Bind the sampler_buffer location to texture unit 0.
88  *
89  *   Perform the following calculations:
90  *
91  *   computeSSBO.outValue.x = uint( textureSize(sampler_buffer) );
92  *   computeSSBO.outValue.y = uint( texelFetch( sampler_buffer, 0 ).x );
93  *   computeSSBO.outValue.z =
94  *       uint( texelFetch( sampler_buffer, computeSSBO.outValue.x - 1 ).x );
95  *
96  *   Call:
97  *
98  *   glDispatchCompute(1, 1, 1);
99  *   glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
100  *
101  *   The test passes if
102  *
103  *   outValue.x ==  value(MAX_TEXTURE_BUFFER_SIZE_EXT)
104  *   outValue.y ==  0
105  *   outValue.z ==  ((value(MAX_TEXTURE_BUFFER_SIZE_EXT)-1) % 256).
106  */
107 class TextureBufferMAXSizeValidation : public TestCaseBase
108 {
109 public:
110 	/* Public methods */
111 	TextureBufferMAXSizeValidation(Context& context, const ExtParameters& extParams, const char* name,
112 								   const char* description);
113 
~TextureBufferMAXSizeValidation()114 	virtual ~TextureBufferMAXSizeValidation()
115 	{
116 	}
117 
118 	virtual void		  deinit(void);
119 	virtual IterateResult iterate(void);
120 
121 private:
122 	/* Private methods */
123 	void		initTest(void);
124 	const char* getComputeShaderCode(void);
125 
126 	/* Static constant variables */
127 	static const glw::GLuint m_n_vec_components;
128 
129 	/* Variables for general usage */
130 	glw::GLuint m_cs_id;
131 	glw::GLint  m_max_tex_buffer_size;
132 	glw::GLuint m_po_id;
133 	glw::GLuint m_ssbo_id;
134 	glw::GLuint m_tbo_id;
135 	glw::GLuint m_tbo_tex_id;
136 };
137 
138 } // namespace glcts
139 
140 #endif // _ESEXTCTEXTUREBUFFERMAXSIZEVALIDATION_HPP
141