1 #ifndef _ESEXTCTEXTUREBUFFERPRECISION_HPP
2 #define _ESEXTCTEXTUREBUFFERPRECISION_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  esextcTextureBufferPrecision.hpp
28  * \brief Texture Buffer Precision Qualifier (Test 10)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "../esextcTestCaseBase.hpp"
32 #include "glcTestCase.hpp"
33 #include "gluShaderUtil.hpp"
34 #include "tcuDefs.hpp"
35 #include <map>
36 
37 namespace glcts
38 {
39 
40 /** Implementation of (Test 10) from CTS_EXT_texture_buffer. Description follows:
41  *
42  *  Test whether shaders that don't include a precision qualifier for each of the
43  *  *samplerBuffer and *imageBuffer uniform declarations fail to compile.
44  *
45  *  Category: API.
46  *
47  *  Write a compute shader that defines
48  *
49  *  layout (r32f) uniform imageBuffer image_buffer;
50  *
51  *  buffer ComputeSSBO
52  *  {
53  *    float value;
54  *  } computeSSBO;
55  *
56  *  In the compute shader execute:
57  *
58  *  computeSSBO.value = imageLoad( image_buffer, 0 ).r;
59  *
60  *  Try to compile the shader. The shader should fail to compile.
61  *
62  *  Include a precision qualifier for the uniform declaration:
63  *
64  *  layout (r32f) uniform highp imageBuffer image_buffer;
65  *
66  *  This time the shader should compile without error.
67  *
68  *  Instead of including a precision qualifier for the uniform
69  *  declaration specify the default precision qualifier:
70  *
71  *  precision highp imageBuffer;
72  *
73  *  This time the shader should also compile without error.
74  *
75  *  Repeat the above tests with the iimageBuffer and uimageBuffer types
76  *  (instead of imageBuffer).
77  *
78  *  ---------------------------------------------------------------------------
79  *
80  *  Write a fragment shader that defines:
81  *
82  *  uniform samplerBuffer sampler_buffer;
83  *
84  *  layout(location = 0) out vec4 color;
85  *
86  *  In the fragment shader execute:
87  *
88  *  color = texelFetch( sampler_buffer, 0 );
89  *
90  *  Try to compile the shader. The shader should fail to compile.
91  *
92  *  Include a precision qualifier for the uniform declaration:
93  *
94  *  uniform highp samplerBuffer sampler_buffer;
95  *
96  *  This time the shader should compile without error.
97  *
98  *  Instead of including a precision qualifier for the uniform
99  *  declaration specify the default precision qualifier:
100  *
101  *  precision highp samplerBuffer;
102  *
103  *  This time the shader should also compile without error.
104  *
105  *  Repeat the above tests with the isamplerBuffer and usamplerBuffer types
106  *  (instead of samplerBuffer).
107  */
108 class TextureBufferPrecision : public TestCaseBase
109 {
110 public:
111 	/* Public methods */
112 	TextureBufferPrecision(Context& context, const ExtParameters& extParams, const char* name, const char* description);
113 
~TextureBufferPrecision()114 	virtual ~TextureBufferPrecision()
115 	{
116 	}
117 
118 	virtual void		  deinit(void);
119 	virtual IterateResult iterate(void);
120 
121 private:
122 	/* Private methods */
123 	glw::GLboolean verifyShaderCompilationStatus(glw::GLenum shader_type, const char** sh_code_parts,
124 												 const glw::GLuint parts_count, const glw::GLint expected_status);
125 
126 	/* Private variables */
127 	glw::GLuint m_po_id; /* Program object */
128 	glw::GLuint m_sh_id; /* Shader object */
129 
130 	static const char* const m_cs_code_head; /* Head of the compute shader. */
131 	static const char* const m_cs_code_declaration_without_precision
132 		[3]; /* Variables declarations for the compute shader without usage of the precision qualifier. */
133 	static const char* const m_cs_code_declaration_with_precision
134 		[3]; /* Variables declarations for the compute shader with usage of the precision qualifier. */
135 	static const char* const
136 							 m_cs_code_global_precision[3]; /* The default precision qualifier declarations for the compute shader. */
137 	static const char* const m_cs_code_body;				/* The compute shader body. */
138 
139 	static const char* const m_fs_code_head; /* Head of the fragment shader. */
140 	static const char* const m_fs_code_declaration_without_precision
141 		[3]; /* Variables declarations for the fragment shader without usage of the precision qualifier. */
142 	static const char* const m_fs_code_declaration_with_precision
143 		[3]; /* Variables declarations for the fragment shader with usage of the precision qualifier. */
144 	static const char* const
145 							 m_fs_code_global_precision[3]; /* The default precision qualifier declarations for the fragment shader. */
146 	static const char* const m_fs_code_body;				/* The fragment shader body. */
147 };
148 
149 } // namespace glcts
150 
151 #endif // _ESEXTCTEXTUREBUFFERPRECISION_HPP
152