xref: /aosp_15_r20/external/deqp/modules/gles3/functional/es3fFboApiTests.cpp (revision 35238bce31c2a825756842865a792f8cf7f89930)
1*35238bceSAndroid Build Coastguard Worker /*-------------------------------------------------------------------------
2*35238bceSAndroid Build Coastguard Worker  * drawElements Quality Program OpenGL ES 3.0 Module
3*35238bceSAndroid Build Coastguard Worker  * -------------------------------------------------
4*35238bceSAndroid Build Coastguard Worker  *
5*35238bceSAndroid Build Coastguard Worker  * Copyright 2014 The Android Open Source Project
6*35238bceSAndroid Build Coastguard Worker  *
7*35238bceSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
8*35238bceSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
9*35238bceSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
10*35238bceSAndroid Build Coastguard Worker  *
11*35238bceSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
12*35238bceSAndroid Build Coastguard Worker  *
13*35238bceSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
14*35238bceSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
15*35238bceSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16*35238bceSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
17*35238bceSAndroid Build Coastguard Worker  * limitations under the License.
18*35238bceSAndroid Build Coastguard Worker  *
19*35238bceSAndroid Build Coastguard Worker  *//*!
20*35238bceSAndroid Build Coastguard Worker  * \file
21*35238bceSAndroid Build Coastguard Worker  * \brief Framebuffer Object API Tests.
22*35238bceSAndroid Build Coastguard Worker  *
23*35238bceSAndroid Build Coastguard Worker  * Notes:
24*35238bceSAndroid Build Coastguard Worker  *   All gl calls are passed thru sglr::Context class. Reasons:
25*35238bceSAndroid Build Coastguard Worker  *    + Name, object allocation is tracked and live resources are freed
26*35238bceSAndroid Build Coastguard Worker  *      when Context is destroyed.
27*35238bceSAndroid Build Coastguard Worker  *    + Makes it possible to easily log all relevant calls into test log.
28*35238bceSAndroid Build Coastguard Worker  *      \todo [pyry] This is not implemented yet
29*35238bceSAndroid Build Coastguard Worker  *//*--------------------------------------------------------------------*/
30*35238bceSAndroid Build Coastguard Worker 
31*35238bceSAndroid Build Coastguard Worker #include "es3fFboApiTests.hpp"
32*35238bceSAndroid Build Coastguard Worker #include "sglrGLContext.hpp"
33*35238bceSAndroid Build Coastguard Worker #include "gluDefs.hpp"
34*35238bceSAndroid Build Coastguard Worker #include "gluStrUtil.hpp"
35*35238bceSAndroid Build Coastguard Worker #include "tcuRenderTarget.hpp"
36*35238bceSAndroid Build Coastguard Worker #include "deString.h"
37*35238bceSAndroid Build Coastguard Worker #include "glwFunctions.hpp"
38*35238bceSAndroid Build Coastguard Worker #include "glwEnums.hpp"
39*35238bceSAndroid Build Coastguard Worker 
40*35238bceSAndroid Build Coastguard Worker namespace deqp
41*35238bceSAndroid Build Coastguard Worker {
42*35238bceSAndroid Build Coastguard Worker namespace gles3
43*35238bceSAndroid Build Coastguard Worker {
44*35238bceSAndroid Build Coastguard Worker namespace Functional
45*35238bceSAndroid Build Coastguard Worker {
46*35238bceSAndroid Build Coastguard Worker 
47*35238bceSAndroid Build Coastguard Worker using std::string;
48*35238bceSAndroid Build Coastguard Worker using std::vector;
49*35238bceSAndroid Build Coastguard Worker using tcu::TestLog;
50*35238bceSAndroid Build Coastguard Worker 
51*35238bceSAndroid Build Coastguard Worker using glw::GLenum;
52*35238bceSAndroid Build Coastguard Worker using glw::GLint;
53*35238bceSAndroid Build Coastguard Worker 
logComment(tcu::TestContext & testCtx,const char * comment)54*35238bceSAndroid Build Coastguard Worker static void logComment(tcu::TestContext &testCtx, const char *comment)
55*35238bceSAndroid Build Coastguard Worker {
56*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// " << comment << TestLog::EndMessage;
57*35238bceSAndroid Build Coastguard Worker }
58*35238bceSAndroid Build Coastguard Worker 
checkError(tcu::TestContext & testCtx,sglr::Context & ctx,GLenum expect)59*35238bceSAndroid Build Coastguard Worker static void checkError(tcu::TestContext &testCtx, sglr::Context &ctx, GLenum expect)
60*35238bceSAndroid Build Coastguard Worker {
61*35238bceSAndroid Build Coastguard Worker     GLenum result = ctx.getError();
62*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// " << (result == expect ? "Pass" : "Fail") << ", expected "
63*35238bceSAndroid Build Coastguard Worker                      << glu::getErrorStr(expect) << TestLog::EndMessage;
64*35238bceSAndroid Build Coastguard Worker 
65*35238bceSAndroid Build Coastguard Worker     if (result != expect)
66*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error code mismatch");
67*35238bceSAndroid Build Coastguard Worker }
68*35238bceSAndroid Build Coastguard Worker 
checkEitherError(tcu::TestContext & testCtx,sglr::Context & ctx,GLenum expectA,GLenum expectB)69*35238bceSAndroid Build Coastguard Worker static void checkEitherError(tcu::TestContext &testCtx, sglr::Context &ctx, GLenum expectA, GLenum expectB)
70*35238bceSAndroid Build Coastguard Worker {
71*35238bceSAndroid Build Coastguard Worker     GLenum result = ctx.getError();
72*35238bceSAndroid Build Coastguard Worker     bool isOk     = (result == expectA || result == expectB);
73*35238bceSAndroid Build Coastguard Worker 
74*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// " << (isOk ? "Pass" : "Fail") << ", expected "
75*35238bceSAndroid Build Coastguard Worker                      << glu::getErrorStr(expectA) << " or " << glu::getErrorStr(expectB) << TestLog::EndMessage;
76*35238bceSAndroid Build Coastguard Worker 
77*35238bceSAndroid Build Coastguard Worker     if (!isOk)
78*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Error code mismatch");
79*35238bceSAndroid Build Coastguard Worker }
80*35238bceSAndroid Build Coastguard Worker 
getAttachmentName(GLenum attachment)81*35238bceSAndroid Build Coastguard Worker static const char *getAttachmentName(GLenum attachment)
82*35238bceSAndroid Build Coastguard Worker {
83*35238bceSAndroid Build Coastguard Worker     switch (attachment)
84*35238bceSAndroid Build Coastguard Worker     {
85*35238bceSAndroid Build Coastguard Worker     case GL_COLOR_ATTACHMENT0:
86*35238bceSAndroid Build Coastguard Worker         return "GL_COLOR_ATTACHMENT0";
87*35238bceSAndroid Build Coastguard Worker     case GL_DEPTH_ATTACHMENT:
88*35238bceSAndroid Build Coastguard Worker         return "GL_DEPTH_ATTACHMENT";
89*35238bceSAndroid Build Coastguard Worker     case GL_STENCIL_ATTACHMENT:
90*35238bceSAndroid Build Coastguard Worker         return "GL_STENCIL_ATTACHMENT";
91*35238bceSAndroid Build Coastguard Worker     default:
92*35238bceSAndroid Build Coastguard Worker         throw tcu::InternalError("Unknown attachment", "", __FILE__, __LINE__);
93*35238bceSAndroid Build Coastguard Worker     }
94*35238bceSAndroid Build Coastguard Worker }
95*35238bceSAndroid Build Coastguard Worker 
getAttachmentParameterName(GLenum pname)96*35238bceSAndroid Build Coastguard Worker static const char *getAttachmentParameterName(GLenum pname)
97*35238bceSAndroid Build Coastguard Worker {
98*35238bceSAndroid Build Coastguard Worker     switch (pname)
99*35238bceSAndroid Build Coastguard Worker     {
100*35238bceSAndroid Build Coastguard Worker     case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
101*35238bceSAndroid Build Coastguard Worker         return "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE";
102*35238bceSAndroid Build Coastguard Worker     case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
103*35238bceSAndroid Build Coastguard Worker         return "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME";
104*35238bceSAndroid Build Coastguard Worker     case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
105*35238bceSAndroid Build Coastguard Worker         return "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL";
106*35238bceSAndroid Build Coastguard Worker     case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
107*35238bceSAndroid Build Coastguard Worker         return "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE";
108*35238bceSAndroid Build Coastguard Worker     default:
109*35238bceSAndroid Build Coastguard Worker         throw tcu::InternalError("Unknown parameter", "", __FILE__, __LINE__);
110*35238bceSAndroid Build Coastguard Worker     }
111*35238bceSAndroid Build Coastguard Worker }
112*35238bceSAndroid Build Coastguard Worker 
getAttachmentParameterValueName(GLint value)113*35238bceSAndroid Build Coastguard Worker static string getAttachmentParameterValueName(GLint value)
114*35238bceSAndroid Build Coastguard Worker {
115*35238bceSAndroid Build Coastguard Worker     switch (value)
116*35238bceSAndroid Build Coastguard Worker     {
117*35238bceSAndroid Build Coastguard Worker     case 0:
118*35238bceSAndroid Build Coastguard Worker         return "GL_NONE(0)";
119*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE:
120*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE";
121*35238bceSAndroid Build Coastguard Worker     case GL_RENDERBUFFER:
122*35238bceSAndroid Build Coastguard Worker         return "GL_RENDERBUFFER";
123*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
124*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE_CUBE_MAP_POSITIVE_X";
125*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
126*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE_CUBE_MAP_NEGATIVE_X";
127*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
128*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE_CUBE_MAP_POSITIVE_Y";
129*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
130*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y";
131*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
132*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE_CUBE_MAP_POSITIVE_Z";
133*35238bceSAndroid Build Coastguard Worker     case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
134*35238bceSAndroid Build Coastguard Worker         return "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z";
135*35238bceSAndroid Build Coastguard Worker     default:
136*35238bceSAndroid Build Coastguard Worker     {
137*35238bceSAndroid Build Coastguard Worker         char tmp[64];
138*35238bceSAndroid Build Coastguard Worker         deSprintf(tmp, sizeof(tmp), "0x%x", value);
139*35238bceSAndroid Build Coastguard Worker         return string(tmp);
140*35238bceSAndroid Build Coastguard Worker     }
141*35238bceSAndroid Build Coastguard Worker     }
142*35238bceSAndroid Build Coastguard Worker }
143*35238bceSAndroid Build Coastguard Worker 
checkFboAttachmentParam(tcu::TestContext & testCtx,sglr::Context & ctx,GLenum attachment,GLenum pname,GLint expectedValue)144*35238bceSAndroid Build Coastguard Worker static void checkFboAttachmentParam(tcu::TestContext &testCtx, sglr::Context &ctx, GLenum attachment, GLenum pname,
145*35238bceSAndroid Build Coastguard Worker                                     GLint expectedValue)
146*35238bceSAndroid Build Coastguard Worker {
147*35238bceSAndroid Build Coastguard Worker     TestLog &log = testCtx.getLog();
148*35238bceSAndroid Build Coastguard Worker     log << TestLog::Message << "// Querying " << getAttachmentName(attachment) << " "
149*35238bceSAndroid Build Coastguard Worker         << getAttachmentParameterName(pname) << TestLog::EndMessage;
150*35238bceSAndroid Build Coastguard Worker 
151*35238bceSAndroid Build Coastguard Worker     GLint value = 0xcdcdcdcd;
152*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, attachment, pname, &value);
153*35238bceSAndroid Build Coastguard Worker 
154*35238bceSAndroid Build Coastguard Worker     GLenum err = ctx.getError();
155*35238bceSAndroid Build Coastguard Worker 
156*35238bceSAndroid Build Coastguard Worker     if (value == expectedValue && err == GL_NO_ERROR)
157*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "// Pass" << TestLog::EndMessage;
158*35238bceSAndroid Build Coastguard Worker     else
159*35238bceSAndroid Build Coastguard Worker     {
160*35238bceSAndroid Build Coastguard Worker         log << TestLog::Message << "// Fail, expected " << getAttachmentParameterValueName(expectedValue)
161*35238bceSAndroid Build Coastguard Worker             << " without error" << TestLog::EndMessage;
162*35238bceSAndroid Build Coastguard Worker         testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Invalid result for attachment param query");
163*35238bceSAndroid Build Coastguard Worker     }
164*35238bceSAndroid Build Coastguard Worker }
165*35238bceSAndroid Build Coastguard Worker 
textureLevelsTest(tcu::TestContext & testCtx,sglr::Context & context)166*35238bceSAndroid Build Coastguard Worker static void textureLevelsTest(tcu::TestContext &testCtx, sglr::Context &context)
167*35238bceSAndroid Build Coastguard Worker {
168*35238bceSAndroid Build Coastguard Worker     uint32_t tex = 1;
169*35238bceSAndroid Build Coastguard Worker     uint32_t fbo = 1;
170*35238bceSAndroid Build Coastguard Worker     GLint maxTexSize;
171*35238bceSAndroid Build Coastguard Worker     int log2MaxTexSize;
172*35238bceSAndroid Build Coastguard Worker 
173*35238bceSAndroid Build Coastguard Worker     context.getIntegerv(GL_MAX_TEXTURE_SIZE, &maxTexSize);
174*35238bceSAndroid Build Coastguard Worker     log2MaxTexSize = deLog2Floor32(maxTexSize);
175*35238bceSAndroid Build Coastguard Worker 
176*35238bceSAndroid Build Coastguard Worker     testCtx.getLog() << TestLog::Message << "// GL_MAX_TEXTURE_SIZE is " << maxTexSize << ", floor(log2(" << maxTexSize
177*35238bceSAndroid Build Coastguard Worker                      << ")) = " << log2MaxTexSize << TestLog::EndMessage;
178*35238bceSAndroid Build Coastguard Worker 
179*35238bceSAndroid Build Coastguard Worker     context.bindTexture(GL_TEXTURE_2D, tex);
180*35238bceSAndroid Build Coastguard Worker     context.texImage2D(GL_TEXTURE_2D, 0, GL_RGB, 256, 256);
181*35238bceSAndroid Build Coastguard Worker     context.texImage2D(GL_TEXTURE_2D, 1, GL_RGB, 128, 128);
182*35238bceSAndroid Build Coastguard Worker 
183*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, fbo);
184*35238bceSAndroid Build Coastguard Worker 
185*35238bceSAndroid Build Coastguard Worker     const int levels[] = {2,
186*35238bceSAndroid Build Coastguard Worker                           1,
187*35238bceSAndroid Build Coastguard Worker                           0,
188*35238bceSAndroid Build Coastguard Worker                           -1,
189*35238bceSAndroid Build Coastguard Worker                           0x7fffffff,
190*35238bceSAndroid Build Coastguard Worker                           0,
191*35238bceSAndroid Build Coastguard Worker                           log2MaxTexSize - 2,
192*35238bceSAndroid Build Coastguard Worker                           log2MaxTexSize - 1,
193*35238bceSAndroid Build Coastguard Worker                           log2MaxTexSize,
194*35238bceSAndroid Build Coastguard Worker                           log2MaxTexSize + 1,
195*35238bceSAndroid Build Coastguard Worker                           log2MaxTexSize + 2,
196*35238bceSAndroid Build Coastguard Worker                           1};
197*35238bceSAndroid Build Coastguard Worker 
198*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(levels); ndx++)
199*35238bceSAndroid Build Coastguard Worker     {
200*35238bceSAndroid Build Coastguard Worker         context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, levels[ndx]);
201*35238bceSAndroid Build Coastguard Worker         checkError(testCtx, context,
202*35238bceSAndroid Build Coastguard Worker                    levels[ndx] >= 0 && levels[ndx] <= log2MaxTexSize ? GL_NO_ERROR : GL_INVALID_VALUE);
203*35238bceSAndroid Build Coastguard Worker     }
204*35238bceSAndroid Build Coastguard Worker }
205*35238bceSAndroid Build Coastguard Worker 
validTex2DAttachmentsTest(tcu::TestContext & testCtx,sglr::Context & context)206*35238bceSAndroid Build Coastguard Worker static void validTex2DAttachmentsTest(tcu::TestContext &testCtx, sglr::Context &context)
207*35238bceSAndroid Build Coastguard Worker {
208*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
209*35238bceSAndroid Build Coastguard Worker     static const GLenum attachmentPoints[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
210*35238bceSAndroid Build Coastguard Worker 
211*35238bceSAndroid Build Coastguard Worker     // Texture2D
212*35238bceSAndroid Build Coastguard Worker     uint32_t tex2D = 1;
213*35238bceSAndroid Build Coastguard Worker     context.bindTexture(GL_TEXTURE_2D, tex2D);
214*35238bceSAndroid Build Coastguard Worker     for (int pointNdx = 0; pointNdx < DE_LENGTH_OF_ARRAY(attachmentPoints); pointNdx++)
215*35238bceSAndroid Build Coastguard Worker     {
216*35238bceSAndroid Build Coastguard Worker         context.framebufferTexture2D(GL_FRAMEBUFFER, attachmentPoints[pointNdx], GL_TEXTURE_2D, tex2D, 0);
217*35238bceSAndroid Build Coastguard Worker         checkError(testCtx, context, GL_NO_ERROR);
218*35238bceSAndroid Build Coastguard Worker     }
219*35238bceSAndroid Build Coastguard Worker }
220*35238bceSAndroid Build Coastguard Worker 
validTexCubeAttachmentsTest(tcu::TestContext & testCtx,sglr::Context & context)221*35238bceSAndroid Build Coastguard Worker static void validTexCubeAttachmentsTest(tcu::TestContext &testCtx, sglr::Context &context)
222*35238bceSAndroid Build Coastguard Worker {
223*35238bceSAndroid Build Coastguard Worker     static const GLenum attachmentPoints[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
224*35238bceSAndroid Build Coastguard Worker     static const GLenum cubeTargets[]      = {GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
225*35238bceSAndroid Build Coastguard Worker                                               GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
226*35238bceSAndroid Build Coastguard Worker                                               GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z};
227*35238bceSAndroid Build Coastguard Worker 
228*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
229*35238bceSAndroid Build Coastguard Worker 
230*35238bceSAndroid Build Coastguard Worker     // TextureCube
231*35238bceSAndroid Build Coastguard Worker     uint32_t texCube = 2;
232*35238bceSAndroid Build Coastguard Worker     context.bindTexture(GL_TEXTURE_CUBE_MAP, texCube);
233*35238bceSAndroid Build Coastguard Worker     for (int pointNdx = 0; pointNdx < DE_LENGTH_OF_ARRAY(attachmentPoints); pointNdx++)
234*35238bceSAndroid Build Coastguard Worker     {
235*35238bceSAndroid Build Coastguard Worker         for (int targetNdx = 0; targetNdx < DE_LENGTH_OF_ARRAY(cubeTargets); targetNdx++)
236*35238bceSAndroid Build Coastguard Worker         {
237*35238bceSAndroid Build Coastguard Worker             context.framebufferTexture2D(GL_FRAMEBUFFER, attachmentPoints[pointNdx], cubeTargets[targetNdx], texCube,
238*35238bceSAndroid Build Coastguard Worker                                          0);
239*35238bceSAndroid Build Coastguard Worker             checkError(testCtx, context, GL_NO_ERROR);
240*35238bceSAndroid Build Coastguard Worker         }
241*35238bceSAndroid Build Coastguard Worker     }
242*35238bceSAndroid Build Coastguard Worker }
243*35238bceSAndroid Build Coastguard Worker 
validRboAttachmentsTest(tcu::TestContext & testCtx,sglr::Context & context)244*35238bceSAndroid Build Coastguard Worker static void validRboAttachmentsTest(tcu::TestContext &testCtx, sglr::Context &context)
245*35238bceSAndroid Build Coastguard Worker {
246*35238bceSAndroid Build Coastguard Worker     static const GLenum attachmentPoints[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
247*35238bceSAndroid Build Coastguard Worker 
248*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
249*35238bceSAndroid Build Coastguard Worker 
250*35238bceSAndroid Build Coastguard Worker     // Renderbuffer
251*35238bceSAndroid Build Coastguard Worker     uint32_t rbo = 3;
252*35238bceSAndroid Build Coastguard Worker     context.bindRenderbuffer(GL_RENDERBUFFER, rbo);
253*35238bceSAndroid Build Coastguard Worker     for (int pointNdx = 0; pointNdx < DE_LENGTH_OF_ARRAY(attachmentPoints); pointNdx++)
254*35238bceSAndroid Build Coastguard Worker     {
255*35238bceSAndroid Build Coastguard Worker         context.framebufferRenderbuffer(GL_FRAMEBUFFER, attachmentPoints[pointNdx], GL_RENDERBUFFER, rbo);
256*35238bceSAndroid Build Coastguard Worker         checkError(testCtx, context, GL_NO_ERROR);
257*35238bceSAndroid Build Coastguard Worker     }
258*35238bceSAndroid Build Coastguard Worker }
259*35238bceSAndroid Build Coastguard Worker 
attachToDefaultFramebufferTest(tcu::TestContext & testCtx,sglr::Context & context)260*35238bceSAndroid Build Coastguard Worker static void attachToDefaultFramebufferTest(tcu::TestContext &testCtx, sglr::Context &context)
261*35238bceSAndroid Build Coastguard Worker {
262*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching 2D texture to default framebuffer");
263*35238bceSAndroid Build Coastguard Worker 
264*35238bceSAndroid Build Coastguard Worker     uint32_t tex2D = 1;
265*35238bceSAndroid Build Coastguard Worker     context.bindTexture(GL_TEXTURE_2D, tex2D);
266*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 0);
267*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
268*35238bceSAndroid Build Coastguard Worker 
269*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching renderbuffer to default framebuffer");
270*35238bceSAndroid Build Coastguard Worker 
271*35238bceSAndroid Build Coastguard Worker     uint32_t rbo = 1;
272*35238bceSAndroid Build Coastguard Worker     context.bindRenderbuffer(GL_RENDERBUFFER, rbo);
273*35238bceSAndroid Build Coastguard Worker     context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rbo);
274*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
275*35238bceSAndroid Build Coastguard Worker }
276*35238bceSAndroid Build Coastguard Worker 
invalidTex2DAttachmentTest(tcu::TestContext & testCtx,sglr::Context & context)277*35238bceSAndroid Build Coastguard Worker static void invalidTex2DAttachmentTest(tcu::TestContext &testCtx, sglr::Context &context)
278*35238bceSAndroid Build Coastguard Worker {
279*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
280*35238bceSAndroid Build Coastguard Worker 
281*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching 2D texture using GL_TEXTURE_CUBE_MAP_NEGATIVE_X texture target");
282*35238bceSAndroid Build Coastguard Worker 
283*35238bceSAndroid Build Coastguard Worker     uint32_t tex2D = 1;
284*35238bceSAndroid Build Coastguard Worker     context.bindTexture(GL_TEXTURE_2D, tex2D);
285*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, tex2D, 0);
286*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
287*35238bceSAndroid Build Coastguard Worker 
288*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching deleted 2D texture object");
289*35238bceSAndroid Build Coastguard Worker     context.deleteTextures(1, &tex2D);
290*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 0);
291*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
292*35238bceSAndroid Build Coastguard Worker }
293*35238bceSAndroid Build Coastguard Worker 
invalidTexCubeAttachmentTest(tcu::TestContext & testCtx,sglr::Context & context)294*35238bceSAndroid Build Coastguard Worker static void invalidTexCubeAttachmentTest(tcu::TestContext &testCtx, sglr::Context &context)
295*35238bceSAndroid Build Coastguard Worker {
296*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
297*35238bceSAndroid Build Coastguard Worker 
298*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching cube texture using GL_TEXTURE_2D texture target");
299*35238bceSAndroid Build Coastguard Worker     uint32_t texCube = 2;
300*35238bceSAndroid Build Coastguard Worker     context.bindTexture(GL_TEXTURE_CUBE_MAP, texCube);
301*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texCube, 0);
302*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
303*35238bceSAndroid Build Coastguard Worker 
304*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching deleted cube texture object");
305*35238bceSAndroid Build Coastguard Worker     context.deleteTextures(1, &texCube);
306*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, 0);
307*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
308*35238bceSAndroid Build Coastguard Worker }
309*35238bceSAndroid Build Coastguard Worker 
invalidRboAttachmentTest(tcu::TestContext & testCtx,sglr::Context & context)310*35238bceSAndroid Build Coastguard Worker static void invalidRboAttachmentTest(tcu::TestContext &testCtx, sglr::Context &context)
311*35238bceSAndroid Build Coastguard Worker {
312*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
313*35238bceSAndroid Build Coastguard Worker 
314*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching renderbuffer using GL_FRAMEBUFFER renderbuffer target");
315*35238bceSAndroid Build Coastguard Worker     uint32_t rbo = 3;
316*35238bceSAndroid Build Coastguard Worker     context.bindRenderbuffer(GL_RENDERBUFFER, rbo);
317*35238bceSAndroid Build Coastguard Worker     context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER, rbo);
318*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_ENUM);
319*35238bceSAndroid Build Coastguard Worker 
320*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching deleted renderbuffer object");
321*35238bceSAndroid Build Coastguard Worker     context.deleteRenderbuffers(1, &rbo);
322*35238bceSAndroid Build Coastguard Worker     context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
323*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
324*35238bceSAndroid Build Coastguard Worker }
325*35238bceSAndroid Build Coastguard Worker 
attachNamesTest(tcu::TestContext & testCtx,sglr::Context & context)326*35238bceSAndroid Build Coastguard Worker static void attachNamesTest(tcu::TestContext &testCtx, sglr::Context &context)
327*35238bceSAndroid Build Coastguard Worker {
328*35238bceSAndroid Build Coastguard Worker     context.bindFramebuffer(GL_FRAMEBUFFER, 1);
329*35238bceSAndroid Build Coastguard Worker 
330*35238bceSAndroid Build Coastguard Worker     // Just allocate some names, don't bind for storage
331*35238bceSAndroid Build Coastguard Worker     uint32_t reservedTexName;
332*35238bceSAndroid Build Coastguard Worker     context.genTextures(1, &reservedTexName);
333*35238bceSAndroid Build Coastguard Worker 
334*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching allocated texture name to 2D target");
335*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, reservedTexName, 0);
336*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
337*35238bceSAndroid Build Coastguard Worker 
338*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching allocated texture name to cube target");
339*35238bceSAndroid Build Coastguard Worker     context.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, reservedTexName,
340*35238bceSAndroid Build Coastguard Worker                                  0);
341*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
342*35238bceSAndroid Build Coastguard Worker 
343*35238bceSAndroid Build Coastguard Worker     uint32_t reservedRboName;
344*35238bceSAndroid Build Coastguard Worker     context.genRenderbuffers(1, &reservedRboName);
345*35238bceSAndroid Build Coastguard Worker 
346*35238bceSAndroid Build Coastguard Worker     logComment(testCtx, "Attaching allocated renderbuffer name");
347*35238bceSAndroid Build Coastguard Worker     context.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, reservedRboName);
348*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, context, GL_INVALID_OPERATION);
349*35238bceSAndroid Build Coastguard Worker }
350*35238bceSAndroid Build Coastguard Worker 
attachmentQueryDefaultFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)351*35238bceSAndroid Build Coastguard Worker static void attachmentQueryDefaultFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
352*35238bceSAndroid Build Coastguard Worker {
353*35238bceSAndroid Build Coastguard Worker     // Check that proper error codes are returned
354*35238bceSAndroid Build Coastguard Worker     GLint unused = -1;
355*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
356*35238bceSAndroid Build Coastguard Worker                                             &unused);
357*35238bceSAndroid Build Coastguard Worker     checkEitherError(testCtx, ctx, GL_INVALID_ENUM, GL_INVALID_OPERATION);
358*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
359*35238bceSAndroid Build Coastguard Worker                                             &unused);
360*35238bceSAndroid Build Coastguard Worker     checkEitherError(testCtx, ctx, GL_INVALID_ENUM, GL_INVALID_OPERATION);
361*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
362*35238bceSAndroid Build Coastguard Worker                                             GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &unused);
363*35238bceSAndroid Build Coastguard Worker     checkEitherError(testCtx, ctx, GL_INVALID_ENUM, GL_INVALID_OPERATION);
364*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
365*35238bceSAndroid Build Coastguard Worker                                             GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, &unused);
366*35238bceSAndroid Build Coastguard Worker     checkEitherError(testCtx, ctx, GL_INVALID_ENUM, GL_INVALID_OPERATION);
367*35238bceSAndroid Build Coastguard Worker }
368*35238bceSAndroid Build Coastguard Worker 
attachmentQueryEmptyFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)369*35238bceSAndroid Build Coastguard Worker static void attachmentQueryEmptyFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
370*35238bceSAndroid Build Coastguard Worker {
371*35238bceSAndroid Build Coastguard Worker     static const GLenum attachmentPoints[] = {GL_COLOR_ATTACHMENT0, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
372*35238bceSAndroid Build Coastguard Worker 
373*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
374*35238bceSAndroid Build Coastguard Worker 
375*35238bceSAndroid Build Coastguard Worker     for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(attachmentPoints); ndx++)
376*35238bceSAndroid Build Coastguard Worker         checkFboAttachmentParam(testCtx, ctx, attachmentPoints[ndx], GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_NONE);
377*35238bceSAndroid Build Coastguard Worker 
378*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 0);
379*35238bceSAndroid Build Coastguard Worker 
380*35238bceSAndroid Build Coastguard Worker     // Check that proper error codes are returned
381*35238bceSAndroid Build Coastguard Worker     GLint unused = -1;
382*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
383*35238bceSAndroid Build Coastguard Worker                                             GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &unused);
384*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, ctx, GL_INVALID_OPERATION);
385*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
386*35238bceSAndroid Build Coastguard Worker                                             GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, &unused);
387*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, ctx, GL_INVALID_OPERATION);
388*35238bceSAndroid Build Coastguard Worker }
389*35238bceSAndroid Build Coastguard Worker 
attachmentQueryTex2DTest(tcu::TestContext & testCtx,sglr::Context & ctx)390*35238bceSAndroid Build Coastguard Worker static void attachmentQueryTex2DTest(tcu::TestContext &testCtx, sglr::Context &ctx)
391*35238bceSAndroid Build Coastguard Worker {
392*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
393*35238bceSAndroid Build Coastguard Worker 
394*35238bceSAndroid Build Coastguard Worker     ctx.bindTexture(GL_TEXTURE_2D, 1);
395*35238bceSAndroid Build Coastguard Worker     ctx.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 1, 0);
396*35238bceSAndroid Build Coastguard Worker 
397*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
398*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 1);
399*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, 0);
400*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, 0);
401*35238bceSAndroid Build Coastguard Worker }
402*35238bceSAndroid Build Coastguard Worker 
attachmentQueryTexCubeTest(tcu::TestContext & testCtx,sglr::Context & ctx)403*35238bceSAndroid Build Coastguard Worker static void attachmentQueryTexCubeTest(tcu::TestContext &testCtx, sglr::Context &ctx)
404*35238bceSAndroid Build Coastguard Worker {
405*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
406*35238bceSAndroid Build Coastguard Worker 
407*35238bceSAndroid Build Coastguard Worker     ctx.bindTexture(GL_TEXTURE_CUBE_MAP, 2);
408*35238bceSAndroid Build Coastguard Worker     ctx.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 2, 0);
409*35238bceSAndroid Build Coastguard Worker 
410*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
411*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 2);
412*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, 0);
413*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE,
414*35238bceSAndroid Build Coastguard Worker                             GL_TEXTURE_CUBE_MAP_NEGATIVE_Y);
415*35238bceSAndroid Build Coastguard Worker }
416*35238bceSAndroid Build Coastguard Worker 
attachmentQueryRboTest(tcu::TestContext & testCtx,sglr::Context & ctx)417*35238bceSAndroid Build Coastguard Worker static void attachmentQueryRboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
418*35238bceSAndroid Build Coastguard Worker {
419*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
420*35238bceSAndroid Build Coastguard Worker 
421*35238bceSAndroid Build Coastguard Worker     ctx.bindRenderbuffer(GL_RENDERBUFFER, 3);
422*35238bceSAndroid Build Coastguard Worker     ctx.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 3);
423*35238bceSAndroid Build Coastguard Worker 
424*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
425*35238bceSAndroid Build Coastguard Worker                             GL_RENDERBUFFER);
426*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, 3);
427*35238bceSAndroid Build Coastguard Worker 
428*35238bceSAndroid Build Coastguard Worker     GLint unused = 0;
429*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
430*35238bceSAndroid Build Coastguard Worker                                             GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &unused);
431*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, ctx, GL_INVALID_ENUM);
432*35238bceSAndroid Build Coastguard Worker     ctx.getFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
433*35238bceSAndroid Build Coastguard Worker                                             GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, &unused);
434*35238bceSAndroid Build Coastguard Worker     checkError(testCtx, ctx, GL_INVALID_ENUM);
435*35238bceSAndroid Build Coastguard Worker }
436*35238bceSAndroid Build Coastguard Worker 
deleteTex2DAttachedToBoundFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)437*35238bceSAndroid Build Coastguard Worker static void deleteTex2DAttachedToBoundFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
438*35238bceSAndroid Build Coastguard Worker {
439*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
440*35238bceSAndroid Build Coastguard Worker 
441*35238bceSAndroid Build Coastguard Worker     uint32_t tex2D = 1;
442*35238bceSAndroid Build Coastguard Worker     ctx.bindTexture(GL_TEXTURE_2D, tex2D);
443*35238bceSAndroid Build Coastguard Worker     ctx.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 0);
444*35238bceSAndroid Build Coastguard Worker 
445*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
446*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, tex2D);
447*35238bceSAndroid Build Coastguard Worker 
448*35238bceSAndroid Build Coastguard Worker     ctx.deleteTextures(1, &tex2D);
449*35238bceSAndroid Build Coastguard Worker 
450*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_NONE);
451*35238bceSAndroid Build Coastguard Worker }
452*35238bceSAndroid Build Coastguard Worker 
deleteTexCubeAttachedToBoundFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)453*35238bceSAndroid Build Coastguard Worker static void deleteTexCubeAttachedToBoundFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
454*35238bceSAndroid Build Coastguard Worker {
455*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
456*35238bceSAndroid Build Coastguard Worker 
457*35238bceSAndroid Build Coastguard Worker     uint32_t texCube = 1;
458*35238bceSAndroid Build Coastguard Worker     ctx.bindTexture(GL_TEXTURE_CUBE_MAP, texCube);
459*35238bceSAndroid Build Coastguard Worker     ctx.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, 0);
460*35238bceSAndroid Build Coastguard Worker 
461*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
462*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, texCube);
463*35238bceSAndroid Build Coastguard Worker 
464*35238bceSAndroid Build Coastguard Worker     ctx.deleteTextures(1, &texCube);
465*35238bceSAndroid Build Coastguard Worker 
466*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_NONE);
467*35238bceSAndroid Build Coastguard Worker }
468*35238bceSAndroid Build Coastguard Worker 
deleteRboAttachedToBoundFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)469*35238bceSAndroid Build Coastguard Worker static void deleteRboAttachedToBoundFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
470*35238bceSAndroid Build Coastguard Worker {
471*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
472*35238bceSAndroid Build Coastguard Worker 
473*35238bceSAndroid Build Coastguard Worker     uint32_t rbo = 1;
474*35238bceSAndroid Build Coastguard Worker     ctx.bindRenderbuffer(GL_RENDERBUFFER, rbo);
475*35238bceSAndroid Build Coastguard Worker     ctx.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
476*35238bceSAndroid Build Coastguard Worker 
477*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
478*35238bceSAndroid Build Coastguard Worker                             GL_RENDERBUFFER);
479*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, rbo);
480*35238bceSAndroid Build Coastguard Worker 
481*35238bceSAndroid Build Coastguard Worker     ctx.deleteRenderbuffers(1, &rbo);
482*35238bceSAndroid Build Coastguard Worker 
483*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_NONE);
484*35238bceSAndroid Build Coastguard Worker }
485*35238bceSAndroid Build Coastguard Worker 
deleteTex2DAttachedToNotBoundFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)486*35238bceSAndroid Build Coastguard Worker static void deleteTex2DAttachedToNotBoundFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
487*35238bceSAndroid Build Coastguard Worker {
488*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
489*35238bceSAndroid Build Coastguard Worker 
490*35238bceSAndroid Build Coastguard Worker     uint32_t tex2D = 1;
491*35238bceSAndroid Build Coastguard Worker     ctx.bindTexture(GL_TEXTURE_2D, tex2D);
492*35238bceSAndroid Build Coastguard Worker     ctx.framebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex2D, 0);
493*35238bceSAndroid Build Coastguard Worker 
494*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
495*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, tex2D);
496*35238bceSAndroid Build Coastguard Worker 
497*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 0);
498*35238bceSAndroid Build Coastguard Worker 
499*35238bceSAndroid Build Coastguard Worker     ctx.deleteTextures(1, &tex2D);
500*35238bceSAndroid Build Coastguard Worker 
501*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
502*35238bceSAndroid Build Coastguard Worker 
503*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
504*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_COLOR_ATTACHMENT0, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, tex2D);
505*35238bceSAndroid Build Coastguard Worker }
506*35238bceSAndroid Build Coastguard Worker 
deleteTexCubeAttachedToNotBoundFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)507*35238bceSAndroid Build Coastguard Worker static void deleteTexCubeAttachedToNotBoundFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
508*35238bceSAndroid Build Coastguard Worker {
509*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
510*35238bceSAndroid Build Coastguard Worker 
511*35238bceSAndroid Build Coastguard Worker     uint32_t texCube = 1;
512*35238bceSAndroid Build Coastguard Worker     ctx.bindTexture(GL_TEXTURE_CUBE_MAP, texCube);
513*35238bceSAndroid Build Coastguard Worker     ctx.framebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, texCube, 0);
514*35238bceSAndroid Build Coastguard Worker 
515*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
516*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, texCube);
517*35238bceSAndroid Build Coastguard Worker 
518*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 0);
519*35238bceSAndroid Build Coastguard Worker 
520*35238bceSAndroid Build Coastguard Worker     ctx.deleteTextures(1, &texCube);
521*35238bceSAndroid Build Coastguard Worker 
522*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
523*35238bceSAndroid Build Coastguard Worker 
524*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE);
525*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_DEPTH_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, texCube);
526*35238bceSAndroid Build Coastguard Worker }
527*35238bceSAndroid Build Coastguard Worker 
deleteRboAttachedToNotBoundFboTest(tcu::TestContext & testCtx,sglr::Context & ctx)528*35238bceSAndroid Build Coastguard Worker static void deleteRboAttachedToNotBoundFboTest(tcu::TestContext &testCtx, sglr::Context &ctx)
529*35238bceSAndroid Build Coastguard Worker {
530*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
531*35238bceSAndroid Build Coastguard Worker 
532*35238bceSAndroid Build Coastguard Worker     uint32_t rbo = 1;
533*35238bceSAndroid Build Coastguard Worker     ctx.bindRenderbuffer(GL_RENDERBUFFER, rbo);
534*35238bceSAndroid Build Coastguard Worker     ctx.framebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
535*35238bceSAndroid Build Coastguard Worker 
536*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
537*35238bceSAndroid Build Coastguard Worker                             GL_RENDERBUFFER);
538*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, rbo);
539*35238bceSAndroid Build Coastguard Worker 
540*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 0);
541*35238bceSAndroid Build Coastguard Worker 
542*35238bceSAndroid Build Coastguard Worker     ctx.deleteRenderbuffers(1, &rbo);
543*35238bceSAndroid Build Coastguard Worker 
544*35238bceSAndroid Build Coastguard Worker     ctx.bindFramebuffer(GL_FRAMEBUFFER, 1);
545*35238bceSAndroid Build Coastguard Worker 
546*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
547*35238bceSAndroid Build Coastguard Worker                             GL_RENDERBUFFER);
548*35238bceSAndroid Build Coastguard Worker     checkFboAttachmentParam(testCtx, ctx, GL_STENCIL_ATTACHMENT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, rbo);
549*35238bceSAndroid Build Coastguard Worker }
550*35238bceSAndroid Build Coastguard Worker 
551*35238bceSAndroid Build Coastguard Worker class FboApiCase : public TestCase
552*35238bceSAndroid Build Coastguard Worker {
553*35238bceSAndroid Build Coastguard Worker public:
554*35238bceSAndroid Build Coastguard Worker     typedef void (*TestFunc)(tcu::TestContext &testCtx, sglr::Context &context);
555*35238bceSAndroid Build Coastguard Worker 
556*35238bceSAndroid Build Coastguard Worker     FboApiCase(Context &context, const char *name, const char *description, TestFunc test);
557*35238bceSAndroid Build Coastguard Worker     virtual ~FboApiCase(void);
558*35238bceSAndroid Build Coastguard Worker 
559*35238bceSAndroid Build Coastguard Worker     virtual IterateResult iterate(void);
560*35238bceSAndroid Build Coastguard Worker 
561*35238bceSAndroid Build Coastguard Worker private:
562*35238bceSAndroid Build Coastguard Worker     FboApiCase(const FboApiCase &other);
563*35238bceSAndroid Build Coastguard Worker     FboApiCase &operator=(const FboApiCase &other);
564*35238bceSAndroid Build Coastguard Worker 
565*35238bceSAndroid Build Coastguard Worker     TestFunc m_testFunc;
566*35238bceSAndroid Build Coastguard Worker };
567*35238bceSAndroid Build Coastguard Worker 
FboApiCase(Context & context,const char * name,const char * description,TestFunc test)568*35238bceSAndroid Build Coastguard Worker FboApiCase::FboApiCase(Context &context, const char *name, const char *description, TestFunc test)
569*35238bceSAndroid Build Coastguard Worker     : TestCase(context, name, description)
570*35238bceSAndroid Build Coastguard Worker     , m_testFunc(test)
571*35238bceSAndroid Build Coastguard Worker {
572*35238bceSAndroid Build Coastguard Worker }
573*35238bceSAndroid Build Coastguard Worker 
~FboApiCase(void)574*35238bceSAndroid Build Coastguard Worker FboApiCase::~FboApiCase(void)
575*35238bceSAndroid Build Coastguard Worker {
576*35238bceSAndroid Build Coastguard Worker }
577*35238bceSAndroid Build Coastguard Worker 
iterate(void)578*35238bceSAndroid Build Coastguard Worker TestCase::IterateResult FboApiCase::iterate(void)
579*35238bceSAndroid Build Coastguard Worker {
580*35238bceSAndroid Build Coastguard Worker     const glw::Functions &gl = m_context.getRenderContext().getFunctions();
581*35238bceSAndroid Build Coastguard Worker 
582*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "Before test case");
583*35238bceSAndroid Build Coastguard Worker 
584*35238bceSAndroid Build Coastguard Worker     // Initialize result to PASS
585*35238bceSAndroid Build Coastguard Worker     m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
586*35238bceSAndroid Build Coastguard Worker 
587*35238bceSAndroid Build Coastguard Worker     // Execute test case
588*35238bceSAndroid Build Coastguard Worker     {
589*35238bceSAndroid Build Coastguard Worker         tcu::TestLog &log = m_context.getTestContext().getLog();
590*35238bceSAndroid Build Coastguard Worker         sglr::GLContext context(m_context.getRenderContext(), log, sglr::GLCONTEXT_LOG_CALLS,
591*35238bceSAndroid Build Coastguard Worker                                 tcu::IVec4(0, 0, m_context.getRenderContext().getRenderTarget().getWidth(),
592*35238bceSAndroid Build Coastguard Worker                                            m_context.getRenderContext().getRenderTarget().getHeight()));
593*35238bceSAndroid Build Coastguard Worker         m_testFunc(m_testCtx, context);
594*35238bceSAndroid Build Coastguard Worker     }
595*35238bceSAndroid Build Coastguard Worker 
596*35238bceSAndroid Build Coastguard Worker     GLU_EXPECT_NO_ERROR(gl.getError(), "After test case");
597*35238bceSAndroid Build Coastguard Worker 
598*35238bceSAndroid Build Coastguard Worker     return STOP;
599*35238bceSAndroid Build Coastguard Worker }
600*35238bceSAndroid Build Coastguard Worker 
FboApiTests(Context & context)601*35238bceSAndroid Build Coastguard Worker FboApiTests::FboApiTests(Context &context) : TestCaseGroup(context, "api", "API Tests")
602*35238bceSAndroid Build Coastguard Worker {
603*35238bceSAndroid Build Coastguard Worker }
604*35238bceSAndroid Build Coastguard Worker 
~FboApiTests(void)605*35238bceSAndroid Build Coastguard Worker FboApiTests::~FboApiTests(void)
606*35238bceSAndroid Build Coastguard Worker {
607*35238bceSAndroid Build Coastguard Worker }
608*35238bceSAndroid Build Coastguard Worker 
init(void)609*35238bceSAndroid Build Coastguard Worker void FboApiTests::init(void)
610*35238bceSAndroid Build Coastguard Worker {
611*35238bceSAndroid Build Coastguard Worker     // Valid attachments
612*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "valid_tex2d_attachments", "Valid 2D texture attachments",
613*35238bceSAndroid Build Coastguard Worker                             validTex2DAttachmentsTest));
614*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "valid_texcube_attachments", "Valid cubemap attachments",
615*35238bceSAndroid Build Coastguard Worker                             validTexCubeAttachmentsTest));
616*35238bceSAndroid Build Coastguard Worker     addChild(
617*35238bceSAndroid Build Coastguard Worker         new FboApiCase(m_context, "valid_rbo_attachments", "Valid renderbuffer attachments", validRboAttachmentsTest));
618*35238bceSAndroid Build Coastguard Worker 
619*35238bceSAndroid Build Coastguard Worker     // Invalid attachments
620*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attach_to_default_fbo", "Invalid usage: attaching to default FBO",
621*35238bceSAndroid Build Coastguard Worker                             attachToDefaultFramebufferTest));
622*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "invalid_tex2d_attachments", "Invalid 2D texture attachments",
623*35238bceSAndroid Build Coastguard Worker                             invalidTex2DAttachmentTest));
624*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "invalid_texcube_attachments", "Invalid cubemap attachments",
625*35238bceSAndroid Build Coastguard Worker                             invalidTexCubeAttachmentTest));
626*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "invalid_rbo_attachments", "Invalid renderbuffer attachments",
627*35238bceSAndroid Build Coastguard Worker                             invalidRboAttachmentTest));
628*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attach_names", "Attach allocated names without objects", attachNamesTest));
629*35238bceSAndroid Build Coastguard Worker 
630*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "texture_levels", "Valid and invalid texturel levels", textureLevelsTest));
631*35238bceSAndroid Build Coastguard Worker 
632*35238bceSAndroid Build Coastguard Worker     // Attachment queries
633*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attachment_query_default_fbo", "Query attachments from default FBO",
634*35238bceSAndroid Build Coastguard Worker                             attachmentQueryDefaultFboTest));
635*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attachment_query_empty_fbo", "Query attachments from empty FBO",
636*35238bceSAndroid Build Coastguard Worker                             attachmentQueryEmptyFboTest));
637*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attachment_query_tex2d", "Query 2d texture attachment properties",
638*35238bceSAndroid Build Coastguard Worker                             attachmentQueryTex2DTest));
639*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attachment_query_texcube", "Query cubemap attachment properties",
640*35238bceSAndroid Build Coastguard Worker                             attachmentQueryTexCubeTest));
641*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "attachment_query_rbo", "Query renderbuffer attachment properties",
642*35238bceSAndroid Build Coastguard Worker                             attachmentQueryRboTest));
643*35238bceSAndroid Build Coastguard Worker 
644*35238bceSAndroid Build Coastguard Worker     // Delete attachments
645*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "delete_tex_2d_attached_to_bound_fbo",
646*35238bceSAndroid Build Coastguard Worker                             "Delete 2d texture attached to currently bound FBO", deleteTex2DAttachedToBoundFboTest));
647*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "delete_tex_cube_attached_to_bound_fbo",
648*35238bceSAndroid Build Coastguard Worker                             "Delete cubemap attached to currently bound FBO", deleteTexCubeAttachedToBoundFboTest));
649*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "delete_rbo_attached_to_bound_fbo",
650*35238bceSAndroid Build Coastguard Worker                             "Delete renderbuffer attached to currently bound FBO", deleteRboAttachedToBoundFboTest));
651*35238bceSAndroid Build Coastguard Worker 
652*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "delete_tex_2d_attached_to_not_bound_fbo", "Delete 2d texture attached to FBO",
653*35238bceSAndroid Build Coastguard Worker                             deleteTex2DAttachedToNotBoundFboTest));
654*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "delete_tex_cube_attached_to_not_bound_fbo", "Delete cubemap attached to FBO",
655*35238bceSAndroid Build Coastguard Worker                             deleteTexCubeAttachedToNotBoundFboTest));
656*35238bceSAndroid Build Coastguard Worker     addChild(new FboApiCase(m_context, "delete_rbo_attached_to_not_bound_fbo", "Delete renderbuffer attached to FBO",
657*35238bceSAndroid Build Coastguard Worker                             deleteRboAttachedToNotBoundFboTest));
658*35238bceSAndroid Build Coastguard Worker }
659*35238bceSAndroid Build Coastguard Worker 
660*35238bceSAndroid Build Coastguard Worker } // namespace Functional
661*35238bceSAndroid Build Coastguard Worker } // namespace gles3
662*35238bceSAndroid Build Coastguard Worker } // namespace deqp
663