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