1#ifndef _ESEXTCTEXTUREBUFFERPARAMVALUEINTTOFLOATCONVERSION_HPP
2#define _ESEXTCTEXTUREBUFFERPARAMVALUEINTTOFLOATCONVERSION_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  esextcTextureBufferParamValueIntToFloatConversion.hpp
28 * \brief Texture Buffer - Integer To Float Conversion (Test 4)
29 */ /*-------------------------------------------------------------------*/
30
31#include "../esextcTestCaseBase.hpp"
32
33namespace glcts
34{
35/** Implementation of (Test 4) from CTS_EXT_texture_buffer. Description follows
36 *
37 *   Test whether for texture buffer formats with unsigned normalized
38 *   fixed-point components, the extracted values in the shader are correctly
39 *   converted to floating-point values using equation 2.1 from OpenGL ES
40 *   specification.
41 *
42 *   Category: API, Functional Test.
43 *
44 *   The test should create a texture object and bind it to TEXTURE_BUFFER_EXT
45 *   texture target at texture unit 0. It should also create buffer object and
46 *   bind it to TEXTURE_BUFFER_EXT target.
47 *
48 *   It should then allocate memory block of size 256 bytes. The memory should be
49 *   initialized with subsequent unsigned byte values from the range [0 .. 255].
50 *
51 *   Use glBufferData to initialize a buffer object's data store.
52 *   glBufferData should be given a pointer to allocated memory that will be
53 *   copied into the data store for initialization.
54 *
55 *   The buffer object should be used as texture buffer's data store by calling
56 *
57 *   TexBufferEXT(TEXTURE_BUFFER_EXT, GL_R8, buffer_id );
58 *
59 *   Write a compute shader that defines
60 *
61 *   uniform highp samplerBuffer sampler_buffer;
62 *
63 *   Bind the sampler_buffer location to texture unit 0.
64 *
65 *   Work group size should be equal to 16 x 16 x 1.
66 *
67 *   The shader should also define a shader storage buffer object
68 *
69 *   buffer ComputeSSBO
70 *   {
71 *     float value[];
72 *
73 *   } computeSSBO;
74 *
75 *   Initialize a buffer object to be assigned as ssbo's data store. The size of
76 *   this buffer object's data store should be equal to 256 * sizeof(GLfloat).
77 *
78 *   In the compute shader execute:
79 *
80 *   int index = int(gl_LocalInvocationID.x * gl_WorkGroupSize.y + gl_LocalInvocationID.y);
81 *
82 *   computeSSBO.value[index] = texelFetch( sampler_buffer, index ).x;
83 *
84 *   Call:
85 *
86 *   glDispatchCompute(1, 1, 1);
87 *   glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
88 *
89 *   Map the ssbo's buffer object's data store to client's address space.
90 *
91 *   The test passes if for each of 256 float values read from the mapped
92 *   ssbo's buffer object's data store the value of
93 *
94 *   fabs( computeSSBO.value[index] - (index / 255.0f) )
95 *
96 *   is smaller than 1.0f/256.0f epsilon tolerance.
97 *
98 */
99class TextureBufferParamValueIntToFloatConversion : public TestCaseBase
100{
101public:
102	/* Public methods */
103	TextureBufferParamValueIntToFloatConversion(Context& context, const ExtParameters& extParams, const char* name,
104												const char* description);
105
106	virtual ~TextureBufferParamValueIntToFloatConversion()
107	{
108	}
109
110	virtual void		  deinit(void);
111	virtual IterateResult iterate(void);
112
113private:
114	/* Private methods */
115	void		initTest(void);
116	std::string getComputeShaderCode(void);
117
118	/* Variables for general usage */
119	glw::GLuint m_cs_id;
120	glw::GLuint m_po_id;
121	glw::GLuint m_ssbo_id;
122	glw::GLuint m_tbo_id;
123	glw::GLuint m_tbo_tex_id;
124
125	/* Static constant variables */
126	static glw::GLuint		  m_texture_buffer_size;
127	static glw::GLuint		  m_work_group_x_size;
128	static glw::GLuint		  m_work_group_y_size;
129	static const glw::GLfloat m_epsilon;
130};
131
132} // namespace glcts
133
134#endif // _ESEXTCTEXTUREBUFFERPARAMVALUEINTTOFLOATCONVERSION_HPP
135