• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-------------------------------------------------------------------------
2  * drawElements Quality Program OpenGL ES 3.0 Module
3  * -------------------------------------------------
4  *
5  * Copyright 2014 The Android Open Source Project
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  *//*!
20  * \file
21  * \brief Fbo state query tests.
22  *//*--------------------------------------------------------------------*/
23 
24 #include "es3fFboStateQueryTests.hpp"
25 #include "glsStateQueryUtil.hpp"
26 #include "es3fApiCase.hpp"
27 #include "gluRenderContext.hpp"
28 #include "glwEnums.hpp"
29 #include "glwFunctions.hpp"
30 #include "tcuRenderTarget.hpp"
31 #include "deMath.h"
32 
33 using namespace glw; // GLint and other GL types
34 using deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard;
35 
36 
37 namespace deqp
38 {
39 namespace gles3
40 {
41 namespace Functional
42 {
43 namespace
44 {
45 
checkAttachmentComponentSizeAtLeast(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLenum target,GLenum attachment,int r,int g,int b,int a,int d,int s)46 void checkAttachmentComponentSizeAtLeast (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum target, GLenum attachment, int r, int g, int b, int a, int d, int s)
47 {
48 	using tcu::TestLog;
49 
50 	const int referenceSizes[] = {r, g, b, a, d, s};
51 	const GLenum paramNames[] =
52 	{
53 		GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,	GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
54 		GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
55 		GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
56 	};
57 
58 	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(referenceSizes) == DE_LENGTH_OF_ARRAY(paramNames));
59 
60 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceSizes); ++ndx)
61 	{
62 		if (referenceSizes[ndx] == -1)
63 			continue;
64 
65 		StateQueryMemoryWriteGuard<GLint> state;
66 		gl.glGetFramebufferAttachmentParameteriv(target, attachment, paramNames[ndx], &state);
67 
68 		if (!state.verifyValidity(testCtx))
69 		{
70 			gl.glGetError(); // just log the error
71 			continue;
72 		}
73 
74 		if (state < referenceSizes[ndx])
75 		{
76 			testCtx.getLog() << TestLog::Message << "// ERROR: Expected greater or equal to " << referenceSizes[ndx] << "; got " << state << TestLog::EndMessage;
77 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
78 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
79 		}
80 	}
81 }
82 
checkAttachmentComponentSizeExactly(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLenum target,GLenum attachment,int r,int g,int b,int a,int d,int s)83 void checkAttachmentComponentSizeExactly (tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum target, GLenum attachment, int r, int g, int b, int a, int d, int s)
84 {
85 	using tcu::TestLog;
86 
87 	const int referenceSizes[] = {r, g, b, a, d, s};
88 	const GLenum paramNames[] =
89 	{
90 		GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE,	GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE,
91 		GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE, GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE,
92 		GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
93 	};
94 
95 	DE_STATIC_ASSERT(DE_LENGTH_OF_ARRAY(referenceSizes) == DE_LENGTH_OF_ARRAY(paramNames));
96 
97 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(referenceSizes); ++ndx)
98 	{
99 		if (referenceSizes[ndx] == -1)
100 			continue;
101 
102 		StateQueryMemoryWriteGuard<GLint> state;
103 		gl.glGetFramebufferAttachmentParameteriv(target, attachment, paramNames[ndx], &state);
104 
105 		if (!state.verifyValidity(testCtx))
106 		{
107 			gl.glGetError(); // just log the error
108 			continue;
109 		}
110 
111 		if (state != referenceSizes[ndx])
112 		{
113 			testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << referenceSizes[ndx] << "; got " << state << TestLog::EndMessage;
114 			if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
115 				testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
116 		}
117 	}
118 }
119 
checkIntEquals(tcu::TestContext & testCtx,GLint got,GLint expected)120 void checkIntEquals (tcu::TestContext& testCtx, GLint got, GLint expected)
121 {
122 	using tcu::TestLog;
123 
124 	if (got != expected)
125 	{
126 		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage;
127 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
128 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
129 	}
130 }
131 
checkIntEqualsAny(tcu::TestContext & testCtx,GLint got,GLint expected0,GLint expected1)132 void checkIntEqualsAny (tcu::TestContext& testCtx, GLint got, GLint expected0, GLint expected1)
133 {
134 	using tcu::TestLog;
135 
136 	if (got != expected0 && got != expected1)
137 	{
138 		testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected0 << " or " << expected1 << "; got " << got << TestLog::EndMessage;
139 		if (testCtx.getTestResult() == QP_TEST_RESULT_PASS)
140 			testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value");
141 	}
142 }
143 
checkAttachmentParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLenum target,GLenum attachment,GLenum pname,GLenum reference)144 void checkAttachmentParam(tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum target, GLenum attachment, GLenum pname, GLenum reference)
145 {
146 	StateQueryMemoryWriteGuard<GLint> state;
147 	gl.glGetFramebufferAttachmentParameteriv(target, attachment, pname, &state);
148 
149 	if (state.verifyValidity(testCtx))
150 		checkIntEquals(testCtx, state, reference);
151 }
152 
checkColorAttachmentParam(tcu::TestContext & testCtx,glu::CallLogWrapper & gl,GLenum target,GLenum pname,GLenum reference)153 void checkColorAttachmentParam(tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum target, GLenum pname, GLenum reference)
154 {
155 	checkAttachmentParam(testCtx, gl, target, GL_COLOR_ATTACHMENT0, pname, reference);
156 }
157 
158 class DefaultFramebufferCase : public ApiCase
159 {
160 public:
DefaultFramebufferCase(Context & context,const char * name,const char * description,GLenum framebufferTarget)161 	DefaultFramebufferCase (Context& context, const char* name, const char* description, GLenum framebufferTarget)
162 		: ApiCase				(context, name, description)
163 		, m_framebufferTarget	(framebufferTarget)
164 	{
165 	}
166 
test(void)167 	void test (void)
168 	{
169 		const bool		hasColorBuffer =	m_context.getRenderTarget().getPixelFormat().redBits   > 0 ||
170 											m_context.getRenderTarget().getPixelFormat().greenBits > 0 ||
171 											m_context.getRenderTarget().getPixelFormat().blueBits  > 0 ||
172 											m_context.getRenderTarget().getPixelFormat().alphaBits > 0;
173 		const GLenum	attachments[] =
174 		{
175 			(GLenum)(glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)) ? GL_FRONT : GL_BACK),
176 			GL_DEPTH,
177 			GL_STENCIL
178 		};
179 		const bool		attachmentExists[] =
180 		{
181 			hasColorBuffer,
182 			m_context.getRenderTarget().getDepthBits() > 0,
183 			m_context.getRenderTarget().getStencilBits() > 0
184 		};
185 
186 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(attachments); ++ndx)
187 		{
188 			StateQueryMemoryWriteGuard<GLint> state;
189 			glGetFramebufferAttachmentParameteriv(m_framebufferTarget, attachments[ndx], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &state);
190 			expectError(GL_NO_ERROR);
191 
192 			if (state.verifyValidity(m_testCtx))
193 			{
194 				if (attachmentExists[ndx])
195 				{
196 					checkIntEquals(m_testCtx, state, GL_FRAMEBUFFER_DEFAULT);
197 				}
198 				else
199 				{
200 					// \note [jarkko] FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE "identifes the type of object which contains the attached image". However, it
201 					// is unclear if an object of type FRAMEBUFFER_DEFAULT can contain a null image (or a 0-bits-per-pixel image). Accept both
202 					// FRAMEBUFFER_DEFAULT and NONE as valid results in these cases.
203 					checkIntEqualsAny(m_testCtx, state, GL_FRAMEBUFFER_DEFAULT, GL_NONE);
204 				}
205 			}
206 		}
207 	}
208 
209 private:
210 	GLenum m_framebufferTarget;
211 };
212 
213 class AttachmentObjectCase : public ApiCase
214 {
215 public:
AttachmentObjectCase(Context & context,const char * name,const char * description)216 	AttachmentObjectCase (Context& context, const char* name, const char* description)
217 		: ApiCase(context, name, description)
218 	{
219 	}
220 
test(void)221 	void test (void)
222 	{
223 		GLuint framebufferID = 0;
224 		glGenFramebuffers(1, &framebufferID);
225 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
226 		expectError(GL_NO_ERROR);
227 
228 		// initial
229 		{
230 			checkAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_NONE);
231 			checkAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 0);
232 			expectError(GL_NO_ERROR);
233 		}
234 
235 		// texture
236 		{
237 			GLuint textureID = 0;
238 			glGenTextures(1, &textureID);
239 			glBindTexture(GL_TEXTURE_2D, textureID);
240 			glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL);
241 			expectError(GL_NO_ERROR);
242 
243 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
244 			expectError(GL_NO_ERROR);
245 
246 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
247 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, textureID);
248 
249 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
250 			glDeleteTextures(1, &textureID);
251 		}
252 
253 		// rb
254 		{
255 			GLuint renderbufferID = 0;
256 			glGenRenderbuffers(1, &renderbufferID);
257 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
258 			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8, 128, 128);
259 			expectError(GL_NO_ERROR);
260 
261 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
262 			expectError(GL_NO_ERROR);
263 
264 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_RENDERBUFFER);
265 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, renderbufferID);
266 
267 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
268 			glDeleteRenderbuffers(1, &renderbufferID);
269 		}
270 
271 		glDeleteFramebuffers(1, &framebufferID);
272 		expectError(GL_NO_ERROR);
273 	}
274 };
275 
276 class AttachmentTextureLevelCase : public ApiCase
277 {
278 public:
AttachmentTextureLevelCase(Context & context,const char * name,const char * description)279 	AttachmentTextureLevelCase (Context& context, const char* name, const char* description)
280 		: ApiCase(context, name, description)
281 	{
282 	}
283 
test(void)284 	void test (void)
285 	{
286 		GLuint framebufferID = 0;
287 		glGenFramebuffers(1, &framebufferID);
288 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
289 		expectError(GL_NO_ERROR);
290 
291 		for (int mipmapLevel = 0; mipmapLevel < 7; ++mipmapLevel)
292 		{
293 			GLuint textureID = 0;
294 			glGenTextures(1, &textureID);
295 			glBindTexture(GL_TEXTURE_2D, textureID);
296 			glTexStorage2D(GL_TEXTURE_2D, 7, GL_RGB8, 128, 128);
297 			expectError(GL_NO_ERROR);
298 
299 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, mipmapLevel);
300 			expectError(GL_NO_ERROR);
301 
302 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, mipmapLevel);
303 
304 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
305 			glDeleteTextures(1, &textureID);
306 		}
307 
308 		glDeleteFramebuffers(1, &framebufferID);
309 		expectError(GL_NO_ERROR);
310 	}
311 };
312 
313 class AttachmentTextureCubeMapFaceCase : public ApiCase
314 {
315 public:
AttachmentTextureCubeMapFaceCase(Context & context,const char * name,const char * description)316 	AttachmentTextureCubeMapFaceCase (Context& context, const char* name, const char* description)
317 		: ApiCase(context, name, description)
318 	{
319 	}
320 
test(void)321 	void test (void)
322 	{
323 		GLuint framebufferID = 0;
324 		glGenFramebuffers(1, &framebufferID);
325 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
326 		expectError(GL_NO_ERROR);
327 
328 		{
329 			GLuint textureID = 0;
330 			glGenTextures(1, &textureID);
331 			glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
332 			expectError(GL_NO_ERROR);
333 
334 			glTexStorage2D(GL_TEXTURE_CUBE_MAP, 1, GL_RGB8, 128, 128);
335 			expectError(GL_NO_ERROR);
336 
337 			const GLenum faces[] =
338 			{
339 				GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
340 				GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
341 				GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
342 			};
343 
344 			for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(faces); ++ndx)
345 			{
346 				glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, faces[ndx], textureID, 0);
347 				checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, faces[ndx]);
348 			}
349 
350 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
351 			glDeleteTextures(1, &textureID);
352 		}
353 
354 		glDeleteFramebuffers(1, &framebufferID);
355 		expectError(GL_NO_ERROR);
356 	}
357 };
358 
359 class AttachmentTextureLayerCase : public ApiCase
360 {
361 public:
AttachmentTextureLayerCase(Context & context,const char * name,const char * description)362 	AttachmentTextureLayerCase (Context& context, const char* name, const char* description)
363 		: ApiCase(context, name, description)
364 	{
365 	}
366 
test(void)367 	void test (void)
368 	{
369 		GLuint framebufferID = 0;
370 		glGenFramebuffers(1, &framebufferID);
371 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
372 		expectError(GL_NO_ERROR);
373 
374 		// tex3d
375 		{
376 			GLuint textureID = 0;
377 			glGenTextures(1, &textureID);
378 			glBindTexture(GL_TEXTURE_3D, textureID);
379 			glTexStorage3D(GL_TEXTURE_3D, 1, GL_RGBA8, 16, 16, 16);
380 
381 			for (int layer = 0; layer < 16; ++layer)
382 			{
383 				glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureID, 0, layer);
384 				checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER, layer);
385 			}
386 
387 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
388 			glDeleteTextures(1, &textureID);
389 		}
390 		// tex2d array
391 		{
392 			GLuint textureID = 0;
393 			glGenTextures(1, &textureID);
394 			glBindTexture(GL_TEXTURE_2D_ARRAY, textureID);
395 			glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_RGBA8, 16, 16, 16);
396 
397 			for (int layer = 0; layer < 16; ++layer)
398 			{
399 				glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textureID, 0, layer);
400 				checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER, layer);
401 			}
402 
403 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
404 			glDeleteTextures(1, &textureID);
405 		}
406 
407 		glDeleteFramebuffers(1, &framebufferID);
408 		expectError(GL_NO_ERROR);
409 	}
410 };
411 
412 class AttachmentTextureColorCodingCase : public ApiCase
413 {
414 public:
AttachmentTextureColorCodingCase(Context & context,const char * name,const char * description)415 	AttachmentTextureColorCodingCase (Context& context, const char* name, const char* description)
416 		: ApiCase(context, name, description)
417 	{
418 	}
419 
test(void)420 	void test (void)
421 	{
422 		GLuint framebufferID = 0;
423 		glGenFramebuffers(1, &framebufferID);
424 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
425 		expectError(GL_NO_ERROR);
426 
427 		// rgb8 color
428 		{
429 			GLuint renderbufferID = 0;
430 			glGenRenderbuffers(1, &renderbufferID);
431 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
432 			glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8, 128, 128);
433 			expectError(GL_NO_ERROR);
434 
435 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
436 			expectError(GL_NO_ERROR);
437 
438 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_LINEAR);
439 
440 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
441 			glDeleteRenderbuffers(1, &renderbufferID);
442 		}
443 
444 		// srgb8_alpha8 color
445 		{
446 			GLuint renderbufferID = 0;
447 			glGenRenderbuffers(1, &renderbufferID);
448 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
449 			glRenderbufferStorage(GL_RENDERBUFFER, GL_SRGB8_ALPHA8, 128, 128);
450 			expectError(GL_NO_ERROR);
451 
452 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
453 			expectError(GL_NO_ERROR);
454 
455 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_SRGB);
456 
457 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
458 			glDeleteRenderbuffers(1, &renderbufferID);
459 		}
460 
461 		// depth
462 		{
463 			GLuint renderbufferID = 0;
464 			glGenRenderbuffers(1, &renderbufferID);
465 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
466 			glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, 128, 128);
467 			expectError(GL_NO_ERROR);
468 
469 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbufferID);
470 			expectError(GL_NO_ERROR);
471 
472 			checkAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_LINEAR);
473 
474 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
475 			glDeleteRenderbuffers(1, &renderbufferID);
476 		}
477 
478 		glDeleteFramebuffers(1, &framebufferID);
479 		expectError(GL_NO_ERROR);
480 	}
481 };
482 
483 class AttachmentTextureComponentTypeCase : public ApiCase
484 {
485 public:
AttachmentTextureComponentTypeCase(Context & context,const char * name,const char * description)486 	AttachmentTextureComponentTypeCase (Context& context, const char* name, const char* description)
487 		: ApiCase(context, name, description)
488 	{
489 	}
490 
test(void)491 	void test (void)
492 	{
493 		GLuint framebufferID = 0;
494 		glGenFramebuffers(1, &framebufferID);
495 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
496 		expectError(GL_NO_ERROR);
497 
498 		// color-renderable required texture formats
499 		const struct RequiredColorFormat
500 		{
501 			GLenum internalFormat;
502 			GLenum componentType;
503 		} requiredColorformats[] =
504 		{
505 			{ GL_R8,			GL_UNSIGNED_NORMALIZED	},
506 			{ GL_RG8,			GL_UNSIGNED_NORMALIZED	},
507 			{ GL_RGB8,			GL_UNSIGNED_NORMALIZED	},
508 			{ GL_RGB565,		GL_UNSIGNED_NORMALIZED	},
509 			{ GL_RGBA4,			GL_UNSIGNED_NORMALIZED	},
510 			{ GL_RGB5_A1,		GL_UNSIGNED_NORMALIZED	},
511 			{ GL_RGBA8,			GL_UNSIGNED_NORMALIZED	},
512 			{ GL_RGB10_A2,		GL_UNSIGNED_NORMALIZED	},
513 			{ GL_RGB10_A2UI,	GL_UNSIGNED_INT			},
514 			{ GL_SRGB8_ALPHA8,	GL_UNSIGNED_NORMALIZED	},
515 			{ GL_R8I,			GL_INT					},
516 			{ GL_R8UI,			GL_UNSIGNED_INT			},
517 			{ GL_R16I,			GL_INT					},
518 			{ GL_R16UI,			GL_UNSIGNED_INT			},
519 			{ GL_R32I,			GL_INT					},
520 			{ GL_R32UI,			GL_UNSIGNED_INT			},
521 			{ GL_RG8I,			GL_INT					},
522 			{ GL_RG8UI,			GL_UNSIGNED_INT			},
523 			{ GL_RG16I,			GL_INT					},
524 			{ GL_RG16UI,		GL_UNSIGNED_INT			},
525 			{ GL_RG32I,			GL_INT					},
526 			{ GL_RG32UI,		GL_UNSIGNED_INT			},
527 			{ GL_RGBA8I,		GL_INT					},
528 			{ GL_RGBA8UI,		GL_UNSIGNED_INT			},
529 			{ GL_RGBA16I,		GL_INT					},
530 			{ GL_RGBA16UI,		GL_UNSIGNED_INT			},
531 			{ GL_RGBA32I,		GL_INT					},
532 			{ GL_RGBA32UI,		GL_UNSIGNED_INT			}
533 		};
534 
535 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(requiredColorformats); ++ndx)
536 		{
537 			const GLenum colorFormat = requiredColorformats[ndx].internalFormat;
538 
539 			GLuint textureID = 0;
540 			glGenTextures(1, &textureID);
541 			glBindTexture(GL_TEXTURE_2D, textureID);
542 			glTexStorage2D(GL_TEXTURE_2D, 1, colorFormat, 128, 128);
543 			expectError(GL_NO_ERROR);
544 
545 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
546 			expectError(GL_NO_ERROR);
547 
548 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, requiredColorformats[ndx].componentType);
549 
550 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
551 			glDeleteTextures(1, &textureID);
552 		}
553 
554 		glDeleteFramebuffers(1, &framebufferID);
555 		expectError(GL_NO_ERROR);
556 	}
557 };
558 
559 class AttachmentSizeInitialCase : public ApiCase
560 {
561 public:
AttachmentSizeInitialCase(Context & context,const char * name,const char * description)562 	AttachmentSizeInitialCase (Context& context, const char* name, const char* description)
563 		: ApiCase(context, name, description)
564 	{
565 	}
566 
test(void)567 	void test (void)
568 	{
569 		const GLenum colorAttachment = (glu::contextSupports(m_context.getRenderContext().getType(), glu::ApiType::core(4, 5)) ? GL_FRONT : GL_BACK);
570 		// check default
571 		if (attachmentExists(colorAttachment))
572 		{
573 			checkAttachmentComponentSizeAtLeast(
574 				m_testCtx,
575 				*this,
576 				GL_FRAMEBUFFER,
577 				colorAttachment,
578 				m_context.getRenderTarget().getPixelFormat().redBits,
579 				m_context.getRenderTarget().getPixelFormat().greenBits,
580 				m_context.getRenderTarget().getPixelFormat().blueBits,
581 				m_context.getRenderTarget().getPixelFormat().alphaBits,
582 				-1,
583 				-1);
584 			expectError(GL_NO_ERROR);
585 		}
586 
587 		if (attachmentExists(GL_DEPTH))
588 		{
589 			checkAttachmentComponentSizeAtLeast(
590 				m_testCtx,
591 				*this,
592 				GL_FRAMEBUFFER,
593 				GL_DEPTH,
594 				-1,
595 				-1,
596 				-1,
597 				-1,
598 				m_context.getRenderTarget().getDepthBits(),
599 				-1);
600 			expectError(GL_NO_ERROR);
601 		}
602 
603 		if (attachmentExists(GL_STENCIL))
604 		{
605 			checkAttachmentComponentSizeAtLeast(
606 				m_testCtx,
607 				*this,
608 				GL_FRAMEBUFFER,
609 				GL_STENCIL,
610 				-1,
611 				-1,
612 				-1,
613 				-1,
614 				-1,
615 				m_context.getRenderTarget().getStencilBits());
616 			expectError(GL_NO_ERROR);
617 		}
618 	}
619 
attachmentExists(GLenum attachment)620 	bool attachmentExists (GLenum attachment)
621 	{
622 		StateQueryMemoryWriteGuard<GLint> state;
623 		glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &state);
624 		expectError(GL_NO_ERROR);
625 
626 		return !state.isUndefined() && state != GL_NONE;
627 	}
628 };
629 
630 class AttachmentSizeCase : public ApiCase
631 {
632 public:
AttachmentSizeCase(Context & context,const char * name,const char * description)633 	AttachmentSizeCase (Context& context, const char* name, const char* description)
634 		: ApiCase(context, name, description)
635 	{
636 	}
637 
638 	virtual void testColorAttachment (GLenum internalFormat, GLenum attachment, GLint bitsR, GLint bitsG, GLint bitsB, GLint bitsA) = DE_NULL;
639 
640 	virtual void testDepthAttachment (GLenum internalFormat, GLenum attachment, GLint bitsD, GLint bitsS) = DE_NULL;
641 
test(void)642 	void test (void)
643 	{
644 		GLuint framebufferID = 0;
645 		glGenFramebuffers(1, &framebufferID);
646 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
647 		expectError(GL_NO_ERROR);
648 
649 		// check some color targets
650 
651 		const struct ColorAttachment
652 		{
653 			GLenum	internalFormat;
654 			int		bitsR, bitsG, bitsB, bitsA;
655 		} colorAttachments[] =
656 		{
657 			{ GL_RGBA8,		8,	8,	8,	8 },
658 			{ GL_RGB565,	5,	6,	5,	0 },
659 			{ GL_RGBA4,		4,	4,	4,	4 },
660 			{ GL_RGB5_A1,	5,	5,	5,	1 },
661 			{ GL_RGBA8I,	8,	8,	8,	8 },
662 			{ GL_RG32UI,	32,	32,	0,	0 }
663 		};
664 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorAttachments); ++ndx)
665 			testColorAttachment(colorAttachments[ndx].internalFormat, GL_COLOR_ATTACHMENT0, colorAttachments[ndx].bitsR, colorAttachments[ndx].bitsG, colorAttachments[ndx].bitsB, colorAttachments[ndx].bitsA);
666 
667 		// check some depth targets
668 
669 		const struct DepthAttachment
670 		{
671 			GLenum	internalFormat;
672 			GLenum	attachment;
673 			int		dbits;
674 			int		sbits;
675 		} depthAttachments[] =
676 		{
677 			{ GL_DEPTH_COMPONENT16,		GL_DEPTH_ATTACHMENT,			16, 0 },
678 			{ GL_DEPTH_COMPONENT24,		GL_DEPTH_ATTACHMENT,			24, 0 },
679 			{ GL_DEPTH_COMPONENT32F,	GL_DEPTH_ATTACHMENT,			32, 0 },
680 			{ GL_DEPTH24_STENCIL8,		GL_DEPTH_STENCIL_ATTACHMENT,	24, 8 },
681 			{ GL_DEPTH32F_STENCIL8,		GL_DEPTH_STENCIL_ATTACHMENT,	32, 8 },
682 		};
683 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthAttachments); ++ndx)
684 			testDepthAttachment(depthAttachments[ndx].internalFormat, depthAttachments[ndx].attachment, depthAttachments[ndx].dbits, depthAttachments[ndx].sbits);
685 
686 		glDeleteFramebuffers(1, &framebufferID);
687 		expectError(GL_NO_ERROR);
688 	}
689 };
690 
691 class AttachmentSizeRboCase : public AttachmentSizeCase
692 {
693 public:
AttachmentSizeRboCase(Context & context,const char * name,const char * description)694 	AttachmentSizeRboCase (Context& context, const char* name, const char* description)
695 		: AttachmentSizeCase(context, name, description)
696 	{
697 	}
698 
testColorAttachment(GLenum internalFormat,GLenum attachment,GLint bitsR,GLint bitsG,GLint bitsB,GLint bitsA)699 	void testColorAttachment (GLenum internalFormat, GLenum attachment, GLint bitsR, GLint bitsG, GLint bitsB, GLint bitsA)
700 	{
701 		GLuint renderbufferID = 0;
702 		glGenRenderbuffers(1, &renderbufferID);
703 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
704 		glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, 128, 128);
705 		expectError(GL_NO_ERROR);
706 
707 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, renderbufferID);
708 		expectError(GL_NO_ERROR);
709 
710 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, bitsR, bitsG, bitsB, bitsA, -1, -1);
711 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, 0, 0);
712 
713 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, 0);
714 		glDeleteRenderbuffers(1, &renderbufferID);
715 	}
716 
testDepthAttachment(GLenum internalFormat,GLenum attachment,GLint bitsD,GLint bitsS)717 	void testDepthAttachment (GLenum internalFormat, GLenum attachment, GLint bitsD, GLint bitsS)
718 	{
719 		GLuint renderbufferID = 0;
720 		glGenRenderbuffers(1, &renderbufferID);
721 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
722 		glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, 128, 128);
723 		expectError(GL_NO_ERROR);
724 
725 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, renderbufferID);
726 		expectError(GL_NO_ERROR);
727 
728 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, bitsD, bitsS);
729 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, 0, 0, 0, 0, -1, -1);
730 
731 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, 0);
732 		glDeleteRenderbuffers(1, &renderbufferID);
733 	}
734 };
735 
736 class AttachmentSizeTextureCase : public AttachmentSizeCase
737 {
738 public:
AttachmentSizeTextureCase(Context & context,const char * name,const char * description)739 	AttachmentSizeTextureCase (Context& context, const char* name, const char* description)
740 		: AttachmentSizeCase(context, name, description)
741 	{
742 	}
743 
testColorAttachment(GLenum internalFormat,GLenum attachment,GLint bitsR,GLint bitsG,GLint bitsB,GLint bitsA)744 	void testColorAttachment (GLenum internalFormat, GLenum attachment, GLint bitsR, GLint bitsG, GLint bitsB, GLint bitsA)
745 	{
746 		GLuint textureID = 0;
747 		glGenTextures(1, &textureID);
748 		glBindTexture(GL_TEXTURE_2D, textureID);
749 		glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 128, 128);
750 		expectError(GL_NO_ERROR);
751 
752 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textureID, 0);
753 		expectError(GL_NO_ERROR);
754 
755 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, bitsR, bitsG, bitsB, bitsA, -1, -1);
756 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, 0, 0);
757 
758 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, 0, 0);
759 		glDeleteTextures(1, &textureID);
760 	}
761 
testDepthAttachment(GLenum internalFormat,GLenum attachment,GLint bitsD,GLint bitsS)762 	void testDepthAttachment (GLenum internalFormat, GLenum attachment, GLint bitsD, GLint bitsS)
763 	{
764 		// don't test stencil formats with textures
765 		if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
766 			return;
767 
768 		GLuint textureID = 0;
769 		glGenTextures(1, &textureID);
770 		glBindTexture(GL_TEXTURE_2D, textureID);
771 		glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 128, 128);
772 		expectError(GL_NO_ERROR);
773 
774 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textureID, 0);
775 		expectError(GL_NO_ERROR);
776 
777 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, bitsD, bitsS);
778 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, 0, 0, 0, 0, -1, -1);
779 
780 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, 0, 0);
781 		glDeleteTextures(1, &textureID);
782 	}
783 };
784 
785 class UnspecifiedAttachmentTextureColorCodingCase : public ApiCase
786 {
787 public:
UnspecifiedAttachmentTextureColorCodingCase(Context & context,const char * name,const char * description)788 	UnspecifiedAttachmentTextureColorCodingCase (Context& context, const char* name, const char* description)
789 		: ApiCase(context, name, description)
790 	{
791 	}
792 
test(void)793 	void test (void)
794 	{
795 		GLuint framebufferID = 0;
796 		glGenFramebuffers(1, &framebufferID);
797 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
798 		expectError(GL_NO_ERROR);
799 
800 		// color
801 		{
802 			GLuint renderbufferID = 0;
803 			glGenRenderbuffers(1, &renderbufferID);
804 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
805 			expectError(GL_NO_ERROR);
806 
807 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
808 			expectError(GL_NO_ERROR);
809 
810 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_LINEAR);
811 			expectError(GL_NO_ERROR);
812 
813 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
814 			glDeleteRenderbuffers(1, &renderbufferID);
815 		}
816 
817 		// depth
818 		{
819 			GLuint renderbufferID = 0;
820 			glGenRenderbuffers(1, &renderbufferID);
821 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
822 			expectError(GL_NO_ERROR);
823 
824 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbufferID);
825 			expectError(GL_NO_ERROR);
826 
827 			checkAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_LINEAR);
828 
829 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
830 			glDeleteRenderbuffers(1, &renderbufferID);
831 		}
832 
833 		glDeleteFramebuffers(1, &framebufferID);
834 		expectError(GL_NO_ERROR);
835 	}
836 };
837 
838 class UnspecifiedAttachmentTextureComponentTypeCase : public ApiCase
839 {
840 public:
UnspecifiedAttachmentTextureComponentTypeCase(Context & context,const char * name,const char * description)841 	UnspecifiedAttachmentTextureComponentTypeCase (Context& context, const char* name, const char* description)
842 		: ApiCase(context, name, description)
843 	{
844 	}
845 
test(void)846 	void test (void)
847 	{
848 		GLuint framebufferID = 0;
849 		glGenFramebuffers(1, &framebufferID);
850 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
851 		expectError(GL_NO_ERROR);
852 
853 		{
854 			GLuint textureID = 0;
855 			glGenTextures(1, &textureID);
856 			glBindTexture(GL_TEXTURE_2D, textureID);
857 			expectError(GL_NO_ERROR);
858 
859 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
860 			expectError(GL_NO_ERROR);
861 
862 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, GL_NONE);
863 			expectError(GL_NO_ERROR);
864 
865 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
866 			glDeleteTextures(1, &textureID);
867 		}
868 
869 		glDeleteFramebuffers(1, &framebufferID);
870 		expectError(GL_NO_ERROR);
871 	}
872 };
873 
874 class UnspecifiedAttachmentSizeCase : public ApiCase
875 {
876 public:
UnspecifiedAttachmentSizeCase(Context & context,const char * name,const char * description)877 	UnspecifiedAttachmentSizeCase (Context& context, const char* name, const char* description)
878 		: ApiCase(context, name, description)
879 	{
880 	}
881 
882 	virtual void testColorAttachment (void) = DE_NULL;
883 
884 	virtual void testDepthAttachment (void) = DE_NULL;
885 
test(void)886 	void test (void)
887 	{
888 		GLuint framebufferID = 0;
889 		glGenFramebuffers(1, &framebufferID);
890 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
891 		expectError(GL_NO_ERROR);
892 
893 		// check color target
894 		testColorAttachment();
895 
896 		// check depth target
897 		testDepthAttachment();
898 
899 		glDeleteFramebuffers(1, &framebufferID);
900 		expectError(GL_NO_ERROR);
901 	}
902 };
903 
904 class UnspecifiedAttachmentSizeRboCase : public UnspecifiedAttachmentSizeCase
905 {
906 public:
UnspecifiedAttachmentSizeRboCase(Context & context,const char * name,const char * description)907 	UnspecifiedAttachmentSizeRboCase (Context& context, const char* name, const char* description)
908 		: UnspecifiedAttachmentSizeCase(context, name, description)
909 	{
910 	}
911 
testColorAttachment(void)912 	void testColorAttachment (void)
913 	{
914 		GLuint renderbufferID = 0;
915 		glGenRenderbuffers(1, &renderbufferID);
916 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
917 		expectError(GL_NO_ERROR);
918 
919 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
920 		expectError(GL_NO_ERROR);
921 
922 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0, 0, 0, 0, 0);
923 		expectError(GL_NO_ERROR);
924 
925 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
926 		glDeleteRenderbuffers(1, &renderbufferID);
927 	}
928 
testDepthAttachment(void)929 	void testDepthAttachment (void)
930 	{
931 		GLuint renderbufferID = 0;
932 		glGenRenderbuffers(1, &renderbufferID);
933 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
934 		expectError(GL_NO_ERROR);
935 
936 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbufferID);
937 		expectError(GL_NO_ERROR);
938 
939 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0, 0, 0, 0, 0);
940 		expectError(GL_NO_ERROR);
941 
942 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
943 		glDeleteRenderbuffers(1, &renderbufferID);
944 	}
945 };
946 
947 class UnspecifiedAttachmentSizeTextureCase : public UnspecifiedAttachmentSizeCase
948 {
949 public:
UnspecifiedAttachmentSizeTextureCase(Context & context,const char * name,const char * description)950 	UnspecifiedAttachmentSizeTextureCase (Context& context, const char* name, const char* description)
951 		: UnspecifiedAttachmentSizeCase(context, name, description)
952 	{
953 	}
954 
testColorAttachment(void)955 	void testColorAttachment (void)
956 	{
957 		GLuint textureID = 0;
958 		glGenTextures(1, &textureID);
959 		glBindTexture(GL_TEXTURE_2D, textureID);
960 		expectError(GL_NO_ERROR);
961 
962 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
963 		expectError(GL_NO_ERROR);
964 
965 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0, 0, 0, 0, 0);
966 		expectError(GL_NO_ERROR);
967 
968 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
969 		glDeleteTextures(1, &textureID);
970 	}
971 
testDepthAttachment(void)972 	void testDepthAttachment (void)
973 	{
974 		GLuint textureID = 0;
975 		glGenTextures(1, &textureID);
976 		glBindTexture(GL_TEXTURE_2D, textureID);
977 		expectError(GL_NO_ERROR);
978 
979 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, textureID, 0);
980 		expectError(GL_NO_ERROR);
981 
982 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0, 0, 0, 0, 0);
983 		expectError(GL_NO_ERROR);
984 
985 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
986 		glDeleteTextures(1, &textureID);
987 	}
988 };
989 
990 } // anonymous
991 
992 
FboStateQueryTests(Context & context)993 FboStateQueryTests::FboStateQueryTests (Context& context)
994 	: TestCaseGroup(context, "fbo", "Fbo State Query tests")
995 {
996 }
997 
init(void)998 void FboStateQueryTests::init (void)
999 {
1000 	const struct FramebufferTarget
1001 	{
1002 		const char*	name;
1003 		GLenum		target;
1004 	} fboTargets[] =
1005 	{
1006 		{ "draw_framebuffer_", GL_DRAW_FRAMEBUFFER },
1007 		{ "read_framebuffer_", GL_READ_FRAMEBUFFER }
1008 	};
1009 
1010 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fboTargets); ++ndx)
1011 		addChild(new DefaultFramebufferCase(m_context, (std::string(fboTargets[ndx].name) + "default_framebuffer").c_str(), "default framebuffer", fboTargets[ndx].target));
1012 
1013 	addChild(new AttachmentObjectCase							(m_context, "framebuffer_attachment_object",							"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE and FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"));
1014 	addChild(new AttachmentTextureLevelCase						(m_context, "framebuffer_attachment_texture_level",						"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"));
1015 	addChild(new AttachmentTextureCubeMapFaceCase				(m_context, "framebuffer_attachment_texture_cube_map_face",				"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"));
1016 	addChild(new AttachmentTextureLayerCase						(m_context, "framebuffer_attachment_texture_layer",						"FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"));
1017 	addChild(new AttachmentTextureColorCodingCase				(m_context, "framebuffer_attachment_color_encoding",					"FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"));
1018 	addChild(new AttachmentTextureComponentTypeCase				(m_context, "framebuffer_attachment_component_type",					"FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"));
1019 	addChild(new AttachmentSizeInitialCase						(m_context, "framebuffer_attachment_x_size_initial",					"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1020 	addChild(new AttachmentSizeRboCase							(m_context, "framebuffer_attachment_x_size_rbo",						"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1021 	addChild(new AttachmentSizeTextureCase						(m_context, "framebuffer_attachment_x_size_texture",					"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1022 
1023 	addChild(new UnspecifiedAttachmentTextureColorCodingCase	(m_context, "framebuffer_unspecified_attachment_color_encoding",		"FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"));
1024 	addChild(new UnspecifiedAttachmentTextureComponentTypeCase	(m_context, "framebuffer_unspecified_attachment_component_type",		"FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"));
1025 	addChild(new UnspecifiedAttachmentSizeRboCase				(m_context, "framebuffer_unspecified_attachment_x_size_rbo",			"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1026 	addChild(new UnspecifiedAttachmentSizeTextureCase			(m_context, "framebuffer_unspecified_attachment_x_size_texture",		"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1027 }
1028 
1029 } // Functional
1030 } // gles3
1031 } // deqp
1032