• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCTEXTUREBUFFERATOMICFUNCTIONS_HPP
2 #define _ESEXTCTEXTUREBUFFERATOMICFUNCTIONS_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  esextcTextureBufferAtomicFunctions.hpp
28  * \brief Texture Buffer Atomic Functions (Test 5)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "../esextcTestCaseBase.hpp"
32 
33 namespace glcts
34 {
35 
36 /** Implementation of (Test 5) from CTS_EXT_texture_buffer. Description follows
37  *
38  *   Test whether image atomic functions work correctly with image uniforms
39  *   having texture buffers bound to their image units.
40  *
41  *   Category: API, Functional Test.
42  *             Dependency with OES_shader_image_atomic.
43  *
44  *   The test should create texture object and bind it to TEXTURE_BUFFER_EXT
45  *   texture target at texture unit 0.
46  *
47  *   It should create a buffer object and bind it to TEXTURE_BUFFER_EXT target.
48  *
49  *   Let n_elements = value(GL_MAX_COMPUTE_WORK_GROUP_SIZE, X axis);
50  *
51  *   The test should allocate a memory block of the size
52  *   (n_elements + 1) * sizeof(GLunit);
53  *
54  *   The memory block should then be filled with subsequent unsigned integer
55  *   values from the range [0..n_elements]
56  *
57  *   Use glBufferData to initialize a buffer object's data store.
58  *   glBufferData should be given a pointer to allocated memory that will be
59  *   copied into the data store for initialization.
60  *
61  *   The buffer object should be used as texture buffer's data store by calling
62  *
63  *   TexBufferEXT(TEXTURE_BUFFER_EXT, GL_R32UI, buffer_id );
64  *
65  *   Write a compute shader that defines
66  *
67  *   layout(r32ui, binding = 0) uniform highp uimageBuffer uimage_buffer;
68  *
69  *   Work group size should be equal to n_elements x 1 x 1.
70  *
71  *   In the compute shader execute:
72  *
73  *   uint value = imageLoad( uimage_buffer, int(gl_LocalInvocationID.x) + 1 ).x;
74  *   imageAtomicAdd( uimage_buffer, 0 , value );
75  *
76  *   memoryBarrier();
77  *
78  *   value = imageLoad( uimage_buffer, 0 ).x;
79  *   imageAtomicCompSwap( uimage_buffer, int(gl_LocalInvocationID.x) + 1,
80  *                                       gl_LocalInvocationID.x + 1u, value );
81  *
82  *   Call:
83  *
84  *   glDispatchCompute(1, 1, 1);
85  *   glMemoryBarrier(BUFFER_UPDATE_BARRIER_BIT);
86  *
87  *   Map the buffer object's data store to client's address space by using
88  *   glMapBufferRange function (map the whole data store). The test passes if
89  *   each of the (n_elements + 1) unsigned integer values in the data store is
90  *   equal to
91  *
92  *   ((1 + n_elements) * n_elements) / 2
93  */
94 class TextureBufferAtomicFunctions : public TestCaseBase
95 {
96 public:
97 	/* Public methods */
98 	TextureBufferAtomicFunctions(Context& context, const ExtParameters& extParams, const char* name,
99 								 const char* description);
100 
~TextureBufferAtomicFunctions()101 	virtual ~TextureBufferAtomicFunctions()
102 	{
103 	}
104 
105 	virtual void		  deinit(void);
106 	virtual IterateResult iterate(void);
107 
108 private:
109 	/* Private methods */
110 	void		initTest(void);
111 	std::string getComputeShaderCode(glw::GLint work_group_size) const;
112 
113 	/* Variables for general usage */
114 	glw::GLuint m_cs_id;
115 	glw::GLuint m_po_id;
116 	glw::GLuint m_tbo_id;
117 	glw::GLuint m_tbo_tex_id;
118 	glw::GLuint m_n_texels_in_texture_buffer;
119 };
120 
121 } // namespace glcts
122 
123 #endif // _ESEXTCTEXTUREBUFFERATOMICFUNCTIONS_HPP
124