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