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