• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCGPUSHADER5SAMPLERARRAYINDEXING_HPP
2 #define _ESEXTCGPUSHADER5SAMPLERARRAYINDEXING_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 esextcGPUShader5SamplerArrayIndexing.hpp
28  * \brief  gpu_shader5 extension - Sampler Array Indexing (Test 1)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "../esextcTestCaseBase.hpp"
32 
33 namespace glcts
34 {
35 /** "Test 1" from CTS_EXT_gpu_shader5. Description follows
36  *
37  *   Test whether indexing into an array of samplers using dynamically
38  *   uniform integer expressions works as expected.
39  *
40  *   Category:   API,
41  *               Functional Test.
42  *
43  *   The test should set up a FBO. A 2D texture of 3x3 resolution using
44  *   GL_RGBA8 internal format should be attached to its color attachment 0.
45  *
46  *   Write a vertex shader that declares input attribute
47  *
48  *   in vec4 position;
49  *
50  *   and assigns the value of position to gl_Position.
51  *
52  *   Write a fragment shader with an array of four sampler2D samplers.
53  *   For each of the samplers in the array bind a 1x1 texture with
54  *   GL_RGBA32F internal format. Fill the four textures with
55  *   (1.0f,0,0,0), (0,1.0f,0,0), (0,0,1.0f,0), (0,0,0,1.0f) respectively.
56  *
57  *   Define in the fragment shader a variable
58  *
59  *   layout(location = 0) out vec4 outColor = vec4(0.0f,0.0f,0.0f,0.0f);
60  *
61  *   Write a loop that goes from 0 to 3 inclusive and for each iteration
62  *   uses the loop index to index into the array of four sampler2d samples
63  *   and each chosen sampler is used to read a texel from texture bound to
64  *   it at coordinate (0.0f,0.0f).
65  *
66  *   A sum of vec4 values read from the textures should be stored
67  *   in outColor.
68  *
69  *   Create a program from the above vertex shader and fragment shader
70  *   and use it.
71  *
72  *   Configure buffer object as data source for the position attribute.
73  *   The buffer object should be filled with data: (-1,-1,0,1),(1,-1,0,1),
74  *   (-1,1,0,1),(1,1,0,1).
75  *
76  *   Execute a draw call glDrawArrays(GL_TRIANGLE_STRIP, 0, 4).
77  *
78  *   Call glReadPixels(1,1,1,1,GL_RGBA,GL_UNSIGNED_BYTE, pixel);
79  *
80  *   The test is successful if texel color is equal to (255,255,255,255)
81  *   with GTF tolerance.
82  */
83 class GPUShader5SamplerArrayIndexing : public TestCaseBase
84 {
85 public:
86 	/* Public methods */
87 	GPUShader5SamplerArrayIndexing(Context& context, const ExtParameters& extParams, const char* name,
88 								   const char* description);
89 
~GPUShader5SamplerArrayIndexing(void)90 	virtual ~GPUShader5SamplerArrayIndexing(void)
91 	{
92 	}
93 
94 	virtual void		  deinit(void);
95 	virtual IterateResult iterate(void);
96 
97 private:
98 	void		initTest(void);
99 	const char* getFragmentShaderCode();
100 	const char* getVertexShaderCode();
101 
102 	/* Private static variables */
103 	static const int m_n_small_textures;
104 	static const int m_n_texture_components;
105 	static const int m_big_texture_height;
106 	static const int m_big_texture_width;
107 	static const int m_n_texture_levels;
108 	static const int m_small_texture_height;
109 	static const int m_small_texture_width;
110 
111 	/* Private variables */
112 	glw::GLuint  m_big_to_id;
113 	glw::GLuint  m_fbo_id;
114 	glw::GLuint  m_fs_id;
115 	glw::GLuint  m_po_id;
116 	glw::GLuint* m_small_to_ids;
117 	glw::GLuint  m_vao_id;
118 	glw::GLuint  m_vbo_id;
119 	glw::GLuint  m_vs_id;
120 };
121 
122 } // namespace glcts
123 
124 #endif // _ESEXTCGPUSHADER5SAMPLERARRAYINDEXING_HPP
125