• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCGPUSHADER5UNIFORMBLOCKSARRAYINDEXING_HPP
2 #define _ESEXTCGPUSHADER5UNIFORMBLOCKSARRAYINDEXING_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 esextcGPUShader5UniformBlocksArrayIndexing.hpp
28  * \brief GPUShader5 Uniform Blocks Array Indexing Test (Test Group 4)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "../esextcTestCaseBase.hpp"
32 
33 namespace glcts
34 {
35 
36 /** "Test 4" from CTS_EXT_gpu_shader5. Description follows
37  *
38  *   Test whether indexing into an array of uniform blocks using dynamically
39  *   uniform integer expressions works as expected.
40  *
41  *   Category:  API,
42  *              Functional Test.
43  *
44  *   Write a vertex shader with an array of four uniform blocks.
45  *
46  *   The blocks should be as specified below:
47  *   uniform PositionBlock {
48  *       vec4 position;
49  *   } positionBlocks[4];
50  *
51  *   Initialize a set of buffer objects to be assigned as uniform block data
52  *   sources. Subsequent buffer objects should use: (-1.0, -1.0, 0.0, 1.0),
53  *   (-1.0, 1.0, 0.0, 1.0), (1.0, -1.0, 0.0, 1.0), (1.0, 1.0, 0.0, 1.0)
54  *   as position vector variable values.
55  *
56  *   Add a uniform variable:
57  *
58  *   uniform uint index;
59  *
60  *   In the vertex shader perform operation:
61  *
62  *   gl_Position =  positionBlocks[index].position;
63  *
64  *   Write a fragment shader that assigns a (1.0,1.0,1.0,1.0) color to
65  *   fragment output color.
66  *
67  *   Configure transform feedback to capture the value of gl_Position.
68  *
69  *   Create a program from the above vertex shader and fragment shader
70  *   and use it.
71  *
72  *   Execute four draw calls:
73  *
74  *   glUniform1ui( indexLocation, 0);
75  *   glDrawArrays(GL_POINTS, 0, 1);
76  *
77  *   glUniform1ui( indexLocation, 1);
78  *   glDrawArrays(GL_POINTS, 0, 1);
79  *
80  *   glUniform1ui( indexLocation, 2);
81  *   glDrawArrays(GL_POINTS, 0, 1);
82  *
83  *   glUniform1ui( indexLocation, 3);
84  *   glDrawArrays(GL_POINTS, 0, 1);
85  *
86  *   After each draw call copy captured result from the buffer object bound
87  *   to transform feedback binding point to outPositions[drawCallNr]
88  *   array member.
89  *
90  *   The test is successful if the value of outPosition[0] is equal to
91  *   (-1.0,-1.0,0.0,1.0), outPosition [1] is equal to (-1.0,1.0,0.0,1.0),
92  *   outPosition [2] is equal to (1.0,-1.0,0.0,1.0) and outPosition[3]
93  *   is equal to (1.0,1.0,0.0,1.0) - all equalities with GTF tolerance.
94  */
95 class GPUShader5UniformBlocksArrayIndexing : public TestCaseBase
96 {
97 public:
98 	/* Public methods */
99 	GPUShader5UniformBlocksArrayIndexing(Context& context, const ExtParameters& extParams, const char* name,
100 										 const char* description);
101 
~GPUShader5UniformBlocksArrayIndexing()102 	virtual ~GPUShader5UniformBlocksArrayIndexing()
103 	{
104 	}
105 
106 	virtual void		  deinit(void);
107 	virtual IterateResult iterate(void);
108 
109 private:
110 	/* Private methods */
111 	void initTest(void);
112 
113 	/* Private variables */
114 	static const char*		  m_fragment_shader_code;
115 	static const glw::GLuint  m_n_array_size;
116 	static const glw::GLuint  m_n_position_components;
117 	static const glw::GLfloat m_position_data[];
118 	static const char*		  m_vertex_shader_code;
119 
120 	glw::GLuint  m_fragment_shader_id;
121 	glw::GLuint  m_program_id;
122 	glw::GLuint  m_tf_buffer_id;
123 	glw::GLuint* m_uniform_buffer_ids;
124 	glw::GLuint  m_vertex_shader_id;
125 	glw::GLuint  m_vao_id;
126 
127 	/* Private functions */
128 	bool drawAndCheckResult(glw::GLuint index_location, glw::GLuint index_value);
129 };
130 
131 } // namespace glcts
132 
133 #endif // _ESEXTCGPUSHADER5UNIFORMBLOCKSARRAYINDEXING_HPP
134