1e5c31af7Sopenharmony_ci#ifndef _GL4CBUFFERSTORAGETESTS_HPP
2e5c31af7Sopenharmony_ci#define _GL4CBUFFERSTORAGETESTS_HPP
3e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
4e5c31af7Sopenharmony_ci * OpenGL Conformance Test Suite
5e5c31af7Sopenharmony_ci * -----------------------------
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Copyright (c) 2015-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  gl4cBufferStorageTests.hpp
28e5c31af7Sopenharmony_ci * \brief Declares test classes for "Buffer Storage" functionality.
29e5c31af7Sopenharmony_ci */ /*-------------------------------------------------------------------*/
30e5c31af7Sopenharmony_ci
31e5c31af7Sopenharmony_ci#include "glcTestCase.hpp"
32e5c31af7Sopenharmony_ci#include "glwDefs.hpp"
33e5c31af7Sopenharmony_ci
34e5c31af7Sopenharmony_cinamespace gl4cts
35e5c31af7Sopenharmony_ci{
36e5c31af7Sopenharmony_cinamespace BufferStorage
37e5c31af7Sopenharmony_ci{
38e5c31af7Sopenharmony_ciclass Buffer;
39e5c31af7Sopenharmony_ci
40e5c31af7Sopenharmony_ci/** Implementation of test "Errors". Description follows:
41e5c31af7Sopenharmony_ci *
42e5c31af7Sopenharmony_ci * Verify that proper errors are generated:
43e5c31af7Sopenharmony_ci * - INVALID_OPERATION is generated by BufferStorage when 0 is bound to
44e5c31af7Sopenharmony_ci * <target>; Check all targets;
45e5c31af7Sopenharmony_ci * - INVLIAD_OPERATION is generated by BufferStorage, NamedBufferStorage and
46e5c31af7Sopenharmony_ci * BufferData if buffer already have immutable store;
47e5c31af7Sopenharmony_ci * - INVALID_VALUE is generated by BufferStorage and NamedBufferStorage when
48e5c31af7Sopenharmony_ci * <size> is less or equal to zero;
49e5c31af7Sopenharmony_ci * - INVLAID_VALUE is generated by BufferStorage and NamedBufferStorage when
50e5c31af7Sopenharmony_ci * <flags> contains MAP_PERSISTENT_BIT and neither MAP_READ_BIT nor
51e5c31af7Sopenharmony_ci * MAP_WRITE_BIT;
52e5c31af7Sopenharmony_ci * - INVALID_VALUE is generated by BufferStorage and NamedBufferStorage when
53e5c31af7Sopenharmony_ci * <flags> contains MAP_COHERENT_BIT and no MAP_PERSISTENT_BIT;
54e5c31af7Sopenharmony_ci * - INVALID_OPERATION is generated by MapBufferRange if any of:
55e5c31af7Sopenharmony_ci *   * MAP_COHERENT_BIT,
56e5c31af7Sopenharmony_ci *   * MAP_PERSISTENT_BIT,
57e5c31af7Sopenharmony_ci *   * MAP_READ_BIT,
58e5c31af7Sopenharmony_ci *   * MAP_WRITE_BIT
59e5c31af7Sopenharmony_ci * is included in <access> and not in buffer's storage flags;
60e5c31af7Sopenharmony_ci * - INVALID_OPERATION is generated by BufferSubData and NamedBufferSubData
61e5c31af7Sopenharmony_ci * when buffer has immutable store but its flags does not include
62e5c31af7Sopenharmony_ci * DYNAMIC_STORAGE.
63e5c31af7Sopenharmony_ci **/
64e5c31af7Sopenharmony_ciclass ErrorsTest : public deqp::TestCase
65e5c31af7Sopenharmony_ci{
66e5c31af7Sopenharmony_cipublic:
67e5c31af7Sopenharmony_ci	/* Public methods */
68e5c31af7Sopenharmony_ci	ErrorsTest(deqp::Context& context);
69e5c31af7Sopenharmony_ci	virtual ~ErrorsTest()
70e5c31af7Sopenharmony_ci	{
71e5c31af7Sopenharmony_ci	}
72e5c31af7Sopenharmony_ci
73e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
74e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
75e5c31af7Sopenharmony_ci
76e5c31af7Sopenharmony_ciprivate:
77e5c31af7Sopenharmony_ci	/* Private methods */
78e5c31af7Sopenharmony_ci	void verifyError(glw::GLenum expected_error, const glw::GLchar* error_message, bool& out_test_result);
79e5c31af7Sopenharmony_ci};
80e5c31af7Sopenharmony_ci
81e5c31af7Sopenharmony_ci/** Implementation of test "GetBufferParameter". Description follows:
82e5c31af7Sopenharmony_ci *
83e5c31af7Sopenharmony_ci * Verify that proper values are reported for buffers with immutable store.
84e5c31af7Sopenharmony_ci *
85e5c31af7Sopenharmony_ci * Steps:
86e5c31af7Sopenharmony_ci * - prepare immutable buffer with tested set of <flags>;
87e5c31af7Sopenharmony_ci * - inspect <param> BUFFER_STORAGE_FLAGS to verify that correct flags are
88e5c31af7Sopenharmony_ci * reported;
89e5c31af7Sopenharmony_ci * - inspect <param> BUFFER_IMMUTABLE_STORAGE to verify that TRUE is reported;
90e5c31af7Sopenharmony_ci * - inspect <param> BUFFER_SIZE to verify that correct value is reported;
91e5c31af7Sopenharmony_ci * - if tested flags set allows mapping, for each valid <access> set:
92e5c31af7Sopenharmony_ci *   * execute MapBufferRange with given <access>
93e5c31af7Sopenharmony_ci *   * inspect <param> BUFFER_ACCESS_FLAGS to verify that correct values are
94e5c31af7Sopenharmony_ci *   reported;
95e5c31af7Sopenharmony_ci * - delete buffer.
96e5c31af7Sopenharmony_ci *
97e5c31af7Sopenharmony_ci * Repeat steps for all valid combinations of flags for BufferStorage.
98e5c31af7Sopenharmony_ci **/
99e5c31af7Sopenharmony_ciclass GetBufferParameterTest : public deqp::TestCase
100e5c31af7Sopenharmony_ci{
101e5c31af7Sopenharmony_cipublic:
102e5c31af7Sopenharmony_ci	/* Public methods */
103e5c31af7Sopenharmony_ci	GetBufferParameterTest(deqp::Context& context);
104e5c31af7Sopenharmony_ci	virtual ~GetBufferParameterTest()
105e5c31af7Sopenharmony_ci	{
106e5c31af7Sopenharmony_ci	}
107e5c31af7Sopenharmony_ci
108e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
109e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
110e5c31af7Sopenharmony_ci
111e5c31af7Sopenharmony_ciprivate:
112e5c31af7Sopenharmony_ci	/* Private types */
113e5c31af7Sopenharmony_ci	struct testCase
114e5c31af7Sopenharmony_ci	{
115e5c31af7Sopenharmony_ci		testCase(glw::GLenum flags, glw::GLenum access);
116e5c31af7Sopenharmony_ci
117e5c31af7Sopenharmony_ci		glw::GLenum m_flags;
118e5c31af7Sopenharmony_ci		glw::GLenum m_access;
119e5c31af7Sopenharmony_ci	};
120e5c31af7Sopenharmony_ci
121e5c31af7Sopenharmony_ci	/* Private fields */
122e5c31af7Sopenharmony_ci	std::vector<testCase> m_test_cases;
123e5c31af7Sopenharmony_ci};
124e5c31af7Sopenharmony_ci
125e5c31af7Sopenharmony_ci/** Implementation of test "DynamicStorage". Description follows:
126e5c31af7Sopenharmony_ci *
127e5c31af7Sopenharmony_ci * Verify that:
128e5c31af7Sopenharmony_ci * - server can update contents of immutable buffer when DYNAMIC_STORAGE_BIT is
129e5c31af7Sopenharmony_ci * not set;
130e5c31af7Sopenharmony_ci * - client cannot update contents of immutable buffer when DYNAMIC_STORAGE_BIT
131e5c31af7Sopenharmony_ci * is not set;
132e5c31af7Sopenharmony_ci * - client can update contents of immutable buffer when DYNAMIC_STORAGE_BIT is
133e5c31af7Sopenharmony_ci * set.
134e5c31af7Sopenharmony_ci *
135e5c31af7Sopenharmony_ci * Steps:
136e5c31af7Sopenharmony_ci * - prepare 64 bytes immutable buffer filled with value 1; Bind the buffer to
137e5c31af7Sopenharmony_ci * COPY_READ_BUFFER;
138e5c31af7Sopenharmony_ci * - prepare 64 bytes immutable buffer filled with value 2; Do not set
139e5c31af7Sopenharmony_ci * DYNAMIC_STORAGE_BIT for <flags>; Bind the buffer to COPY_WRITE_BUFFER;
140e5c31af7Sopenharmony_ci * - execute BufferSubData to update COPY_WRITE_BUFFER buffer with 64 bytes
141e5c31af7Sopenharmony_ci * filled with value 3; INVLIAD_OPERATION error should be generated;
142e5c31af7Sopenharmony_ci * - inspect contents of buffer to verify it is filled with 2;
143e5c31af7Sopenharmony_ci * - execute CopyBufferSubData to transfer data from COPY_READ_BUFFER to
144e5c31af7Sopenharmony_ci * COPY_WRITE_BUFFER; No error should be generated;
145e5c31af7Sopenharmony_ci * - inspect contents of buffer to verify it is filled with 1;
146e5c31af7Sopenharmony_ci * - delete buffer and create new one; This time <flags> should contain
147e5c31af7Sopenharmony_ci * DYNAMIC_STORAGE_BIT; Bind the buffer to COPY_WRITE_BUFFER;
148e5c31af7Sopenharmony_ci * - execute BufferSubData to update COPY_WRITE_BUFFER buffer with 64 bytes
149e5c31af7Sopenharmony_ci * filled with value 3; No error should be generated;
150e5c31af7Sopenharmony_ci * - inspect contents of buffer to verify it is filled with 3;
151e5c31af7Sopenharmony_ci **/
152e5c31af7Sopenharmony_ciclass DynamicStorageTest : public deqp::TestCase
153e5c31af7Sopenharmony_ci{
154e5c31af7Sopenharmony_cipublic:
155e5c31af7Sopenharmony_ci	/* Public methods */
156e5c31af7Sopenharmony_ci	DynamicStorageTest(deqp::Context& context);
157e5c31af7Sopenharmony_ci	virtual ~DynamicStorageTest()
158e5c31af7Sopenharmony_ci	{
159e5c31af7Sopenharmony_ci	}
160e5c31af7Sopenharmony_ci
161e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
162e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
163e5c31af7Sopenharmony_ci};
164e5c31af7Sopenharmony_ci
165e5c31af7Sopenharmony_ci/** Implementation of test "MapPersistentBufferSubData". Description follows:
166e5c31af7Sopenharmony_ci *
167e5c31af7Sopenharmony_ci * Verify that buffer mapped with MAP_PERSISTENT_BIT can be used by following
168e5c31af7Sopenharmony_ci * operations:
169e5c31af7Sopenharmony_ci * - BufferSubData,
170e5c31af7Sopenharmony_ci * - NamedBufferSubData.
171e5c31af7Sopenharmony_ci *
172e5c31af7Sopenharmony_ci * Steps:
173e5c31af7Sopenharmony_ci * - generate buffer and prepare its storage with BufferStorage; Use following
174e5c31af7Sopenharmony_ci * flags MAP_PERSISTENT_BIT, MAP_READ_BIT and MAP_WRITE_BIT;
175e5c31af7Sopenharmony_ci * Provide NULL as <data> and 64 as <size>;
176e5c31af7Sopenharmony_ci * - bind buffer to ARRAY_BUFFER;
177e5c31af7Sopenharmony_ci * - execute tested operation, to update whole buffer with incrementing values
178e5c31af7Sopenharmony_ci * starting from 0; No error should be generated;
179e5c31af7Sopenharmony_ci * - map buffer contents with MapBufferRange; <access> should contain
180e5c31af7Sopenharmony_ci * MAP_PERSISTENT_BIT, MAP_READ_BIT and MAP_WRITE_BIT; Provide 16 as <offset>
181e5c31af7Sopenharmony_ci * and <size>;
182e5c31af7Sopenharmony_ci * - mapped region should contain values from 16 to 31;
183e5c31af7Sopenharmony_ci * - execute tested operation, to update portions of buffer specified below;
184e5c31af7Sopenharmony_ci * No error should be generated;
185e5c31af7Sopenharmony_ci * - unmap buffer;
186e5c31af7Sopenharmony_ci * - map buffer contents again, this time do not provide MAP_PERSISTENT_BIT;
187e5c31af7Sopenharmony_ci * - execute tested operation to update regions specified below; It is expected
188e5c31af7Sopenharmony_ci * that INVALID_OPERATION will be generated for cases that cross mapped region;
189e5c31af7Sopenharmony_ci * No error should be generated for other cases.
190e5c31af7Sopenharmony_ci *
191e5c31af7Sopenharmony_ci * Repeat steps for all tested commands.
192e5c31af7Sopenharmony_ci *
193e5c31af7Sopenharmony_ci * Portions of buffer to be updated:
194e5c31af7Sopenharmony_ci *
195e5c31af7Sopenharmony_ci *   * before mapped region: <offset> 0,  <size> 16,
196e5c31af7Sopenharmony_ci *   * after mapped region:  <offset> 32, <size> 16,
197e5c31af7Sopenharmony_ci *   * at the beginning:     <offset> 8,  <size> 16,
198e5c31af7Sopenharmony_ci *   * at the end:           <offset> 24, <size> 16,
199e5c31af7Sopenharmony_ci *   * in the middle:        <offset> 12, <size> 8;
200e5c31af7Sopenharmony_ci **/
201e5c31af7Sopenharmony_ciclass MapPersistentBufferSubDataTest : public deqp::TestCase
202e5c31af7Sopenharmony_ci{
203e5c31af7Sopenharmony_cipublic:
204e5c31af7Sopenharmony_ci	/* Public methods */
205e5c31af7Sopenharmony_ci	MapPersistentBufferSubDataTest(deqp::Context& context);
206e5c31af7Sopenharmony_ci	virtual ~MapPersistentBufferSubDataTest()
207e5c31af7Sopenharmony_ci	{
208e5c31af7Sopenharmony_ci	}
209e5c31af7Sopenharmony_ci
210e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
211e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
212e5c31af7Sopenharmony_ci
213e5c31af7Sopenharmony_ciprivate:
214e5c31af7Sopenharmony_ci	/* Private types */
215e5c31af7Sopenharmony_ci	struct testCase
216e5c31af7Sopenharmony_ci	{
217e5c31af7Sopenharmony_ci		glw::GLintptr   m_offset;
218e5c31af7Sopenharmony_ci		glw::GLsizeiptr m_size;
219e5c31af7Sopenharmony_ci		bool			m_cross_mapped_region;
220e5c31af7Sopenharmony_ci	};
221e5c31af7Sopenharmony_ci};
222e5c31af7Sopenharmony_ci
223e5c31af7Sopenharmony_ci/** Implementation of test "MapPersistentTexture". Description follows:
224e5c31af7Sopenharmony_ci *
225e5c31af7Sopenharmony_ci * Verify that buffer mapped with MAP_PERSISTENT_BIT can be used by following
226e5c31af7Sopenharmony_ci * operations:
227e5c31af7Sopenharmony_ci * - CompressedTexImage operations,
228e5c31af7Sopenharmony_ci * - CompressedTexSubImage operations,
229e5c31af7Sopenharmony_ci * - CompressedTextureSubImage operations,
230e5c31af7Sopenharmony_ci * - TexImage operations,
231e5c31af7Sopenharmony_ci * - TexSubImage operations.
232e5c31af7Sopenharmony_ci *
233e5c31af7Sopenharmony_ci * Steps:
234e5c31af7Sopenharmony_ci * - generate buffer and prepare its storage with BufferStorage; Use following
235e5c31af7Sopenharmony_ci * flags MAP_READ_BIT, MAP_WRITE_BIT and MAP_PERSISTENT_BIT; Provide data
236e5c31af7Sopenharmony_ci * relevant for tested operation;
237e5c31af7Sopenharmony_ci * - bind buffer to PIXEL_UNPACK_BUFFER;
238e5c31af7Sopenharmony_ci * - prepare texture in a way that is relevant for tested operation;
239e5c31af7Sopenharmony_ci * - execute tested operation, no error should be generated;
240e5c31af7Sopenharmony_ci * - delete texture and prepare next one;
241e5c31af7Sopenharmony_ci * - map buffer contents with MapBufferRange, <access> should contain
242e5c31af7Sopenharmony_ci * MAP_PERSISTENT_BIT, MAP_READ_BIT and MAP_WRITE_BIT;
243e5c31af7Sopenharmony_ci * - execute tested operation, no error should be generated;
244e5c31af7Sopenharmony_ci * - delete texture and prepare next one;
245e5c31af7Sopenharmony_ci * - unmap buffer
246e5c31af7Sopenharmony_ci * - map buffer contents again, this time do not provide MAP_PERSISTENT_BIT;
247e5c31af7Sopenharmony_ci * - execute tested operation, INVALID_OPERATION error should be generated.
248e5c31af7Sopenharmony_ci *
249e5c31af7Sopenharmony_ci * Repeat steps for all tested commands.
250e5c31af7Sopenharmony_ci **/
251e5c31af7Sopenharmony_ciclass MapPersistentTextureTest : public deqp::TestCase
252e5c31af7Sopenharmony_ci{
253e5c31af7Sopenharmony_cipublic:
254e5c31af7Sopenharmony_ci	/* Public methods */
255e5c31af7Sopenharmony_ci	MapPersistentTextureTest(deqp::Context& context);
256e5c31af7Sopenharmony_ci
257e5c31af7Sopenharmony_ci	virtual ~MapPersistentTextureTest()
258e5c31af7Sopenharmony_ci	{
259e5c31af7Sopenharmony_ci	}
260e5c31af7Sopenharmony_ci
261e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
262e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
263e5c31af7Sopenharmony_ci
264e5c31af7Sopenharmony_ciprivate:
265e5c31af7Sopenharmony_ci	/* Private types */
266e5c31af7Sopenharmony_ci	enum TESTED_OPERATION
267e5c31af7Sopenharmony_ci	{
268e5c31af7Sopenharmony_ci		OP_COMPRESSED_TEX_IMAGE = 0,
269e5c31af7Sopenharmony_ci		OP_COMPRESSED_TEX_SUB_IMAGE,
270e5c31af7Sopenharmony_ci		OP_COMPRESSED_TEXTURE_SUB_IMAGE,
271e5c31af7Sopenharmony_ci		OP_TEX_IMAGE,
272e5c31af7Sopenharmony_ci		OP_TEX_SUB_IMAGE,
273e5c31af7Sopenharmony_ci
274e5c31af7Sopenharmony_ci		TESTED_OPERATION_MAX
275e5c31af7Sopenharmony_ci	};
276e5c31af7Sopenharmony_ci
277e5c31af7Sopenharmony_ci	void		getCompressedInfo();
278e5c31af7Sopenharmony_ci	const char* getOperationName(TESTED_OPERATION operation);
279e5c31af7Sopenharmony_ci
280e5c31af7Sopenharmony_ci	bool verifyTestedOperation(TESTED_OPERATION operation, Buffer& buffer, glw::GLenum expected_error);
281e5c31af7Sopenharmony_ci
282e5c31af7Sopenharmony_ci	/* Private fields */
283e5c31af7Sopenharmony_ci	glw::GLint m_compressed_image_size;
284e5c31af7Sopenharmony_ci	glw::GLint m_compressed_internal_format;
285e5c31af7Sopenharmony_ci};
286e5c31af7Sopenharmony_ci
287e5c31af7Sopenharmony_ci/** Implementation of test "MapPersistentReadPixels". Description follows:
288e5c31af7Sopenharmony_ci *
289e5c31af7Sopenharmony_ci * Verify that buffer mapped with MAP_PERSISTENT_BIT can be used by ReadPixels.
290e5c31af7Sopenharmony_ci *
291e5c31af7Sopenharmony_ci * Steps:
292e5c31af7Sopenharmony_ci * - generate buffer and prepare its storage with BufferStorage; Use following
293e5c31af7Sopenharmony_ci * flags MAP_PERSISTENT_BIT, MAP_READ_BIT and MAP_WRITE_BIT;
294e5c31af7Sopenharmony_ci * Provide NULL as <data> and 64 as <size>;
295e5c31af7Sopenharmony_ci * - bind buffer to PIXEL_PACK_BUFFER;
296e5c31af7Sopenharmony_ci * - prepare 8x8 R8UI texture filled with unique values; Attach texture to FBO;
297e5c31af7Sopenharmony_ci * - execute ReadPixels to transfer texture contents to buffer, no error should
298e5c31af7Sopenharmony_ci * be generated;
299e5c31af7Sopenharmony_ci * - update contents of texture with different image;
300e5c31af7Sopenharmony_ci * - map buffer contents with MapBufferRange, <access> should contain
301e5c31af7Sopenharmony_ci * MAP_PERSISTENT_BIT, MAP_READ_BIT and MAP_WRITE_BIT;
302e5c31af7Sopenharmony_ci * - execute ReadPixels to transfer texture contents to buffer, no error should
303e5c31af7Sopenharmony_ci * be generated;
304e5c31af7Sopenharmony_ci * - execute MemoryBarrier with CLIENT_MAPPED_BUFFER_BARRIER_BIT and Finish;
305e5c31af7Sopenharmony_ci * - inspect contents of mapped buffer, to verify that latest data transfer was
306e5c31af7Sopenharmony_ci * successful;
307e5c31af7Sopenharmony_ci * - unmap buffer
308e5c31af7Sopenharmony_ci * - map buffer contents again, this time do not provide MAP_PERSISTENT_BIT;
309e5c31af7Sopenharmony_ci * - execute ReadPixels to transfer texture contents to buffer,
310e5c31af7Sopenharmony_ci * INVALID_OPERATION error should be generated.
311e5c31af7Sopenharmony_ci **/
312e5c31af7Sopenharmony_ciclass MapPersistentReadPixelsTest : public deqp::TestCase
313e5c31af7Sopenharmony_ci{
314e5c31af7Sopenharmony_cipublic:
315e5c31af7Sopenharmony_ci	/* Public methods */
316e5c31af7Sopenharmony_ci	MapPersistentReadPixelsTest(deqp::Context& context);
317e5c31af7Sopenharmony_ci
318e5c31af7Sopenharmony_ci	virtual ~MapPersistentReadPixelsTest()
319e5c31af7Sopenharmony_ci	{
320e5c31af7Sopenharmony_ci	}
321e5c31af7Sopenharmony_ci
322e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
323e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
324e5c31af7Sopenharmony_ci};
325e5c31af7Sopenharmony_ci
326e5c31af7Sopenharmony_ci/** Implementation of test "MapPersistentDispatch". Description follows:
327e5c31af7Sopenharmony_ci *
328e5c31af7Sopenharmony_ci * Test if dispatch operation can work with buffers mapped as
329e5c31af7Sopenharmony_ci * MAP_PERSISTENT_BIT.
330e5c31af7Sopenharmony_ci *
331e5c31af7Sopenharmony_ci * Steps:
332e5c31af7Sopenharmony_ci * - prepare program with compute shader that will:
333e5c31af7Sopenharmony_ci *   * calculate sum gl_GlobalInvocationID.x elements of source buffer;
334e5c31af7Sopenharmony_ci *   * store result in destination buffer at index gl_GlobalInvocationID.x;
335e5c31af7Sopenharmony_ci * Contents of both buffers should be treated as unsigned integers;
336e5c31af7Sopenharmony_ci * - prepare destination and source buffers as follows:
337e5c31af7Sopenharmony_ci *   * both are immutable;
338e5c31af7Sopenharmony_ci *   * both are 64 bytes long;
339e5c31af7Sopenharmony_ci *   * destination is filled with 0;
340e5c31af7Sopenharmony_ci *   * source is filled with specific unsigned integer values;
341e5c31af7Sopenharmony_ci *   * both shall have MAP_COHERENT_BIT and MAP_PERSISTENT_BIT flags set;
342e5c31af7Sopenharmony_ci *   * for source MAP_WRITE_BIT flag shall be set;
343e5c31af7Sopenharmony_ci *   * for destination MAP_READ_BIT flag shall be set;
344e5c31af7Sopenharmony_ci * - bind buffers to SHADER_STORAGE_BUFFER;
345e5c31af7Sopenharmony_ci * - use MapBufferRange to map both buffers; <access> shall be set as follows:
346e5c31af7Sopenharmony_ci *   * MAP_COHERENT_BIT and MAP_PERSISTENT_BIT flags set for both
347e5c31af7Sopenharmony_ci *   * MAP_WRITE_BIT flag shall be set for source;
348e5c31af7Sopenharmony_ci *   * MAP_READ_BIT flag shall be set for destination;
349e5c31af7Sopenharmony_ci * - dispatch program for 16x1x1 groups;
350e5c31af7Sopenharmony_ci * - execute Finish;
351e5c31af7Sopenharmony_ci * - modify contents of source buffer via mapped memory;
352e5c31af7Sopenharmony_ci * - inspect contents of destination buffer via mapped memory; It is expected
353e5c31af7Sopenharmony_ci * that it will contain results based on original content of source buffer;
354e5c31af7Sopenharmony_ci * - dispatch program for 16x1x1 groups;
355e5c31af7Sopenharmony_ci * - execute Finish;
356e5c31af7Sopenharmony_ci * - inspect contents of destination buffer via mapped memory; It is expected
357e5c31af7Sopenharmony_ci * that it will contain results based on modified content of source buffer.
358e5c31af7Sopenharmony_ci **/
359e5c31af7Sopenharmony_ciclass MapPersistentDispatchTest : public deqp::TestCase
360e5c31af7Sopenharmony_ci{
361e5c31af7Sopenharmony_cipublic:
362e5c31af7Sopenharmony_ci	/* Public methods */
363e5c31af7Sopenharmony_ci	MapPersistentDispatchTest(deqp::Context& context);
364e5c31af7Sopenharmony_ci
365e5c31af7Sopenharmony_ci	MapPersistentDispatchTest(deqp::Context& context, const glw::GLchar* test_name,
366e5c31af7Sopenharmony_ci							  const glw::GLchar* test_description);
367e5c31af7Sopenharmony_ci
368e5c31af7Sopenharmony_ci	virtual ~MapPersistentDispatchTest()
369e5c31af7Sopenharmony_ci	{
370e5c31af7Sopenharmony_ci	}
371e5c31af7Sopenharmony_ci
372e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
373e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
374e5c31af7Sopenharmony_ci};
375e5c31af7Sopenharmony_ci
376e5c31af7Sopenharmony_ci/** Implementation of test "MapPersistentFlush". Description follows:
377e5c31af7Sopenharmony_ci *
378e5c31af7Sopenharmony_ci * Test checks if FlushMappedBufferRange works correctly with persistent mapped
379e5c31af7Sopenharmony_ci * buffers.
380e5c31af7Sopenharmony_ci *
381e5c31af7Sopenharmony_ci * Modify MapPersistenDispatch in the following aspects:
382e5c31af7Sopenharmony_ci * - drop MAP_COHERENT_BIT for source buffer;
383e5c31af7Sopenharmony_ci * - apply FlushMappedBufferRange to ensure that modifications of source buffer
384e5c31af7Sopenharmony_ci * are visible to server.
385e5c31af7Sopenharmony_ci **/
386e5c31af7Sopenharmony_ciclass MapPersistentFlushTest : public deqp::TestCase
387e5c31af7Sopenharmony_ci{
388e5c31af7Sopenharmony_cipublic:
389e5c31af7Sopenharmony_ci	/* Public methods */
390e5c31af7Sopenharmony_ci	MapPersistentFlushTest(deqp::Context& context);
391e5c31af7Sopenharmony_ci
392e5c31af7Sopenharmony_ci	virtual ~MapPersistentFlushTest()
393e5c31af7Sopenharmony_ci	{
394e5c31af7Sopenharmony_ci	}
395e5c31af7Sopenharmony_ci
396e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
397e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
398e5c31af7Sopenharmony_ci};
399e5c31af7Sopenharmony_ci
400e5c31af7Sopenharmony_ci/** Implementation of test "MapPersistentDraw". Description follows:
401e5c31af7Sopenharmony_ci *
402e5c31af7Sopenharmony_ci * Test if draw operation can work with buffers mapped as MAP_PERSISTENT_BIT.
403e5c31af7Sopenharmony_ci *
404e5c31af7Sopenharmony_ci * Steps:
405e5c31af7Sopenharmony_ci * - prepare program consisting of vertex, geometry and fragment shader;
406e5c31af7Sopenharmony_ci *   * vertex shader should output single varying "vs_gs_index" of type uint,
407e5c31af7Sopenharmony_ci *   equal to gl_VertexID;
408e5c31af7Sopenharmony_ci *   * geometry shader should:
409e5c31af7Sopenharmony_ci *     - define single uniform buffer array "rectangles" with unspecified size;
410e5c31af7Sopenharmony_ci *     Rectangles should have two vec2 fields: position and size;
411e5c31af7Sopenharmony_ci *     - define single atomic_uint "atom_color";
412e5c31af7Sopenharmony_ci *     - increment "atom_color" once per execution;
413e5c31af7Sopenharmony_ci *     - output a quad that is placed at rectangles[vs_gs_index].position and
414e5c31af7Sopenharmony_ci *     has size equal rectangles[vs_gs_index].size;
415e5c31af7Sopenharmony_ci *     - define output float varying "gs_fs_color" equal to "atom_color" / 255;
416e5c31af7Sopenharmony_ci *   * fragment shader should pass value of "gs_fs_color" varying to red
417e5c31af7Sopenharmony_ci *   channel of output color;
418e5c31af7Sopenharmony_ci * - prepare FBO with 16x16 RGBA8 texture as color 0 attachment filled with 0;
419e5c31af7Sopenharmony_ci * - prepare immutable buffer with single unsigned integer bound to
420e5c31af7Sopenharmony_ci * "atom_color";
421e5c31af7Sopenharmony_ci * - prepare immutable buffer bound to "rectangles", with store for two sets of
422e5c31af7Sopenharmony_ci * data (2 * 2 * sizeof(vec2));
423e5c31af7Sopenharmony_ci * - make persistent mapping of both buffers for reads and writes;
424e5c31af7Sopenharmony_ci * - modify "rectangles" buffer via mapped memory with the following two sets
425e5c31af7Sopenharmony_ci *   * position [-0.5,-0.5], size [1.0,1.0],
426e5c31af7Sopenharmony_ci *   * position [-0.25,-0.25], size [1.5,1.5];
427e5c31af7Sopenharmony_ci * - modify "atom_color" buffer via mapped memory to value 1;
428e5c31af7Sopenharmony_ci * - execute MemoryBarrier for CLIENT_MAPPED_BUFFER_BARRIER_BIT;
429e5c31af7Sopenharmony_ci * - enable blending with functions ONE for both source and destination;
430e5c31af7Sopenharmony_ci * - execute DrawArrays for two vertices;
431e5c31af7Sopenharmony_ci * - execute MemoryBarrier for ALL_BARRIER_BITS and Finish;
432e5c31af7Sopenharmony_ci * - inspect contents of:
433e5c31af7Sopenharmony_ci *   * texture - to verify that pixel at 8,8 is filled with RGBA8(3,0,0,0),
434e5c31af7Sopenharmony_ci *   * "atom_color" - to verify that it is equal to 3;
435e5c31af7Sopenharmony_ci * - modify "rectangles" buffer via mapped memory with the following two sets
436e5c31af7Sopenharmony_ci *   * position [-1.0,-1.0], size [0.5,0.5],
437e5c31af7Sopenharmony_ci *   * position [0.5,0.5], size [0.5,0.5];
438e5c31af7Sopenharmony_ci * - modify "atom_color" buffer via mapped memory to value 5;
439e5c31af7Sopenharmony_ci * - execute MemoryBarrier for CLIENT_MAPPED_BUFFER_BARRIER_BIT;
440e5c31af7Sopenharmony_ci * - execute DrawArrays for two vertices;
441e5c31af7Sopenharmony_ci * - execute MemoryBarrier for ALL_BARRIER_BITS and Finish;
442e5c31af7Sopenharmony_ci * - inspect contents of:
443e5c31af7Sopenharmony_ci *   * texture - to verify that pixel at 8,8 is filled with RGBA8(3,0,0,0),
444e5c31af7Sopenharmony_ci *   * "atom_color" - to verify that it is equal to 7;
445e5c31af7Sopenharmony_ci *
446e5c31af7Sopenharmony_ci *  OpenGL 4.5 Changes
447e5c31af7Sopenharmony_ci *
448e5c31af7Sopenharmony_ci *      The OpenGL 4.5 specification changed wording from:
449e5c31af7Sopenharmony_ci *          "If MAP_COHERENT_BIT is not set and the client performs a write followed
450e5c31af7Sopenharmony_ci *           by a call to the MemoryBarrier command with the CLIENT_MAPPED_BUFFER_BARRIER_BIT set,
451e5c31af7Sopenharmony_ci *           then in subsequent commands the server will see the writes." (OpenGL 4.4, chapter 6.2)
452e5c31af7Sopenharmony_ci *      to form:
453e5c31af7Sopenharmony_ci *          "If MAP_COHERENT_BIT is not set and the client performs a write followed by
454e5c31af7Sopenharmony_ci *           a call to one of the FlushMapped*BufferRange commands with a range including
455e5c31af7Sopenharmony_ci *           the written range, then in subsequent commands the server will see the writes."
456e5c31af7Sopenharmony_ci *          (OpenGL 4.5, chapter 6.2).
457e5c31af7Sopenharmony_ci *      As a results writes to persistently mapped buffer shall be followed by FlushMapped*BufferRange
458e5c31af7Sopenharmony_ci *      not the MemoryBarrier (MemoryBarrier only synchronizes form GPU to the CPU).
459e5c31af7Sopenharmony_ci *
460e5c31af7Sopenharmony_ci *      Steps:
461e5c31af7Sopenharmony_ci *          Change MemoryBarrier to FlushMapped*BufferRange if context supports OpenGL 4.5 Core Profile.
462e5c31af7Sopenharmony_ci *
463e5c31af7Sopenharmony_ci **/
464e5c31af7Sopenharmony_ciclass MapPersistentDrawTest : public deqp::TestCase
465e5c31af7Sopenharmony_ci{
466e5c31af7Sopenharmony_cipublic:
467e5c31af7Sopenharmony_ci	/* Public methods */
468e5c31af7Sopenharmony_ci	MapPersistentDrawTest(deqp::Context& context);
469e5c31af7Sopenharmony_ci
470e5c31af7Sopenharmony_ci	virtual ~MapPersistentDrawTest()
471e5c31af7Sopenharmony_ci	{
472e5c31af7Sopenharmony_ci	}
473e5c31af7Sopenharmony_ci
474e5c31af7Sopenharmony_ci	/* Public methods inherited from TestCase */
475e5c31af7Sopenharmony_ci	virtual tcu::TestNode::IterateResult iterate(void);
476e5c31af7Sopenharmony_ci};
477e5c31af7Sopenharmony_ci} /* BufferStorage */
478e5c31af7Sopenharmony_ci
479e5c31af7Sopenharmony_ci/** Group class for Buffer Storage conformance tests */
480e5c31af7Sopenharmony_ciclass BufferStorageTests : public deqp::TestCaseGroup
481e5c31af7Sopenharmony_ci{
482e5c31af7Sopenharmony_cipublic:
483e5c31af7Sopenharmony_ci	/* Public methods */
484e5c31af7Sopenharmony_ci	BufferStorageTests(deqp::Context& context);
485e5c31af7Sopenharmony_ci
486e5c31af7Sopenharmony_ci	virtual ~BufferStorageTests(void)
487e5c31af7Sopenharmony_ci	{
488e5c31af7Sopenharmony_ci	}
489e5c31af7Sopenharmony_ci
490e5c31af7Sopenharmony_ci	virtual void init(void);
491e5c31af7Sopenharmony_ci
492e5c31af7Sopenharmony_ciprivate:
493e5c31af7Sopenharmony_ci	/* Private methods */
494e5c31af7Sopenharmony_ci	BufferStorageTests(const BufferStorageTests& other);
495e5c31af7Sopenharmony_ci	BufferStorageTests& operator=(const BufferStorageTests& other);
496e5c31af7Sopenharmony_ci};
497e5c31af7Sopenharmony_ci
498e5c31af7Sopenharmony_ci} /* gl4cts */
499e5c31af7Sopenharmony_ci
500e5c31af7Sopenharmony_ci#endif // _GL4CBUFFERSTORAGETESTS_HPP
501