1e5c31af7Sopenharmony_ci#ifndef _ESEXTCTEXTUREBUFFERPARAMETERS_HPP
2e5c31af7Sopenharmony_ci#define _ESEXTCTEXTUREBUFFERPARAMETERS_HPP
3e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
4e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite
5e5c31af7Sopenharmony_ci * -----------------------------
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Copyright (c) 2014-2016 The Khronos Group Inc.
8e5c31af7Sopenharmony_ci *
9e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
10e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
11e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
12e5c31af7Sopenharmony_ci *
13e5c31af7Sopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
14e5c31af7Sopenharmony_ci *
15e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
16e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
17e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
19e5c31af7Sopenharmony_ci * limitations under the License.
20e5c31af7Sopenharmony_ci *
21e5c31af7Sopenharmony_ci */ /*!
22e5c31af7Sopenharmony_ci * \file
23e5c31af7Sopenharmony_ci * \brief
24e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/
25e5c31af7Sopenharmony_ci
26e5c31af7Sopenharmony_ci/*!
27e5c31af7Sopenharmony_ci * \file  esextcTextureBufferParameters.hpp
28e5c31af7Sopenharmony_ci * \brief Texture Buffer GetTexLevelParameter and GetIntegerv test (Test 6)
29e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/
30e5c31af7Sopenharmony_ci
31e5c31af7Sopenharmony_ci#include "../esextcTestCaseBase.hpp"
32e5c31af7Sopenharmony_ci#include "gluShaderUtil.hpp"
33e5c31af7Sopenharmony_ci#include "tcuDefs.hpp"
34e5c31af7Sopenharmony_ci#include <map>
35e5c31af7Sopenharmony_ci
36e5c31af7Sopenharmony_cinamespace glcts
37e5c31af7Sopenharmony_ci{
38e5c31af7Sopenharmony_ci
39e5c31af7Sopenharmony_ci/**   Implementation of (Test 6) from CTS_EXT_texture_buffer. Description follows:
40e5c31af7Sopenharmony_ci *
41e5c31af7Sopenharmony_ci *    Test whether for correctly configured texture buffer with attached
42e5c31af7Sopenharmony_ci *    buffer object used as data store, GetTexLevelParameter and GetIntegerv
43e5c31af7Sopenharmony_ci *    functions return correct values for new tokens specified in the extension
44e5c31af7Sopenharmony_ci *    specification.
45e5c31af7Sopenharmony_ci *
46e5c31af7Sopenharmony_ci *    Category: API.
47e5c31af7Sopenharmony_ci *
48e5c31af7Sopenharmony_ci *    The test should create a texture object and bind it to TEXTURE_BUFFER_EXT
49e5c31af7Sopenharmony_ci *    texture target at texture unit 0. It should also create buffer object and
50e5c31af7Sopenharmony_ci *    bind it to TEXTURE_BUFFER_EXT target.
51e5c31af7Sopenharmony_ci *
52e5c31af7Sopenharmony_ci *    The function glGetIntegerv called with TEXTURE_BINDING_BUFFER_EXT parameter
53e5c31af7Sopenharmony_ci *    name should return the id of the texture object bound to TEXTURE_BUFFER_EXT
54e5c31af7Sopenharmony_ci *    binding point for the active texture image unit.
55e5c31af7Sopenharmony_ci *
56e5c31af7Sopenharmony_ci *    The function glGetIntegerv called with TEXTURE_BUFFER_BINDING_EXT parameter
57e5c31af7Sopenharmony_ci *    name should return the id of the buffer object bound to the TEXTURE_BUFFER_EXT
58e5c31af7Sopenharmony_ci *    binding point.
59e5c31af7Sopenharmony_ci *
60e5c31af7Sopenharmony_ci *    The test should iterate over all formats supported by texture buffer
61e5c31af7Sopenharmony_ci *    listed in table texbo.1
62e5c31af7Sopenharmony_ci *
63e5c31af7Sopenharmony_ci *    For each format it should allocate memory block of size 128 *
64e5c31af7Sopenharmony_ci *    texel_size_for_format.
65e5c31af7Sopenharmony_ci *
66e5c31af7Sopenharmony_ci *    Use glBufferData to initialize a buffer object's data store.
67e5c31af7Sopenharmony_ci *    glBufferData should be given a pointer to allocated memory that will be
68e5c31af7Sopenharmony_ci *    copied into the data store for initialization.
69e5c31af7Sopenharmony_ci *
70e5c31af7Sopenharmony_ci *    The buffer object should be used as texture buffer's data store by calling
71e5c31af7Sopenharmony_ci *
72e5c31af7Sopenharmony_ci *    TexBufferEXT(TEXTURE_BUFFER_EXT, format_name, buffer_id );
73e5c31af7Sopenharmony_ci *
74e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with
75e5c31af7Sopenharmony_ci *    TEXTURE_BUFFER_DATA_STORE_BINDING_EXT parameter name should return id of
76e5c31af7Sopenharmony_ci *    the buffer object whose data store is used by texture buffer.
77e5c31af7Sopenharmony_ci *
78e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with TEXTURE_INTERNAL_FORMAT
79e5c31af7Sopenharmony_ci *    parameter name should return the name of the used format.
80e5c31af7Sopenharmony_ci *
81e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with
82e5c31af7Sopenharmony_ci *    TEXTURE_BUFFER_OFFSET_EXT parameter name should return 0.
83e5c31af7Sopenharmony_ci *
84e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with TEXTURE_BUFFER_SIZE_EXT
85e5c31af7Sopenharmony_ci *    parameter name should return 128 * texel_size_for_format.
86e5c31af7Sopenharmony_ci *
87e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with one of the above parameter
88e5c31af7Sopenharmony_ci *    names and a non-zero lod should generate INVALID_VALUE error.
89e5c31af7Sopenharmony_ci *
90e5c31af7Sopenharmony_ci *    Call:
91e5c31af7Sopenharmony_ci *
92e5c31af7Sopenharmony_ci *    GLint offset_alignment = 0;
93e5c31af7Sopenharmony_ci *    GetIntegerv(TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT, &offset_alignment);
94e5c31af7Sopenharmony_ci *
95e5c31af7Sopenharmony_ci *    Resize the buffer's data store using glBufferData to
96e5c31af7Sopenharmony_ci *    256 * texel_size_for_format + offset_alignment while it's bound to the
97e5c31af7Sopenharmony_ci *    texture buffer.
98e5c31af7Sopenharmony_ci *
99e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with
100e5c31af7Sopenharmony_ci *    TEXTURE_BUFFER_OFFSET_EXT parameter name should return 0.
101e5c31af7Sopenharmony_ci *
102e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with TEXTURE_BUFFER_SIZE_EXT
103e5c31af7Sopenharmony_ci *    parameter name should return 256 * texel_size_for_format.
104e5c31af7Sopenharmony_ci *
105e5c31af7Sopenharmony_ci *    Call:
106e5c31af7Sopenharmony_ci *
107e5c31af7Sopenharmony_ci *    TexBufferRangeEXT(TEXTURE_BUFFER_EXT, format_name, buffer_id,
108e5c31af7Sopenharmony_ci *        offset_alignment, 256 * texel_size_for_format);
109e5c31af7Sopenharmony_ci *
110e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with
111e5c31af7Sopenharmony_ci *    TEXTURE_BUFFER_OFFSET_EXT parameter name should return offset_alignment.
112e5c31af7Sopenharmony_ci *
113e5c31af7Sopenharmony_ci *    The function glGetTexLevelParameteriv called with TEXTURE_BUFFER_SIZE_EXT
114e5c31af7Sopenharmony_ci *    parameter name should return 256 * texel_size_for_format.
115e5c31af7Sopenharmony_ci */
116e5c31af7Sopenharmony_ciclass TextureBufferParameters : public TestCaseBase
117e5c31af7Sopenharmony_ci{
118e5c31af7Sopenharmony_cipublic:
119e5c31af7Sopenharmony_ci	/* Public methods */
120e5c31af7Sopenharmony_ci	TextureBufferParameters(Context& context, const ExtParameters& extParams, const char* name,
121e5c31af7Sopenharmony_ci							const char* description);
122e5c31af7Sopenharmony_ci
123e5c31af7Sopenharmony_ci	virtual ~TextureBufferParameters()
124e5c31af7Sopenharmony_ci	{
125e5c31af7Sopenharmony_ci	}
126e5c31af7Sopenharmony_ci
127e5c31af7Sopenharmony_ci	virtual void		  deinit(void);
128e5c31af7Sopenharmony_ci	virtual IterateResult iterate(void);
129e5c31af7Sopenharmony_ci
130e5c31af7Sopenharmony_ciprivate:
131e5c31af7Sopenharmony_ci	/* Private methods */
132e5c31af7Sopenharmony_ci	void initTest(void);
133e5c31af7Sopenharmony_ci
134e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureBindingBuffer(glw::GLint expected);
135e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureBufferBinding(glw::GLint expected);
136e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureBufferDataStoreBinding(glw::GLint expected);
137e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureBufferOffset(glw::GLint expected);
138e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureBufferSize(glw::GLint expected);
139e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureInternalFormat(glw::GLint expected);
140e5c31af7Sopenharmony_ci	glw::GLboolean queryTextureInvalidLevel();
141e5c31af7Sopenharmony_ci
142e5c31af7Sopenharmony_ci	static const glw::GLuint m_n_texels_phase_one;
143e5c31af7Sopenharmony_ci	static const glw::GLuint m_n_texels_phase_two;
144e5c31af7Sopenharmony_ci
145e5c31af7Sopenharmony_ci	typedef std::map<glw::GLint, glw::GLuint> InternalFormatsMap;
146e5c31af7Sopenharmony_ci
147e5c31af7Sopenharmony_ci	/* Private variables */
148e5c31af7Sopenharmony_ci	InternalFormatsMap m_internal_formats; /* Maps internal format to texel size for that format */
149e5c31af7Sopenharmony_ci	glw::GLuint		   m_tbo_id;		   /* Texture Buffer Object*/
150e5c31af7Sopenharmony_ci	glw::GLuint		   m_to_id;			   /* Texture Object*/
151e5c31af7Sopenharmony_ci};
152e5c31af7Sopenharmony_ci
153e5c31af7Sopenharmony_ci} // namespace glcts
154e5c31af7Sopenharmony_ci
155e5c31af7Sopenharmony_ci#endif // _ESEXTCTEXTUREBUFFERPARAMETERS_HPP
156