• 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 			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 		// check default
570 		if (attachmentExists(GL_BACK))
571 		{
572 			checkAttachmentComponentSizeAtLeast(
573 				m_testCtx,
574 				*this,
575 				GL_FRAMEBUFFER,
576 				GL_BACK,
577 				m_context.getRenderTarget().getPixelFormat().redBits,
578 				m_context.getRenderTarget().getPixelFormat().greenBits,
579 				m_context.getRenderTarget().getPixelFormat().blueBits,
580 				m_context.getRenderTarget().getPixelFormat().alphaBits,
581 				-1,
582 				-1);
583 			expectError(GL_NO_ERROR);
584 		}
585 
586 		if (attachmentExists(GL_DEPTH))
587 		{
588 			checkAttachmentComponentSizeAtLeast(
589 				m_testCtx,
590 				*this,
591 				GL_FRAMEBUFFER,
592 				GL_DEPTH,
593 				-1,
594 				-1,
595 				-1,
596 				-1,
597 				m_context.getRenderTarget().getDepthBits(),
598 				-1);
599 			expectError(GL_NO_ERROR);
600 		}
601 
602 		if (attachmentExists(GL_STENCIL))
603 		{
604 			checkAttachmentComponentSizeAtLeast(
605 				m_testCtx,
606 				*this,
607 				GL_FRAMEBUFFER,
608 				GL_STENCIL,
609 				-1,
610 				-1,
611 				-1,
612 				-1,
613 				-1,
614 				m_context.getRenderTarget().getStencilBits());
615 			expectError(GL_NO_ERROR);
616 		}
617 	}
618 
attachmentExists(GLenum attachment)619 	bool attachmentExists (GLenum attachment)
620 	{
621 		StateQueryMemoryWriteGuard<GLint> state;
622 		glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &state);
623 		expectError(GL_NO_ERROR);
624 
625 		return !state.isUndefined() && state != GL_NONE;
626 	}
627 };
628 
629 class AttachmentSizeCase : public ApiCase
630 {
631 public:
AttachmentSizeCase(Context & context,const char * name,const char * description)632 	AttachmentSizeCase (Context& context, const char* name, const char* description)
633 		: ApiCase(context, name, description)
634 	{
635 	}
636 
637 	virtual void testColorAttachment (GLenum internalFormat, GLenum attachment, GLint bitsR, GLint bitsG, GLint bitsB, GLint bitsA) = DE_NULL;
638 
639 	virtual void testDepthAttachment (GLenum internalFormat, GLenum attachment, GLint bitsD, GLint bitsS) = DE_NULL;
640 
test(void)641 	void test (void)
642 	{
643 		GLuint framebufferID = 0;
644 		glGenFramebuffers(1, &framebufferID);
645 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
646 		expectError(GL_NO_ERROR);
647 
648 		// check some color targets
649 
650 		const struct ColorAttachment
651 		{
652 			GLenum	internalFormat;
653 			int		bitsR, bitsG, bitsB, bitsA;
654 		} colorAttachments[] =
655 		{
656 			{ GL_RGBA8,		8,	8,	8,	8 },
657 			{ GL_RGB565,	5,	6,	5,	0 },
658 			{ GL_RGBA4,		4,	4,	4,	4 },
659 			{ GL_RGB5_A1,	5,	5,	5,	1 },
660 			{ GL_RGBA8I,	8,	8,	8,	8 },
661 			{ GL_RG32UI,	32,	32,	0,	0 }
662 		};
663 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(colorAttachments); ++ndx)
664 			testColorAttachment(colorAttachments[ndx].internalFormat, GL_COLOR_ATTACHMENT0, colorAttachments[ndx].bitsR, colorAttachments[ndx].bitsG, colorAttachments[ndx].bitsB, colorAttachments[ndx].bitsA);
665 
666 		// check some depth targets
667 
668 		const struct DepthAttachment
669 		{
670 			GLenum	internalFormat;
671 			GLenum	attachment;
672 			int		dbits;
673 			int		sbits;
674 		} depthAttachments[] =
675 		{
676 			{ GL_DEPTH_COMPONENT16,		GL_DEPTH_ATTACHMENT,			16, 0 },
677 			{ GL_DEPTH_COMPONENT24,		GL_DEPTH_ATTACHMENT,			24, 0 },
678 			{ GL_DEPTH_COMPONENT32F,	GL_DEPTH_ATTACHMENT,			32, 0 },
679 			{ GL_DEPTH24_STENCIL8,		GL_DEPTH_STENCIL_ATTACHMENT,	24, 8 },
680 			{ GL_DEPTH32F_STENCIL8,		GL_DEPTH_STENCIL_ATTACHMENT,	32, 8 },
681 		};
682 		for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(depthAttachments); ++ndx)
683 			testDepthAttachment(depthAttachments[ndx].internalFormat, depthAttachments[ndx].attachment, depthAttachments[ndx].dbits, depthAttachments[ndx].sbits);
684 
685 		glDeleteFramebuffers(1, &framebufferID);
686 		expectError(GL_NO_ERROR);
687 	}
688 };
689 
690 class AttachmentSizeRboCase : public AttachmentSizeCase
691 {
692 public:
AttachmentSizeRboCase(Context & context,const char * name,const char * description)693 	AttachmentSizeRboCase (Context& context, const char* name, const char* description)
694 		: AttachmentSizeCase(context, name, description)
695 	{
696 	}
697 
testColorAttachment(GLenum internalFormat,GLenum attachment,GLint bitsR,GLint bitsG,GLint bitsB,GLint bitsA)698 	void testColorAttachment (GLenum internalFormat, GLenum attachment, GLint bitsR, GLint bitsG, GLint bitsB, GLint bitsA)
699 	{
700 		GLuint renderbufferID = 0;
701 		glGenRenderbuffers(1, &renderbufferID);
702 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
703 		glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, 128, 128);
704 		expectError(GL_NO_ERROR);
705 
706 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, renderbufferID);
707 		expectError(GL_NO_ERROR);
708 
709 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, bitsR, bitsG, bitsB, bitsA, -1, -1);
710 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, 0, 0);
711 
712 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, 0);
713 		glDeleteRenderbuffers(1, &renderbufferID);
714 	}
715 
testDepthAttachment(GLenum internalFormat,GLenum attachment,GLint bitsD,GLint bitsS)716 	void testDepthAttachment (GLenum internalFormat, GLenum attachment, GLint bitsD, GLint bitsS)
717 	{
718 		GLuint renderbufferID = 0;
719 		glGenRenderbuffers(1, &renderbufferID);
720 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
721 		glRenderbufferStorage(GL_RENDERBUFFER, internalFormat, 128, 128);
722 		expectError(GL_NO_ERROR);
723 
724 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, renderbufferID);
725 		expectError(GL_NO_ERROR);
726 
727 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, bitsD, bitsS);
728 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, 0, 0, 0, 0, -1, -1);
729 
730 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, 0);
731 		glDeleteRenderbuffers(1, &renderbufferID);
732 	}
733 };
734 
735 class AttachmentSizeTextureCase : public AttachmentSizeCase
736 {
737 public:
AttachmentSizeTextureCase(Context & context,const char * name,const char * description)738 	AttachmentSizeTextureCase (Context& context, const char* name, const char* description)
739 		: AttachmentSizeCase(context, name, description)
740 	{
741 	}
742 
testColorAttachment(GLenum internalFormat,GLenum attachment,GLint bitsR,GLint bitsG,GLint bitsB,GLint bitsA)743 	void testColorAttachment (GLenum internalFormat, GLenum attachment, GLint bitsR, GLint bitsG, GLint bitsB, GLint bitsA)
744 	{
745 		GLuint textureID = 0;
746 		glGenTextures(1, &textureID);
747 		glBindTexture(GL_TEXTURE_2D, textureID);
748 		glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 128, 128);
749 		expectError(GL_NO_ERROR);
750 
751 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textureID, 0);
752 		expectError(GL_NO_ERROR);
753 
754 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, bitsR, bitsG, bitsB, bitsA, -1, -1);
755 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, 0, 0);
756 
757 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, 0, 0);
758 		glDeleteTextures(1, &textureID);
759 	}
760 
testDepthAttachment(GLenum internalFormat,GLenum attachment,GLint bitsD,GLint bitsS)761 	void testDepthAttachment (GLenum internalFormat, GLenum attachment, GLint bitsD, GLint bitsS)
762 	{
763 		// don't test stencil formats with textures
764 		if (attachment == GL_DEPTH_STENCIL_ATTACHMENT)
765 			return;
766 
767 		GLuint textureID = 0;
768 		glGenTextures(1, &textureID);
769 		glBindTexture(GL_TEXTURE_2D, textureID);
770 		glTexStorage2D(GL_TEXTURE_2D, 1, internalFormat, 128, 128);
771 		expectError(GL_NO_ERROR);
772 
773 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, textureID, 0);
774 		expectError(GL_NO_ERROR);
775 
776 		checkAttachmentComponentSizeAtLeast	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, -1, -1, -1, -1, bitsD, bitsS);
777 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, attachment, 0, 0, 0, 0, -1, -1);
778 
779 		glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, 0, 0);
780 		glDeleteTextures(1, &textureID);
781 	}
782 };
783 
784 class UnspecifiedAttachmentTextureColorCodingCase : public ApiCase
785 {
786 public:
UnspecifiedAttachmentTextureColorCodingCase(Context & context,const char * name,const char * description)787 	UnspecifiedAttachmentTextureColorCodingCase (Context& context, const char* name, const char* description)
788 		: ApiCase(context, name, description)
789 	{
790 	}
791 
test(void)792 	void test (void)
793 	{
794 		GLuint framebufferID = 0;
795 		glGenFramebuffers(1, &framebufferID);
796 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
797 		expectError(GL_NO_ERROR);
798 
799 		// color
800 		{
801 			GLuint renderbufferID = 0;
802 			glGenRenderbuffers(1, &renderbufferID);
803 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
804 			expectError(GL_NO_ERROR);
805 
806 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
807 			expectError(GL_NO_ERROR);
808 
809 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_LINEAR);
810 			expectError(GL_NO_ERROR);
811 
812 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
813 			glDeleteRenderbuffers(1, &renderbufferID);
814 		}
815 
816 		// depth
817 		{
818 			GLuint renderbufferID = 0;
819 			glGenRenderbuffers(1, &renderbufferID);
820 			glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
821 			expectError(GL_NO_ERROR);
822 
823 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbufferID);
824 			expectError(GL_NO_ERROR);
825 
826 			checkAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING, GL_LINEAR);
827 
828 			glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
829 			glDeleteRenderbuffers(1, &renderbufferID);
830 		}
831 
832 		glDeleteFramebuffers(1, &framebufferID);
833 		expectError(GL_NO_ERROR);
834 	}
835 };
836 
837 class UnspecifiedAttachmentTextureComponentTypeCase : public ApiCase
838 {
839 public:
UnspecifiedAttachmentTextureComponentTypeCase(Context & context,const char * name,const char * description)840 	UnspecifiedAttachmentTextureComponentTypeCase (Context& context, const char* name, const char* description)
841 		: ApiCase(context, name, description)
842 	{
843 	}
844 
test(void)845 	void test (void)
846 	{
847 		GLuint framebufferID = 0;
848 		glGenFramebuffers(1, &framebufferID);
849 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
850 		expectError(GL_NO_ERROR);
851 
852 		{
853 			GLuint textureID = 0;
854 			glGenTextures(1, &textureID);
855 			glBindTexture(GL_TEXTURE_2D, textureID);
856 			expectError(GL_NO_ERROR);
857 
858 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
859 			expectError(GL_NO_ERROR);
860 
861 			checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE, GL_NONE);
862 			expectError(GL_NO_ERROR);
863 
864 			glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
865 			glDeleteTextures(1, &textureID);
866 		}
867 
868 		glDeleteFramebuffers(1, &framebufferID);
869 		expectError(GL_NO_ERROR);
870 	}
871 };
872 
873 class UnspecifiedAttachmentSizeCase : public ApiCase
874 {
875 public:
UnspecifiedAttachmentSizeCase(Context & context,const char * name,const char * description)876 	UnspecifiedAttachmentSizeCase (Context& context, const char* name, const char* description)
877 		: ApiCase(context, name, description)
878 	{
879 	}
880 
881 	virtual void testColorAttachment (void) = DE_NULL;
882 
883 	virtual void testDepthAttachment (void) = DE_NULL;
884 
test(void)885 	void test (void)
886 	{
887 		GLuint framebufferID = 0;
888 		glGenFramebuffers(1, &framebufferID);
889 		glBindFramebuffer(GL_FRAMEBUFFER, framebufferID);
890 		expectError(GL_NO_ERROR);
891 
892 		// check color target
893 		testColorAttachment();
894 
895 		// check depth target
896 		testDepthAttachment();
897 
898 		glDeleteFramebuffers(1, &framebufferID);
899 		expectError(GL_NO_ERROR);
900 	}
901 };
902 
903 class UnspecifiedAttachmentSizeRboCase : public UnspecifiedAttachmentSizeCase
904 {
905 public:
UnspecifiedAttachmentSizeRboCase(Context & context,const char * name,const char * description)906 	UnspecifiedAttachmentSizeRboCase (Context& context, const char* name, const char* description)
907 		: UnspecifiedAttachmentSizeCase(context, name, description)
908 	{
909 	}
910 
testColorAttachment(void)911 	void testColorAttachment (void)
912 	{
913 		GLuint renderbufferID = 0;
914 		glGenRenderbuffers(1, &renderbufferID);
915 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
916 		expectError(GL_NO_ERROR);
917 
918 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID);
919 		expectError(GL_NO_ERROR);
920 
921 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0, 0, 0, 0, 0);
922 		expectError(GL_NO_ERROR);
923 
924 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0);
925 		glDeleteRenderbuffers(1, &renderbufferID);
926 	}
927 
testDepthAttachment(void)928 	void testDepthAttachment (void)
929 	{
930 		GLuint renderbufferID = 0;
931 		glGenRenderbuffers(1, &renderbufferID);
932 		glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID);
933 		expectError(GL_NO_ERROR);
934 
935 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderbufferID);
936 		expectError(GL_NO_ERROR);
937 
938 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0, 0, 0, 0, 0);
939 		expectError(GL_NO_ERROR);
940 
941 		glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
942 		glDeleteRenderbuffers(1, &renderbufferID);
943 	}
944 };
945 
946 class UnspecifiedAttachmentSizeTextureCase : public UnspecifiedAttachmentSizeCase
947 {
948 public:
UnspecifiedAttachmentSizeTextureCase(Context & context,const char * name,const char * description)949 	UnspecifiedAttachmentSizeTextureCase (Context& context, const char* name, const char* description)
950 		: UnspecifiedAttachmentSizeCase(context, name, description)
951 	{
952 	}
953 
testColorAttachment(void)954 	void testColorAttachment (void)
955 	{
956 		GLuint textureID = 0;
957 		glGenTextures(1, &textureID);
958 		glBindTexture(GL_TEXTURE_2D, textureID);
959 		expectError(GL_NO_ERROR);
960 
961 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0);
962 		expectError(GL_NO_ERROR);
963 
964 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, 0, 0, 0, 0, 0, 0);
965 		expectError(GL_NO_ERROR);
966 
967 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
968 		glDeleteTextures(1, &textureID);
969 	}
970 
testDepthAttachment(void)971 	void testDepthAttachment (void)
972 	{
973 		GLuint textureID = 0;
974 		glGenTextures(1, &textureID);
975 		glBindTexture(GL_TEXTURE_2D, textureID);
976 		expectError(GL_NO_ERROR);
977 
978 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, textureID, 0);
979 		expectError(GL_NO_ERROR);
980 
981 		checkAttachmentComponentSizeExactly	(m_testCtx, *this, GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0, 0, 0, 0, 0);
982 		expectError(GL_NO_ERROR);
983 
984 		glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
985 		glDeleteTextures(1, &textureID);
986 	}
987 };
988 
989 } // anonymous
990 
991 
FboStateQueryTests(Context & context)992 FboStateQueryTests::FboStateQueryTests (Context& context)
993 	: TestCaseGroup(context, "fbo", "Fbo State Query tests")
994 {
995 }
996 
init(void)997 void FboStateQueryTests::init (void)
998 {
999 	const struct FramebufferTarget
1000 	{
1001 		const char*	name;
1002 		GLenum		target;
1003 	} fboTargets[] =
1004 	{
1005 		{ "draw_framebuffer_", GL_DRAW_FRAMEBUFFER },
1006 		{ "read_framebuffer_", GL_READ_FRAMEBUFFER }
1007 	};
1008 
1009 	for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(fboTargets); ++ndx)
1010 		addChild(new DefaultFramebufferCase(m_context, (std::string(fboTargets[ndx].name) + "default_framebuffer").c_str(), "default framebuffer", fboTargets[ndx].target));
1011 
1012 	addChild(new AttachmentObjectCase							(m_context, "framebuffer_attachment_object",							"FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE and FRAMEBUFFER_ATTACHMENT_OBJECT_NAME"));
1013 	addChild(new AttachmentTextureLevelCase						(m_context, "framebuffer_attachment_texture_level",						"FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL"));
1014 	addChild(new AttachmentTextureCubeMapFaceCase				(m_context, "framebuffer_attachment_texture_cube_map_face",				"FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE"));
1015 	addChild(new AttachmentTextureLayerCase						(m_context, "framebuffer_attachment_texture_layer",						"FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER"));
1016 	addChild(new AttachmentTextureColorCodingCase				(m_context, "framebuffer_attachment_color_encoding",					"FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"));
1017 	addChild(new AttachmentTextureComponentTypeCase				(m_context, "framebuffer_attachment_component_type",					"FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"));
1018 	addChild(new AttachmentSizeInitialCase						(m_context, "framebuffer_attachment_x_size_initial",					"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1019 	addChild(new AttachmentSizeRboCase							(m_context, "framebuffer_attachment_x_size_rbo",						"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1020 	addChild(new AttachmentSizeTextureCase						(m_context, "framebuffer_attachment_x_size_texture",					"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1021 
1022 	addChild(new UnspecifiedAttachmentTextureColorCodingCase	(m_context, "framebuffer_unspecified_attachment_color_encoding",		"FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING"));
1023 	addChild(new UnspecifiedAttachmentTextureComponentTypeCase	(m_context, "framebuffer_unspecified_attachment_component_type",		"FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"));
1024 	addChild(new UnspecifiedAttachmentSizeRboCase				(m_context, "framebuffer_unspecified_attachment_x_size_rbo",			"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1025 	addChild(new UnspecifiedAttachmentSizeTextureCase			(m_context, "framebuffer_unspecified_attachment_x_size_texture",		"FRAMEBUFFER_ATTACHMENT_x_SIZE"));
1026 }
1027 
1028 } // Functional
1029 } // gles3
1030 } // deqp
1031