1e5c31af7Sopenharmony_ci/*-------------------------------------------------------------------------
2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.0 Module
3e5c31af7Sopenharmony_ci * -------------------------------------------------
4e5c31af7Sopenharmony_ci *
5e5c31af7Sopenharmony_ci * Copyright 2014 The Android Open Source Project
6e5c31af7Sopenharmony_ci *
7e5c31af7Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
8e5c31af7Sopenharmony_ci * you may not use this file except in compliance with the License.
9e5c31af7Sopenharmony_ci * You may obtain a copy of the License at
10e5c31af7Sopenharmony_ci *
11e5c31af7Sopenharmony_ci *      http://www.apache.org/licenses/LICENSE-2.0
12e5c31af7Sopenharmony_ci *
13e5c31af7Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
14e5c31af7Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
15e5c31af7Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16e5c31af7Sopenharmony_ci * See the License for the specific language governing permissions and
17e5c31af7Sopenharmony_ci * limitations under the License.
18e5c31af7Sopenharmony_ci *
19e5c31af7Sopenharmony_ci *//*!
20e5c31af7Sopenharmony_ci * \file
21e5c31af7Sopenharmony_ci * \brief Negative Buffer API tests.
22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/
23e5c31af7Sopenharmony_ci
24e5c31af7Sopenharmony_ci#include "es2fNegativeBufferApiTests.hpp"
25e5c31af7Sopenharmony_ci#include "es2fApiCase.hpp"
26e5c31af7Sopenharmony_ci#include "gluContextInfo.hpp"
27e5c31af7Sopenharmony_ci
28e5c31af7Sopenharmony_ci#include "glwEnums.hpp"
29e5c31af7Sopenharmony_ci#include "glwDefs.hpp"
30e5c31af7Sopenharmony_ci
31e5c31af7Sopenharmony_ciusing namespace glw; // GL types
32e5c31af7Sopenharmony_ci
33e5c31af7Sopenharmony_cinamespace deqp
34e5c31af7Sopenharmony_ci{
35e5c31af7Sopenharmony_cinamespace gles2
36e5c31af7Sopenharmony_ci{
37e5c31af7Sopenharmony_cinamespace Functional
38e5c31af7Sopenharmony_ci{
39e5c31af7Sopenharmony_ci
40e5c31af7Sopenharmony_ciusing tcu::TestLog;
41e5c31af7Sopenharmony_ci
42e5c31af7Sopenharmony_ciNegativeBufferApiTests::NegativeBufferApiTests (Context& context)
43e5c31af7Sopenharmony_ci	: TestCaseGroup(context, "buffer", "Negative Buffer API Cases")
44e5c31af7Sopenharmony_ci{
45e5c31af7Sopenharmony_ci}
46e5c31af7Sopenharmony_ci
47e5c31af7Sopenharmony_ciNegativeBufferApiTests::~NegativeBufferApiTests (void)
48e5c31af7Sopenharmony_ci{
49e5c31af7Sopenharmony_ci}
50e5c31af7Sopenharmony_ci
51e5c31af7Sopenharmony_civoid NegativeBufferApiTests::init (void)
52e5c31af7Sopenharmony_ci{
53e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(bind_buffer, "Invalid glBindBuffer() usage",
54e5c31af7Sopenharmony_ci		{
55e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not one of the allowable values.");
56e5c31af7Sopenharmony_ci			glBindBuffer(-1, 0);
57e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
58e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
59e5c31af7Sopenharmony_ci		});
60e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(delete_buffers, "Invalid glDeleteBuffers() usage",
61e5c31af7Sopenharmony_ci		{
62e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
63e5c31af7Sopenharmony_ci			glDeleteBuffers(-1, 0);
64e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
65e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
66e5c31af7Sopenharmony_ci		});
67e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(gen_buffers, "Invalid glGenBuffers() usage",
68e5c31af7Sopenharmony_ci		{
69e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
70e5c31af7Sopenharmony_ci			glGenBuffers(-1, 0);
71e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
72e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
73e5c31af7Sopenharmony_ci		});
74e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(buffer_data, "Invalid glBufferData() usage",
75e5c31af7Sopenharmony_ci		{
76e5c31af7Sopenharmony_ci			GLuint buffer;
77e5c31af7Sopenharmony_ci			glGenBuffers(1, &buffer);
78e5c31af7Sopenharmony_ci			glBindBuffer(GL_ARRAY_BUFFER, buffer);
79e5c31af7Sopenharmony_ci
80e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
81e5c31af7Sopenharmony_ci			glBufferData(-1, 0, NULL, GL_STREAM_DRAW);
82e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
83e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
84e5c31af7Sopenharmony_ci
85e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if usage is not GL_STREAM_DRAW, GL_STATIC_DRAW, or GL_DYNAMIC_DRAW.");
86e5c31af7Sopenharmony_ci			glBufferData(GL_ARRAY_BUFFER, 0, NULL, -1);
87e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
88e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
89e5c31af7Sopenharmony_ci
90e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if size is negative.");
91e5c31af7Sopenharmony_ci			glBufferData(GL_ARRAY_BUFFER, -1, NULL, GL_STREAM_DRAW);
92e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
93e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
94e5c31af7Sopenharmony_ci
95e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
96e5c31af7Sopenharmony_ci			glBindBuffer(GL_ARRAY_BUFFER, 0);
97e5c31af7Sopenharmony_ci			glBufferData(GL_ARRAY_BUFFER, 0, NULL, GL_STREAM_DRAW);
98e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
99e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
100e5c31af7Sopenharmony_ci
101e5c31af7Sopenharmony_ci			glDeleteBuffers(1, &buffer);
102e5c31af7Sopenharmony_ci		});
103e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(buffer_sub_data, "Invalid glBufferSubData() usage",
104e5c31af7Sopenharmony_ci		{
105e5c31af7Sopenharmony_ci			GLuint buffer;
106e5c31af7Sopenharmony_ci			glGenBuffers(1, &buffer);
107e5c31af7Sopenharmony_ci			glBindBuffer(GL_ARRAY_BUFFER, buffer);
108e5c31af7Sopenharmony_ci			glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
109e5c31af7Sopenharmony_ci
110e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_ARRAY_BUFFER or GL_ELEMENT_ARRAY_BUFFER.");
111e5c31af7Sopenharmony_ci			glBufferSubData(-1, 1, 1, 0);
112e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
113e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
114e5c31af7Sopenharmony_ci
115e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved buffer object name 0 is bound to target.");
116e5c31af7Sopenharmony_ci			glBindBuffer(GL_ARRAY_BUFFER, 0);
117e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, 1, 1, 0);
118e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
119e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
120e5c31af7Sopenharmony_ci
121e5c31af7Sopenharmony_ci			glDeleteBuffers(1, &buffer);
122e5c31af7Sopenharmony_ci		});
123e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(buffer_sub_data_size_offset, "Invalid glBufferSubData() usage",
124e5c31af7Sopenharmony_ci		{
125e5c31af7Sopenharmony_ci			GLuint buffer;
126e5c31af7Sopenharmony_ci			glGenBuffers(1, &buffer);
127e5c31af7Sopenharmony_ci			glBindBuffer(GL_ARRAY_BUFFER, buffer);
128e5c31af7Sopenharmony_ci			glBufferData(GL_ARRAY_BUFFER, 10, 0, GL_STREAM_DRAW);
129e5c31af7Sopenharmony_ci
130e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if offset or size is negative, or if together they define a region of memory that extends beyond the buffer object's allocated data store.");
131e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, -1, 1, 0);
132e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
133e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, -1, -1, 0);
134e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
135e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, 1, -1, 0);
136e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
137e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, 15, 1, 0);
138e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
139e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, 1, 15, 0);
140e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
141e5c31af7Sopenharmony_ci			glBufferSubData(GL_ARRAY_BUFFER, 8, 8, 0);
142e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
143e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
144e5c31af7Sopenharmony_ci
145e5c31af7Sopenharmony_ci			glDeleteBuffers(1, &buffer);
146e5c31af7Sopenharmony_ci		});
147e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(clear, "Invalid glClear() usage",
148e5c31af7Sopenharmony_ci		{
149e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if any bit other than the three defined bits is set in mask.");
150e5c31af7Sopenharmony_ci			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
151e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
152e5c31af7Sopenharmony_ci			glClear(0x00000200);
153e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
154e5c31af7Sopenharmony_ci			glClear(0x00001000);
155e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
156e5c31af7Sopenharmony_ci			glClear(0x00000010);
157e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
158e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
159e5c31af7Sopenharmony_ci		});
160e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(read_pixels, "Invalid glReadPixels() usage",
161e5c31af7Sopenharmony_ci		{
162e5c31af7Sopenharmony_ci			std::vector<GLubyte> ubyteData(4);
163e5c31af7Sopenharmony_ci
164e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the combination of format and type is unsupported.");
165e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ubyteData[0]);
166e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
167e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
168e5c31af7Sopenharmony_ci
169e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if either width or height is negative.");
170e5c31af7Sopenharmony_ci			glReadPixels(0, 0, -1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
171e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
172e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
173e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
174e5c31af7Sopenharmony_ci			glReadPixels(0, 0, -1, -1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
175e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
176e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
177e5c31af7Sopenharmony_ci
178e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_FRAMEBUFFER_OPERATION is generated if the currently bound framebuffer is not framebuffer complete.");
179e5c31af7Sopenharmony_ci			GLuint fbo;
180e5c31af7Sopenharmony_ci			glGenFramebuffers(1, &fbo);
181e5c31af7Sopenharmony_ci			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
182e5c31af7Sopenharmony_ci			glCheckFramebufferStatus(GL_FRAMEBUFFER);
183e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
184e5c31af7Sopenharmony_ci			expectError(GL_INVALID_FRAMEBUFFER_OPERATION);
185e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
186e5c31af7Sopenharmony_ci		});
187e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(read_pixels_format_mismatch, "Invalid glReadPixels() usage",
188e5c31af7Sopenharmony_ci		{
189e5c31af7Sopenharmony_ci			std::vector<GLubyte> ubyteData(4);
190e5c31af7Sopenharmony_ci			std::vector<GLushort> ushortData(4);
191e5c31af7Sopenharmony_ci
192e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "Unsupported combinations of format and type will generate an INVALID_OPERATION error.");
193e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
194e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
195e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_6_5, &ushortData[0]);
196e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
197e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
198e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
199e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_4_4_4_4, &ushortData[0]);
200e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
201e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_RGB, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
202e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
203e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_ALPHA, GL_UNSIGNED_SHORT_5_5_5_1, &ushortData[0]);
204e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
205e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
206e5c31af7Sopenharmony_ci
207e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_RGBA/GL_UNSIGNED_BYTE is always accepted and the other acceptable pair can be discovered by querying GL_IMPLEMENTATION_COLOR_READ_FORMAT and GL_IMPLEMENTATION_COLOR_READ_TYPE.");
208e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &ubyteData[0]);
209e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
210e5c31af7Sopenharmony_ci			GLint readFormat;
211e5c31af7Sopenharmony_ci			GLint readType;
212e5c31af7Sopenharmony_ci			glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_FORMAT, &readFormat);
213e5c31af7Sopenharmony_ci			glGetIntegerv(GL_IMPLEMENTATION_COLOR_READ_TYPE, &readType);
214e5c31af7Sopenharmony_ci			glReadPixels(0, 0, 1, 1, readFormat, readType, &ubyteData[0]);
215e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
216e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
217e5c31af7Sopenharmony_ci		});
218e5c31af7Sopenharmony_ci
219e5c31af7Sopenharmony_ci	// Framebuffer Objects
220e5c31af7Sopenharmony_ci
221e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(bind_framebuffer, "Invalid glBindFramebuffer() usage",
222e5c31af7Sopenharmony_ci		{
223e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
224e5c31af7Sopenharmony_ci			glBindFramebuffer(-1, 0);
225e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
226e5c31af7Sopenharmony_ci			glBindFramebuffer(GL_RENDERBUFFER, 0);
227e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
228e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
229e5c31af7Sopenharmony_ci		});
230e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(bind_renderbuffer, "Invalid glBindRenderbuffer() usage",
231e5c31af7Sopenharmony_ci		{
232e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
233e5c31af7Sopenharmony_ci			glBindRenderbuffer(-1, 0);
234e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
235e5c31af7Sopenharmony_ci			glBindRenderbuffer(GL_FRAMEBUFFER, 0);
236e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
237e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
238e5c31af7Sopenharmony_ci		});
239e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(check_framebuffer_status, "Invalid glCheckFramebufferStatus() usage",
240e5c31af7Sopenharmony_ci		{
241e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
242e5c31af7Sopenharmony_ci			glCheckFramebufferStatus(-1);
243e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
244e5c31af7Sopenharmony_ci			glCheckFramebufferStatus(GL_RENDERBUFFER);
245e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
246e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
247e5c31af7Sopenharmony_ci		});
248e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(gen_framebuffers, "Invalid glGenFramebuffers() usage",
249e5c31af7Sopenharmony_ci		{
250e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
251e5c31af7Sopenharmony_ci			glGenFramebuffers(-1, 0);
252e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
253e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
254e5c31af7Sopenharmony_ci		});
255e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(gen_renderbuffers, "Invalid glGenRenderbuffers() usage",
256e5c31af7Sopenharmony_ci		{
257e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
258e5c31af7Sopenharmony_ci			glGenRenderbuffers(-1, 0);
259e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
260e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
261e5c31af7Sopenharmony_ci		});
262e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(delete_framebuffers, "Invalid glDeleteFramebuffers() usage",
263e5c31af7Sopenharmony_ci		{
264e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
265e5c31af7Sopenharmony_ci			glDeleteFramebuffers(-1, 0);
266e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
267e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
268e5c31af7Sopenharmony_ci		});
269e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(delete_renderbuffers, "Invalid glDeleteRenderbuffers() usage",
270e5c31af7Sopenharmony_ci		{;
271e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if n is negative.");
272e5c31af7Sopenharmony_ci			glDeleteRenderbuffers(-1, 0);
273e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
274e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
275e5c31af7Sopenharmony_ci		});
276e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(framebuffer_renderbuffer, "Invalid glFramebufferRenderbuffer() usage",
277e5c31af7Sopenharmony_ci		{
278e5c31af7Sopenharmony_ci			GLuint fbo;
279e5c31af7Sopenharmony_ci			GLuint rbo;
280e5c31af7Sopenharmony_ci			glGenFramebuffers(1, &fbo);
281e5c31af7Sopenharmony_ci			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
282e5c31af7Sopenharmony_ci			glGenRenderbuffers(1, &rbo);
283e5c31af7Sopenharmony_ci
284e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
285e5c31af7Sopenharmony_ci			glFramebufferRenderbuffer(-1, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
286e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
287e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
288e5c31af7Sopenharmony_ci
289e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if attachment is not an accepted attachment point.");
290e5c31af7Sopenharmony_ci			glFramebufferRenderbuffer(GL_FRAMEBUFFER, -1, GL_RENDERBUFFER, 0);
291e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
292e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
293e5c31af7Sopenharmony_ci
294e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if renderbuffertarget is not GL_RENDERBUFFER.");
295e5c31af7Sopenharmony_ci			glBindRenderbuffer(GL_RENDERBUFFER, rbo);
296e5c31af7Sopenharmony_ci			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, rbo);
297e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
298e5c31af7Sopenharmony_ci			glBindRenderbuffer(GL_RENDERBUFFER, 0);
299e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
300e5c31af7Sopenharmony_ci
301e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if renderbuffer is neither 0 nor the name of an existing renderbuffer object.");
302e5c31af7Sopenharmony_ci			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, -1);
303e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
304e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
305e5c31af7Sopenharmony_ci
306e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default framebuffer object name 0 is bound.");
307e5c31af7Sopenharmony_ci			glBindFramebuffer(GL_FRAMEBUFFER, 0);
308e5c31af7Sopenharmony_ci			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
309e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
310e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
311e5c31af7Sopenharmony_ci
312e5c31af7Sopenharmony_ci			glDeleteRenderbuffers(1, &rbo);
313e5c31af7Sopenharmony_ci			glDeleteFramebuffers(1, &fbo);
314e5c31af7Sopenharmony_ci		});
315e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(framebuffer_texture2d, "Invalid glFramebufferTexture2D() usage",
316e5c31af7Sopenharmony_ci		{
317e5c31af7Sopenharmony_ci			GLuint fbo;
318e5c31af7Sopenharmony_ci			GLuint tex2D;
319e5c31af7Sopenharmony_ci			GLuint texCube;
320e5c31af7Sopenharmony_ci			glGenFramebuffers(1, &fbo);
321e5c31af7Sopenharmony_ci			glBindFramebuffer(GL_FRAMEBUFFER, fbo);
322e5c31af7Sopenharmony_ci			glGenTextures(1, &tex2D);
323e5c31af7Sopenharmony_ci			glBindTexture(GL_TEXTURE_2D, tex2D);
324e5c31af7Sopenharmony_ci			glGenTextures(1, &texCube);
325e5c31af7Sopenharmony_ci			glBindTexture(GL_TEXTURE_CUBE_MAP, texCube);
326e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
327e5c31af7Sopenharmony_ci
328e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_FRAMEBUFFER.");
329e5c31af7Sopenharmony_ci			glFramebufferTexture2D(-1, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
330e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
331e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
332e5c31af7Sopenharmony_ci
333e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if textarget is not an accepted texture target.");
334e5c31af7Sopenharmony_ci			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, -1, tex2D, 0);
335e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
336e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
337e5c31af7Sopenharmony_ci
338e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if attachment is not an accepted attachment point.");
339e5c31af7Sopenharmony_ci			glFramebufferTexture2D(GL_FRAMEBUFFER, -1, GL_TEXTURE_2D, 0, 0);
340e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
341e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
342e5c31af7Sopenharmony_ci
343e5c31af7Sopenharmony_ci			if (!(m_context.getContextInfo().isExtensionSupported("GL_OES_fbo_render_mipmap") ||
344e5c31af7Sopenharmony_ci					m_context.getContextInfo().isES3Compatible()))
345e5c31af7Sopenharmony_ci			{
346e5c31af7Sopenharmony_ci				m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if level is not 0.");
347e5c31af7Sopenharmony_ci				glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 3);
348e5c31af7Sopenharmony_ci				expectError(GL_INVALID_VALUE);
349e5c31af7Sopenharmony_ci				m_log << TestLog::EndSection;
350e5c31af7Sopenharmony_ci			}
351e5c31af7Sopenharmony_ci
352e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture is neither 0 nor the name of an existing texture object.");
353e5c31af7Sopenharmony_ci			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, -1, 0);
354e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
355e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
356e5c31af7Sopenharmony_ci
357e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture is the name of an existing two-dimensional texture object but textarget is not GL_TEXTURE_2D.");
358e5c31af7Sopenharmony_ci
359e5c31af7Sopenharmony_ci			expectError(GL_NO_ERROR);
360e5c31af7Sopenharmony_ci			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, tex2D, 0);
361e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
362e5c31af7Sopenharmony_ci			glDeleteTextures(1, &tex2D);
363e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
364e5c31af7Sopenharmony_ci
365e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if texture is the name of an existing cube map texture object but textarget is GL_TEXTURE_2D.");
366e5c31af7Sopenharmony_ci			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
367e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
368e5c31af7Sopenharmony_ci			glDeleteTextures(1, &texCube);
369e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
370e5c31af7Sopenharmony_ci
371e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the default framebuffer object name 0 is bound.");
372e5c31af7Sopenharmony_ci			glBindFramebuffer(GL_FRAMEBUFFER, 0);
373e5c31af7Sopenharmony_ci			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
374e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
375e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
376e5c31af7Sopenharmony_ci
377e5c31af7Sopenharmony_ci			glDeleteFramebuffers(1, &fbo);
378e5c31af7Sopenharmony_ci		});
379e5c31af7Sopenharmony_ci	ES2F_ADD_API_CASE(renderbuffer_storage, "Invalid glRenderbufferStorage() usage",
380e5c31af7Sopenharmony_ci		{
381e5c31af7Sopenharmony_ci			GLuint rbo;
382e5c31af7Sopenharmony_ci			glGenRenderbuffers(1, &rbo);
383e5c31af7Sopenharmony_ci			glBindRenderbuffer(GL_RENDERBUFFER, rbo);
384e5c31af7Sopenharmony_ci
385e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if target is not GL_RENDERBUFFER.");
386e5c31af7Sopenharmony_ci			glRenderbufferStorage(-1, GL_RGBA4, 1, 1);
387e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
388e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_FRAMEBUFFER, GL_RGBA4, 1, 1);
389e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
390e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
391e5c31af7Sopenharmony_ci
392e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_ENUM is generated if internalformat is not an accepted format.");
393e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, -1, 1, 1);
394e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
395e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA, 1, 1);
396e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
397e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, 1, 1);
398e5c31af7Sopenharmony_ci			expectError(GL_INVALID_ENUM);
399e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
400e5c31af7Sopenharmony_ci
401e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is less than zero.");
402e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, -1, 1);
403e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
404e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 1, -1);
405e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
406e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, -1, -1);
407e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
408e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
409e5c31af7Sopenharmony_ci
410e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_VALUE is generated if width or height is greater than GL_MAX_RENDERBUFFER_SIZE.");
411e5c31af7Sopenharmony_ci			GLint maxSize;
412e5c31af7Sopenharmony_ci			glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &maxSize);
413e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 1, maxSize+1);
414e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
415e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, maxSize+1, 1);
416e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
417e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, maxSize+1, maxSize+1);
418e5c31af7Sopenharmony_ci			expectError(GL_INVALID_VALUE);
419e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
420e5c31af7Sopenharmony_ci
421e5c31af7Sopenharmony_ci			m_log << TestLog::Section("", "GL_INVALID_OPERATION is generated if the reserved renderbuffer object name 0 is bound.");
422e5c31af7Sopenharmony_ci			glBindRenderbuffer(GL_RENDERBUFFER, 0);
423e5c31af7Sopenharmony_ci			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 1, 1);
424e5c31af7Sopenharmony_ci			expectError(GL_INVALID_OPERATION);
425e5c31af7Sopenharmony_ci			m_log << TestLog::EndSection;
426e5c31af7Sopenharmony_ci
427e5c31af7Sopenharmony_ci			glDeleteRenderbuffers(1, &rbo);
428e5c31af7Sopenharmony_ci		});
429e5c31af7Sopenharmony_ci}
430e5c31af7Sopenharmony_ci
431e5c31af7Sopenharmony_ci} // Functional
432e5c31af7Sopenharmony_ci} // gles2
433e5c31af7Sopenharmony_ci} // deqp
434