• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _ESEXTCTEXTUREBUFFERPARAMETERS_HPP
2 #define _ESEXTCTEXTUREBUFFERPARAMETERS_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  esextcTextureBufferParameters.hpp
28  * \brief Texture Buffer GetTexLevelParameter and GetIntegerv test (Test 6)
29  */ /*-------------------------------------------------------------------*/
30 
31 #include "../esextcTestCaseBase.hpp"
32 #include "gluShaderUtil.hpp"
33 #include "tcuDefs.hpp"
34 #include <map>
35 
36 namespace glcts
37 {
38 
39 /**   Implementation of (Test 6) from CTS_EXT_texture_buffer. Description follows:
40  *
41  *    Test whether for correctly configured texture buffer with attached
42  *    buffer object used as data store, GetTexLevelParameter and GetIntegerv
43  *    functions return correct values for new tokens specified in the extension
44  *    specification.
45  *
46  *    Category: API.
47  *
48  *    The test should create a texture object and bind it to TEXTURE_BUFFER_EXT
49  *    texture target at texture unit 0. It should also create buffer object and
50  *    bind it to TEXTURE_BUFFER_EXT target.
51  *
52  *    The function glGetIntegerv called with TEXTURE_BINDING_BUFFER_EXT parameter
53  *    name should return the id of the texture object bound to TEXTURE_BUFFER_EXT
54  *    binding point for the active texture image unit.
55  *
56  *    The function glGetIntegerv called with TEXTURE_BUFFER_BINDING_EXT parameter
57  *    name should return the id of the buffer object bound to the TEXTURE_BUFFER_EXT
58  *    binding point.
59  *
60  *    The test should iterate over all formats supported by texture buffer
61  *    listed in table texbo.1
62  *
63  *    For each format it should allocate memory block of size 128 *
64  *    texel_size_for_format.
65  *
66  *    Use glBufferData to initialize a buffer object's data store.
67  *    glBufferData should be given a pointer to allocated memory that will be
68  *    copied into the data store for initialization.
69  *
70  *    The buffer object should be used as texture buffer's data store by calling
71  *
72  *    TexBufferEXT(TEXTURE_BUFFER_EXT, format_name, buffer_id );
73  *
74  *    The function glGetTexLevelParameteriv called with
75  *    TEXTURE_BUFFER_DATA_STORE_BINDING_EXT parameter name should return id of
76  *    the buffer object whose data store is used by texture buffer.
77  *
78  *    The function glGetTexLevelParameteriv called with TEXTURE_INTERNAL_FORMAT
79  *    parameter name should return the name of the used format.
80  *
81  *    The function glGetTexLevelParameteriv called with
82  *    TEXTURE_BUFFER_OFFSET_EXT parameter name should return 0.
83  *
84  *    The function glGetTexLevelParameteriv called with TEXTURE_BUFFER_SIZE_EXT
85  *    parameter name should return 128 * texel_size_for_format.
86  *
87  *    The function glGetTexLevelParameteriv called with one of the above parameter
88  *    names and a non-zero lod should generate INVALID_VALUE error.
89  *
90  *    Call:
91  *
92  *    GLint offset_alignment = 0;
93  *    GetIntegerv(TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT, &offset_alignment);
94  *
95  *    Resize the buffer's data store using glBufferData to
96  *    256 * texel_size_for_format + offset_alignment while it's bound to the
97  *    texture buffer.
98  *
99  *    The function glGetTexLevelParameteriv called with
100  *    TEXTURE_BUFFER_OFFSET_EXT parameter name should return 0.
101  *
102  *    The function glGetTexLevelParameteriv called with TEXTURE_BUFFER_SIZE_EXT
103  *    parameter name should return 256 * texel_size_for_format.
104  *
105  *    Call:
106  *
107  *    TexBufferRangeEXT(TEXTURE_BUFFER_EXT, format_name, buffer_id,
108  *        offset_alignment, 256 * texel_size_for_format);
109  *
110  *    The function glGetTexLevelParameteriv called with
111  *    TEXTURE_BUFFER_OFFSET_EXT parameter name should return offset_alignment.
112  *
113  *    The function glGetTexLevelParameteriv called with TEXTURE_BUFFER_SIZE_EXT
114  *    parameter name should return 256 * texel_size_for_format.
115  */
116 class TextureBufferParameters : public TestCaseBase
117 {
118 public:
119 	/* Public methods */
120 	TextureBufferParameters(Context& context, const ExtParameters& extParams, const char* name,
121 							const char* description);
122 
~TextureBufferParameters()123 	virtual ~TextureBufferParameters()
124 	{
125 	}
126 
127 	virtual void		  deinit(void);
128 	virtual IterateResult iterate(void);
129 
130 private:
131 	/* Private methods */
132 	void initTest(void);
133 
134 	glw::GLboolean queryTextureBindingBuffer(glw::GLint expected);
135 	glw::GLboolean queryTextureBufferBinding(glw::GLint expected);
136 	glw::GLboolean queryTextureBufferDataStoreBinding(glw::GLint expected);
137 	glw::GLboolean queryTextureBufferOffset(glw::GLint expected);
138 	glw::GLboolean queryTextureBufferSize(glw::GLint expected);
139 	glw::GLboolean queryTextureInternalFormat(glw::GLint expected);
140 	glw::GLboolean queryTextureInvalidLevel();
141 
142 	static const glw::GLuint m_n_texels_phase_one;
143 	static const glw::GLuint m_n_texels_phase_two;
144 
145 	typedef std::map<glw::GLint, glw::GLuint> InternalFormatsMap;
146 
147 	/* Private variables */
148 	InternalFormatsMap m_internal_formats; /* Maps internal format to texel size for that format */
149 	glw::GLuint		   m_tbo_id;		   /* Texture Buffer Object*/
150 	glw::GLuint		   m_to_id;			   /* Texture Object*/
151 };
152 
153 } // namespace glcts
154 
155 #endif // _ESEXTCTEXTUREBUFFERPARAMETERS_HPP
156