1e5c31af7Sopenharmony_ci/*------------------------------------------------------------------------- 2e5c31af7Sopenharmony_ci * drawElements Quality Program OpenGL ES 2.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 Fbo state query tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es2fFboStateQueryTests.hpp" 25e5c31af7Sopenharmony_ci#include "glsStateQueryUtil.hpp" 26e5c31af7Sopenharmony_ci#include "es2fApiCase.hpp" 27e5c31af7Sopenharmony_ci#include "gluRenderContext.hpp" 28e5c31af7Sopenharmony_ci#include "glwEnums.hpp" 29e5c31af7Sopenharmony_ci#include "glwFunctions.hpp" 30e5c31af7Sopenharmony_ci#include "tcuRenderTarget.hpp" 31e5c31af7Sopenharmony_ci#include "deMath.h" 32e5c31af7Sopenharmony_ci 33e5c31af7Sopenharmony_ciusing namespace glw; // GLint and other GL types 34e5c31af7Sopenharmony_ciusing deqp::gls::StateQueryUtil::StateQueryMemoryWriteGuard; 35e5c31af7Sopenharmony_ci 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_cinamespace deqp 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_cinamespace gles2 40e5c31af7Sopenharmony_ci{ 41e5c31af7Sopenharmony_cinamespace Functional 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_cinamespace 44e5c31af7Sopenharmony_ci{ 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_civoid checkIntEquals (tcu::TestContext& testCtx, GLint got, GLint expected) 47e5c31af7Sopenharmony_ci{ 48e5c31af7Sopenharmony_ci using tcu::TestLog; 49e5c31af7Sopenharmony_ci 50e5c31af7Sopenharmony_ci if (got != expected) 51e5c31af7Sopenharmony_ci { 52e5c31af7Sopenharmony_ci testCtx.getLog() << TestLog::Message << "// ERROR: Expected " << expected << "; got " << got << TestLog::EndMessage; 53e5c31af7Sopenharmony_ci if (testCtx.getTestResult() == QP_TEST_RESULT_PASS) 54e5c31af7Sopenharmony_ci testCtx.setTestResult(QP_TEST_RESULT_FAIL, "got invalid value"); 55e5c31af7Sopenharmony_ci } 56e5c31af7Sopenharmony_ci} 57e5c31af7Sopenharmony_ci 58e5c31af7Sopenharmony_civoid checkAttachmentParam(tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum target, GLenum attachment, GLenum pname, GLenum reference) 59e5c31af7Sopenharmony_ci{ 60e5c31af7Sopenharmony_ci StateQueryMemoryWriteGuard<GLint> state; 61e5c31af7Sopenharmony_ci gl.glGetFramebufferAttachmentParameteriv(target, attachment, pname, &state); 62e5c31af7Sopenharmony_ci 63e5c31af7Sopenharmony_ci if (state.verifyValidity(testCtx)) 64e5c31af7Sopenharmony_ci checkIntEquals(testCtx, state, reference); 65e5c31af7Sopenharmony_ci} 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_civoid checkColorAttachmentParam(tcu::TestContext& testCtx, glu::CallLogWrapper& gl, GLenum target, GLenum pname, GLenum reference) 68e5c31af7Sopenharmony_ci{ 69e5c31af7Sopenharmony_ci checkAttachmentParam(testCtx, gl, target, GL_COLOR_ATTACHMENT0, pname, reference); 70e5c31af7Sopenharmony_ci} 71e5c31af7Sopenharmony_ci 72e5c31af7Sopenharmony_ciclass AttachmentObjectCase : public ApiCase 73e5c31af7Sopenharmony_ci{ 74e5c31af7Sopenharmony_cipublic: 75e5c31af7Sopenharmony_ci AttachmentObjectCase (Context& context, const char* name, const char* description) 76e5c31af7Sopenharmony_ci : ApiCase(context, name, description) 77e5c31af7Sopenharmony_ci { 78e5c31af7Sopenharmony_ci } 79e5c31af7Sopenharmony_ci 80e5c31af7Sopenharmony_ci void test (void) 81e5c31af7Sopenharmony_ci { 82e5c31af7Sopenharmony_ci GLuint framebufferID = 0; 83e5c31af7Sopenharmony_ci glGenFramebuffers(1, &framebufferID); 84e5c31af7Sopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); 85e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci // texture 88e5c31af7Sopenharmony_ci { 89e5c31af7Sopenharmony_ci GLuint textureID = 0; 90e5c31af7Sopenharmony_ci glGenTextures(1, &textureID); 91e5c31af7Sopenharmony_ci glBindTexture(GL_TEXTURE_2D, textureID); 92e5c31af7Sopenharmony_ci glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, DE_NULL); 93e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 94e5c31af7Sopenharmony_ci 95e5c31af7Sopenharmony_ci glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0); 96e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 97e5c31af7Sopenharmony_ci 98e5c31af7Sopenharmony_ci checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_TEXTURE); 99e5c31af7Sopenharmony_ci checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, textureID); 100e5c31af7Sopenharmony_ci 101e5c31af7Sopenharmony_ci glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 102e5c31af7Sopenharmony_ci glDeleteTextures(1, &textureID); 103e5c31af7Sopenharmony_ci } 104e5c31af7Sopenharmony_ci 105e5c31af7Sopenharmony_ci // rb 106e5c31af7Sopenharmony_ci { 107e5c31af7Sopenharmony_ci GLuint renderbufferID = 0; 108e5c31af7Sopenharmony_ci glGenRenderbuffers(1, &renderbufferID); 109e5c31af7Sopenharmony_ci glBindRenderbuffer(GL_RENDERBUFFER, renderbufferID); 110e5c31af7Sopenharmony_ci glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA4, 128, 128); 111e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 112e5c31af7Sopenharmony_ci 113e5c31af7Sopenharmony_ci glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbufferID); 114e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 115e5c31af7Sopenharmony_ci 116e5c31af7Sopenharmony_ci checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, GL_RENDERBUFFER); 117e5c31af7Sopenharmony_ci checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, renderbufferID); 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_ci glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, 0); 120e5c31af7Sopenharmony_ci glDeleteRenderbuffers(1, &renderbufferID); 121e5c31af7Sopenharmony_ci } 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ci glDeleteFramebuffers(1, &framebufferID); 124e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 125e5c31af7Sopenharmony_ci } 126e5c31af7Sopenharmony_ci}; 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ciclass AttachmentTextureLevelCase : public ApiCase 129e5c31af7Sopenharmony_ci{ 130e5c31af7Sopenharmony_cipublic: 131e5c31af7Sopenharmony_ci AttachmentTextureLevelCase (Context& context, const char* name, const char* description) 132e5c31af7Sopenharmony_ci : ApiCase(context, name, description) 133e5c31af7Sopenharmony_ci { 134e5c31af7Sopenharmony_ci } 135e5c31af7Sopenharmony_ci 136e5c31af7Sopenharmony_ci void test (void) 137e5c31af7Sopenharmony_ci { 138e5c31af7Sopenharmony_ci GLuint framebufferID = 0; 139e5c31af7Sopenharmony_ci glGenFramebuffers(1, &framebufferID); 140e5c31af7Sopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); 141e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_ci // GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL can only be 0 144e5c31af7Sopenharmony_ci { 145e5c31af7Sopenharmony_ci GLuint textureID = 0; 146e5c31af7Sopenharmony_ci 147e5c31af7Sopenharmony_ci glGenTextures(1, &textureID); 148e5c31af7Sopenharmony_ci glBindTexture(GL_TEXTURE_2D, textureID); 149e5c31af7Sopenharmony_ci glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, DE_NULL); 150e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 151e5c31af7Sopenharmony_ci 152e5c31af7Sopenharmony_ci glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, textureID, 0); 153e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 154e5c31af7Sopenharmony_ci 155e5c31af7Sopenharmony_ci checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, 0); 156e5c31af7Sopenharmony_ci 157e5c31af7Sopenharmony_ci glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 158e5c31af7Sopenharmony_ci glDeleteTextures(1, &textureID); 159e5c31af7Sopenharmony_ci } 160e5c31af7Sopenharmony_ci 161e5c31af7Sopenharmony_ci glDeleteFramebuffers(1, &framebufferID); 162e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 163e5c31af7Sopenharmony_ci } 164e5c31af7Sopenharmony_ci}; 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_ciclass AttachmentTextureCubeMapFaceCase : public ApiCase 167e5c31af7Sopenharmony_ci{ 168e5c31af7Sopenharmony_cipublic: 169e5c31af7Sopenharmony_ci AttachmentTextureCubeMapFaceCase (Context& context, const char* name, const char* description) 170e5c31af7Sopenharmony_ci : ApiCase(context, name, description) 171e5c31af7Sopenharmony_ci { 172e5c31af7Sopenharmony_ci } 173e5c31af7Sopenharmony_ci 174e5c31af7Sopenharmony_ci void test (void) 175e5c31af7Sopenharmony_ci { 176e5c31af7Sopenharmony_ci GLuint framebufferID = 0; 177e5c31af7Sopenharmony_ci glGenFramebuffers(1, &framebufferID); 178e5c31af7Sopenharmony_ci glBindFramebuffer(GL_FRAMEBUFFER, framebufferID); 179e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 180e5c31af7Sopenharmony_ci 181e5c31af7Sopenharmony_ci { 182e5c31af7Sopenharmony_ci GLuint textureID = 0; 183e5c31af7Sopenharmony_ci glGenTextures(1, &textureID); 184e5c31af7Sopenharmony_ci glBindTexture(GL_TEXTURE_CUBE_MAP, textureID); 185e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 186e5c31af7Sopenharmony_ci 187e5c31af7Sopenharmony_ci const GLenum faces[] = 188e5c31af7Sopenharmony_ci { 189e5c31af7Sopenharmony_ci GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 190e5c31af7Sopenharmony_ci GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 191e5c31af7Sopenharmony_ci GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 192e5c31af7Sopenharmony_ci }; 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(faces); ++ndx) 195e5c31af7Sopenharmony_ci glTexImage2D(faces[ndx], 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, DE_NULL); 196e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 197e5c31af7Sopenharmony_ci 198e5c31af7Sopenharmony_ci for (int ndx = 0; ndx < DE_LENGTH_OF_ARRAY(faces); ++ndx) 199e5c31af7Sopenharmony_ci { 200e5c31af7Sopenharmony_ci glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, faces[ndx], textureID, 0); 201e5c31af7Sopenharmony_ci checkColorAttachmentParam(m_testCtx, *this, GL_FRAMEBUFFER, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, faces[ndx]); 202e5c31af7Sopenharmony_ci } 203e5c31af7Sopenharmony_ci 204e5c31af7Sopenharmony_ci glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); 205e5c31af7Sopenharmony_ci glDeleteTextures(1, &textureID); 206e5c31af7Sopenharmony_ci } 207e5c31af7Sopenharmony_ci 208e5c31af7Sopenharmony_ci glDeleteFramebuffers(1, &framebufferID); 209e5c31af7Sopenharmony_ci expectError(GL_NO_ERROR); 210e5c31af7Sopenharmony_ci } 211e5c31af7Sopenharmony_ci}; 212e5c31af7Sopenharmony_ci 213e5c31af7Sopenharmony_ci} // anonymous 214e5c31af7Sopenharmony_ci 215e5c31af7Sopenharmony_ci 216e5c31af7Sopenharmony_ciFboStateQueryTests::FboStateQueryTests (Context& context) 217e5c31af7Sopenharmony_ci : TestCaseGroup(context, "fbo", "Fbo State Query tests") 218e5c31af7Sopenharmony_ci{ 219e5c31af7Sopenharmony_ci} 220e5c31af7Sopenharmony_ci 221e5c31af7Sopenharmony_civoid FboStateQueryTests::init (void) 222e5c31af7Sopenharmony_ci{ 223e5c31af7Sopenharmony_ci addChild(new AttachmentObjectCase (m_context, "framebuffer_attachment_object", "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE and FRAMEBUFFER_ATTACHMENT_OBJECT_NAME")); 224e5c31af7Sopenharmony_ci addChild(new AttachmentTextureLevelCase (m_context, "framebuffer_attachment_texture_level", "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL")); 225e5c31af7Sopenharmony_ci addChild(new AttachmentTextureCubeMapFaceCase (m_context, "framebuffer_attachment_texture_cube_map_face", "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE")); 226e5c31af7Sopenharmony_ci} 227e5c31af7Sopenharmony_ci 228e5c31af7Sopenharmony_ci} // Functional 229e5c31af7Sopenharmony_ci} // gles2 230e5c31af7Sopenharmony_ci} // deqp 231