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 Occlusion query tests. 22e5c31af7Sopenharmony_ci *//*--------------------------------------------------------------------*/ 23e5c31af7Sopenharmony_ci 24e5c31af7Sopenharmony_ci#include "es3fOcclusionQueryTests.hpp" 25e5c31af7Sopenharmony_ci 26e5c31af7Sopenharmony_ci#include "tcuTestLog.hpp" 27e5c31af7Sopenharmony_ci#include "tcuVector.hpp" 28e5c31af7Sopenharmony_ci#include "tcuSurface.hpp" 29e5c31af7Sopenharmony_ci#include "tcuRenderTarget.hpp" 30e5c31af7Sopenharmony_ci#include "gluShaderProgram.hpp" 31e5c31af7Sopenharmony_ci#include "gluPixelTransfer.hpp" 32e5c31af7Sopenharmony_ci#include "deRandom.hpp" 33e5c31af7Sopenharmony_ci#include "deString.h" 34e5c31af7Sopenharmony_ci 35e5c31af7Sopenharmony_ci#include "glw.h" 36e5c31af7Sopenharmony_ci 37e5c31af7Sopenharmony_cinamespace deqp 38e5c31af7Sopenharmony_ci{ 39e5c31af7Sopenharmony_cinamespace gles3 40e5c31af7Sopenharmony_ci{ 41e5c31af7Sopenharmony_cinamespace Functional 42e5c31af7Sopenharmony_ci{ 43e5c31af7Sopenharmony_ci 44e5c31af7Sopenharmony_cistatic const tcu::Vec4 DEPTH_WRITE_COLOR = tcu::Vec4(0.0f, 0.0f, 1.0f, 1.0f); 45e5c31af7Sopenharmony_cistatic const tcu::Vec4 DEPTH_CLEAR_COLOR = tcu::Vec4(0.0f, 0.5f, 0.8f, 1.0f); 46e5c31af7Sopenharmony_cistatic const tcu::Vec4 STENCIL_WRITE_COLOR = tcu::Vec4(0.0f, 1.0f, 0.0f, 1.0f); 47e5c31af7Sopenharmony_cistatic const tcu::Vec4 STENCIL_CLEAR_COLOR = tcu::Vec4(0.0f, 0.8f, 0.5f, 1.0f); 48e5c31af7Sopenharmony_cistatic const tcu::Vec4 TARGET_COLOR = tcu::Vec4(1.0f, 0.0f, 0.0f, 1.0f); 49e5c31af7Sopenharmony_cistatic const int ELEMENTS_PER_VERTEX = 4; 50e5c31af7Sopenharmony_cistatic const int NUM_CASE_ITERATIONS = 10; 51e5c31af7Sopenharmony_ci 52e5c31af7Sopenharmony_ci// Constants to tweak visible/invisible case probability balance. 53e5c31af7Sopenharmony_ci 54e5c31af7Sopenharmony_cistatic const int DEPTH_CLEAR_OFFSET = 100; 55e5c31af7Sopenharmony_cistatic const int STENCIL_CLEAR_OFFSET = 100; 56e5c31af7Sopenharmony_cistatic const int SCISSOR_OFFSET = 100; 57e5c31af7Sopenharmony_cistatic const int SCISSOR_MINSIZE = 250; 58e5c31af7Sopenharmony_ci 59e5c31af7Sopenharmony_cienum OccluderType 60e5c31af7Sopenharmony_ci{ 61e5c31af7Sopenharmony_ci OCCLUDER_SCISSOR = (1 << 0), 62e5c31af7Sopenharmony_ci OCCLUDER_DEPTH_WRITE = (1 << 1), 63e5c31af7Sopenharmony_ci OCCLUDER_DEPTH_CLEAR = (1 << 2), 64e5c31af7Sopenharmony_ci OCCLUDER_STENCIL_WRITE = (1 << 3), 65e5c31af7Sopenharmony_ci OCCLUDER_STENCIL_CLEAR = (1 << 4) 66e5c31af7Sopenharmony_ci}; 67e5c31af7Sopenharmony_ci 68e5c31af7Sopenharmony_ciclass OcclusionQueryCase : public TestCase 69e5c31af7Sopenharmony_ci{ 70e5c31af7Sopenharmony_cipublic: 71e5c31af7Sopenharmony_ci OcclusionQueryCase (Context& context, const char* name, const char* description,int numOccluderDraws, int numOccludersPerDraw, float occluderSize, int numTargetDraws, int numTargetsPerDraw, float targetSize, deUint32 queryMode, deUint32 occluderTypes); 72e5c31af7Sopenharmony_ci ~OcclusionQueryCase (void); 73e5c31af7Sopenharmony_ci 74e5c31af7Sopenharmony_ci void init (void); 75e5c31af7Sopenharmony_ci void deinit (void); 76e5c31af7Sopenharmony_ci IterateResult iterate (void); 77e5c31af7Sopenharmony_ci 78e5c31af7Sopenharmony_ciprivate: 79e5c31af7Sopenharmony_ci OcclusionQueryCase (const OcclusionQueryCase& other); 80e5c31af7Sopenharmony_ci OcclusionQueryCase& operator= (const OcclusionQueryCase& other); 81e5c31af7Sopenharmony_ci 82e5c31af7Sopenharmony_ci int m_numOccluderDraws; 83e5c31af7Sopenharmony_ci int m_numOccludersPerDraw; 84e5c31af7Sopenharmony_ci float m_occluderSize; 85e5c31af7Sopenharmony_ci int m_numTargetDraws; 86e5c31af7Sopenharmony_ci int m_numTargetsPerDraw; 87e5c31af7Sopenharmony_ci float m_targetSize; 88e5c31af7Sopenharmony_ci deUint32 m_queryMode; 89e5c31af7Sopenharmony_ci deUint32 m_occluderTypes; 90e5c31af7Sopenharmony_ci 91e5c31af7Sopenharmony_ci glu::RenderContext& m_renderCtx; 92e5c31af7Sopenharmony_ci glu::ShaderProgram* m_program; 93e5c31af7Sopenharmony_ci int m_iterNdx; 94e5c31af7Sopenharmony_ci de::Random m_rnd; 95e5c31af7Sopenharmony_ci}; 96e5c31af7Sopenharmony_ci 97e5c31af7Sopenharmony_ciOcclusionQueryCase::OcclusionQueryCase (Context& context, const char* name, const char* description, int numOccluderDraws, int numOccludersPerDraw, float occluderSize, int numTargetDraws, int numTargetsPerDraw, float targetSize, deUint32 queryMode, deUint32 occluderTypes) 98e5c31af7Sopenharmony_ci : TestCase (context, name, description) 99e5c31af7Sopenharmony_ci , m_numOccluderDraws (numOccluderDraws) 100e5c31af7Sopenharmony_ci , m_numOccludersPerDraw (numOccludersPerDraw) 101e5c31af7Sopenharmony_ci , m_occluderSize (occluderSize) 102e5c31af7Sopenharmony_ci , m_numTargetDraws (numTargetDraws) 103e5c31af7Sopenharmony_ci , m_numTargetsPerDraw (numTargetsPerDraw) 104e5c31af7Sopenharmony_ci , m_targetSize (targetSize) 105e5c31af7Sopenharmony_ci , m_queryMode (queryMode) 106e5c31af7Sopenharmony_ci , m_occluderTypes (occluderTypes) 107e5c31af7Sopenharmony_ci , m_renderCtx (context.getRenderContext()) 108e5c31af7Sopenharmony_ci , m_program (DE_NULL) 109e5c31af7Sopenharmony_ci , m_iterNdx (0) 110e5c31af7Sopenharmony_ci , m_rnd (deStringHash(name)) 111e5c31af7Sopenharmony_ci{ 112e5c31af7Sopenharmony_ci} 113e5c31af7Sopenharmony_ci 114e5c31af7Sopenharmony_ciOcclusionQueryCase::~OcclusionQueryCase (void) 115e5c31af7Sopenharmony_ci{ 116e5c31af7Sopenharmony_ci OcclusionQueryCase::deinit(); 117e5c31af7Sopenharmony_ci} 118e5c31af7Sopenharmony_ci 119e5c31af7Sopenharmony_cistatic void generateVertices (std::vector<float>& dst, float width, float height, int primitiveCount, int verticesPerPrimitive, de::Random rnd, float primitiveSize, float minZ, float maxZ) 120e5c31af7Sopenharmony_ci{ 121e5c31af7Sopenharmony_ci float w = width/2.0f; 122e5c31af7Sopenharmony_ci float h = height/2.0f; 123e5c31af7Sopenharmony_ci float s = primitiveSize/2.0f; 124e5c31af7Sopenharmony_ci 125e5c31af7Sopenharmony_ci int vertexCount = verticesPerPrimitive * primitiveCount; 126e5c31af7Sopenharmony_ci dst.resize(vertexCount * ELEMENTS_PER_VERTEX); 127e5c31af7Sopenharmony_ci 128e5c31af7Sopenharmony_ci for (int i = 0; i < vertexCount; i += 3) // First loop gets a random point inside unit square 129e5c31af7Sopenharmony_ci { 130e5c31af7Sopenharmony_ci float rndX = rnd.getFloat(-w, w); 131e5c31af7Sopenharmony_ci float rndY = rnd.getFloat(-h, h); 132e5c31af7Sopenharmony_ci 133e5c31af7Sopenharmony_ci for (int j = 0; j < verticesPerPrimitive; j++) // Second loop gets 3 random points within given distance s from (rndX, rndY) 134e5c31af7Sopenharmony_ci { 135e5c31af7Sopenharmony_ci dst[(i+j)*ELEMENTS_PER_VERTEX ] = rndX + rnd.getFloat(-s,s); // x 136e5c31af7Sopenharmony_ci dst[(i+j)*ELEMENTS_PER_VERTEX + 1] = rndY + rnd.getFloat(-s,s); // y 137e5c31af7Sopenharmony_ci dst[(i+j)*ELEMENTS_PER_VERTEX + 2] = rnd.getFloat(minZ, maxZ); // z 138e5c31af7Sopenharmony_ci dst[(i+j)*ELEMENTS_PER_VERTEX + 3] = 1.0f; // w 139e5c31af7Sopenharmony_ci } 140e5c31af7Sopenharmony_ci } 141e5c31af7Sopenharmony_ci} 142e5c31af7Sopenharmony_ci 143e5c31af7Sopenharmony_civoid OcclusionQueryCase::init (void) 144e5c31af7Sopenharmony_ci{ 145e5c31af7Sopenharmony_ci const char* vertShaderSource = 146e5c31af7Sopenharmony_ci "#version 300 es\n" 147e5c31af7Sopenharmony_ci "layout(location = 0) in mediump vec4 a_position;\n" 148e5c31af7Sopenharmony_ci "\n" 149e5c31af7Sopenharmony_ci "void main (void)\n" 150e5c31af7Sopenharmony_ci "{\n" 151e5c31af7Sopenharmony_ci " gl_Position = a_position;\n" 152e5c31af7Sopenharmony_ci "}\n"; 153e5c31af7Sopenharmony_ci 154e5c31af7Sopenharmony_ci const char* fragShaderSource = 155e5c31af7Sopenharmony_ci "#version 300 es\n" 156e5c31af7Sopenharmony_ci "layout(location = 0) out mediump vec4 dEQP_FragColor;\n" 157e5c31af7Sopenharmony_ci "uniform mediump vec4 u_color;\n" 158e5c31af7Sopenharmony_ci "\n" 159e5c31af7Sopenharmony_ci "void main (void)\n" 160e5c31af7Sopenharmony_ci "{\n" 161e5c31af7Sopenharmony_ci " mediump float depth_gradient = max(gl_FragCoord.z, 0.0);\n" 162e5c31af7Sopenharmony_ci " mediump float bias = 0.1;\n" 163e5c31af7Sopenharmony_ci " dEQP_FragColor = vec4(u_color.xyz * (depth_gradient + bias), 1.0);\n" 164e5c31af7Sopenharmony_ci "}\n"; 165e5c31af7Sopenharmony_ci 166e5c31af7Sopenharmony_ci DE_ASSERT(!m_program); 167e5c31af7Sopenharmony_ci m_program = new glu::ShaderProgram(m_context.getRenderContext(), glu::makeVtxFragSources(vertShaderSource, fragShaderSource)); 168e5c31af7Sopenharmony_ci 169e5c31af7Sopenharmony_ci if (!m_program->isOk()) 170e5c31af7Sopenharmony_ci { 171e5c31af7Sopenharmony_ci m_testCtx.getLog() << *m_program; 172e5c31af7Sopenharmony_ci delete m_program; 173e5c31af7Sopenharmony_ci m_program = DE_NULL; 174e5c31af7Sopenharmony_ci TCU_FAIL("Failed to compile shader program"); 175e5c31af7Sopenharmony_ci } 176e5c31af7Sopenharmony_ci 177e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass"); // Initialize test result to pass. 178e5c31af7Sopenharmony_ci GLU_CHECK_MSG ("Case initialization finished"); 179e5c31af7Sopenharmony_ci} 180e5c31af7Sopenharmony_ci 181e5c31af7Sopenharmony_civoid OcclusionQueryCase::deinit (void) 182e5c31af7Sopenharmony_ci{ 183e5c31af7Sopenharmony_ci delete m_program; 184e5c31af7Sopenharmony_ci m_program = DE_NULL; 185e5c31af7Sopenharmony_ci} 186e5c31af7Sopenharmony_ci 187e5c31af7Sopenharmony_ciOcclusionQueryCase::IterateResult OcclusionQueryCase::iterate (void) 188e5c31af7Sopenharmony_ci{ 189e5c31af7Sopenharmony_ci tcu::TestLog& log = m_testCtx.getLog(); 190e5c31af7Sopenharmony_ci const tcu::RenderTarget& renderTarget = m_context.getRenderTarget(); 191e5c31af7Sopenharmony_ci deUint32 colorUnif = glGetUniformLocation(m_program->getProgram(), "u_color"); 192e5c31af7Sopenharmony_ci 193e5c31af7Sopenharmony_ci std::vector<float> occluderVertices; 194e5c31af7Sopenharmony_ci std::vector<float> targetVertices; 195e5c31af7Sopenharmony_ci std::vector<deUint32> queryIds(1, 0); 196e5c31af7Sopenharmony_ci bool queryResult = false; 197e5c31af7Sopenharmony_ci bool colorReadResult = false; 198e5c31af7Sopenharmony_ci int targetW = renderTarget.getWidth(); 199e5c31af7Sopenharmony_ci int targetH = renderTarget.getHeight(); 200e5c31af7Sopenharmony_ci 201e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Case iteration " << m_iterNdx+1 << " / " << NUM_CASE_ITERATIONS << tcu::TestLog::EndMessage; 202e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Parameters:\n" 203e5c31af7Sopenharmony_ci << "- " << m_numOccluderDraws << " occluder draws, " << m_numOccludersPerDraw << " primitive writes per draw,\n" 204e5c31af7Sopenharmony_ci << "- " << m_numTargetDraws << " target draws, " << m_numTargetsPerDraw << " targets per draw\n" 205e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 206e5c31af7Sopenharmony_ci 207e5c31af7Sopenharmony_ci DE_ASSERT(m_program); 208e5c31af7Sopenharmony_ci 209e5c31af7Sopenharmony_ci glClearColor (0.0f, 0.0f, 0.0f, 1.0f); 210e5c31af7Sopenharmony_ci glClearDepthf (1.0f); 211e5c31af7Sopenharmony_ci glClearStencil (0); 212e5c31af7Sopenharmony_ci glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 213e5c31af7Sopenharmony_ci glUseProgram (m_program->getProgram()); 214e5c31af7Sopenharmony_ci glEnableVertexAttribArray (0); 215e5c31af7Sopenharmony_ci 216e5c31af7Sopenharmony_ci // Draw occluders 217e5c31af7Sopenharmony_ci 218e5c31af7Sopenharmony_ci std::vector<OccluderType> occOptions(0); 219e5c31af7Sopenharmony_ci if (m_occluderTypes & OCCLUDER_DEPTH_WRITE) occOptions.push_back(OCCLUDER_DEPTH_WRITE); 220e5c31af7Sopenharmony_ci if (m_occluderTypes & OCCLUDER_DEPTH_CLEAR) occOptions.push_back(OCCLUDER_DEPTH_CLEAR); 221e5c31af7Sopenharmony_ci if (m_occluderTypes & OCCLUDER_STENCIL_WRITE) occOptions.push_back(OCCLUDER_STENCIL_WRITE); 222e5c31af7Sopenharmony_ci if (m_occluderTypes & OCCLUDER_STENCIL_CLEAR) occOptions.push_back(OCCLUDER_STENCIL_CLEAR); 223e5c31af7Sopenharmony_ci 224e5c31af7Sopenharmony_ci for (int i = 0; i < m_numOccluderDraws; i++) 225e5c31af7Sopenharmony_ci { 226e5c31af7Sopenharmony_ci if (occOptions.empty()) 227e5c31af7Sopenharmony_ci break; 228e5c31af7Sopenharmony_ci 229e5c31af7Sopenharmony_ci OccluderType type = occOptions[m_rnd.getInt(0, (int)occOptions.size()-1)]; // Choosing a random occluder type from available options 230e5c31af7Sopenharmony_ci 231e5c31af7Sopenharmony_ci switch (type) 232e5c31af7Sopenharmony_ci { 233e5c31af7Sopenharmony_ci case OCCLUDER_DEPTH_WRITE: 234e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Occluder draw " << i+1 << " / " << m_numOccluderDraws << " : " 235e5c31af7Sopenharmony_ci << "Depth write" << tcu::TestLog::EndMessage; 236e5c31af7Sopenharmony_ci 237e5c31af7Sopenharmony_ci generateVertices(occluderVertices, 2.0f, 2.0f, m_numOccludersPerDraw, 3, m_rnd, m_occluderSize, 0.0f, 0.6f); // Generate vertices for occluding primitives 238e5c31af7Sopenharmony_ci 239e5c31af7Sopenharmony_ci DE_ASSERT(!occluderVertices.empty()); 240e5c31af7Sopenharmony_ci 241e5c31af7Sopenharmony_ci glEnable (GL_DEPTH_TEST); 242e5c31af7Sopenharmony_ci glUniform4f (colorUnif, DEPTH_WRITE_COLOR.x(), DEPTH_WRITE_COLOR.y(), DEPTH_WRITE_COLOR.z(), DEPTH_WRITE_COLOR.w()); 243e5c31af7Sopenharmony_ci glVertexAttribPointer (0, ELEMENTS_PER_VERTEX, GL_FLOAT, GL_FALSE, 0, &occluderVertices[0]); 244e5c31af7Sopenharmony_ci glDrawArrays (GL_TRIANGLES, 0, 3*m_numOccludersPerDraw); 245e5c31af7Sopenharmony_ci glDisable (GL_DEPTH_TEST); 246e5c31af7Sopenharmony_ci 247e5c31af7Sopenharmony_ci break; 248e5c31af7Sopenharmony_ci 249e5c31af7Sopenharmony_ci case OCCLUDER_DEPTH_CLEAR: 250e5c31af7Sopenharmony_ci { 251e5c31af7Sopenharmony_ci int scissorBoxX = m_rnd.getInt(-DEPTH_CLEAR_OFFSET, targetW); 252e5c31af7Sopenharmony_ci int scissorBoxY = m_rnd.getInt(-DEPTH_CLEAR_OFFSET, targetH); 253e5c31af7Sopenharmony_ci int scissorBoxW = m_rnd.getInt( DEPTH_CLEAR_OFFSET, targetW+DEPTH_CLEAR_OFFSET); 254e5c31af7Sopenharmony_ci int scissorBoxH = m_rnd.getInt( DEPTH_CLEAR_OFFSET, targetH+DEPTH_CLEAR_OFFSET); 255e5c31af7Sopenharmony_ci 256e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Occluder draw " << i+1 << " / " << m_numOccluderDraws << " : " << "Depth clear" 257e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 258e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Depth-clearing box drawn at " 259e5c31af7Sopenharmony_ci << "(" << scissorBoxX << ", " << scissorBoxY << ")" 260e5c31af7Sopenharmony_ci << ", width = " << scissorBoxW << ", height = " << scissorBoxH << "." 261e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 262e5c31af7Sopenharmony_ci 263e5c31af7Sopenharmony_ci glEnable (GL_SCISSOR_TEST); 264e5c31af7Sopenharmony_ci glScissor (scissorBoxX, scissorBoxY, scissorBoxW, scissorBoxH); 265e5c31af7Sopenharmony_ci glClearDepthf (0.0f); 266e5c31af7Sopenharmony_ci glClearColor (DEPTH_CLEAR_COLOR.x(), DEPTH_CLEAR_COLOR.y(), DEPTH_CLEAR_COLOR.z(), DEPTH_CLEAR_COLOR.w()); 267e5c31af7Sopenharmony_ci glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 268e5c31af7Sopenharmony_ci glDisable (GL_SCISSOR_TEST); 269e5c31af7Sopenharmony_ci 270e5c31af7Sopenharmony_ci break; 271e5c31af7Sopenharmony_ci } 272e5c31af7Sopenharmony_ci 273e5c31af7Sopenharmony_ci case OCCLUDER_STENCIL_WRITE: 274e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Occluder draw " << i+1 << " / " << m_numOccluderDraws << " : " 275e5c31af7Sopenharmony_ci << "Stencil write" << tcu::TestLog::EndMessage; 276e5c31af7Sopenharmony_ci 277e5c31af7Sopenharmony_ci generateVertices(occluderVertices, 2.0f, 2.0f, m_numOccludersPerDraw, 3, m_rnd, m_occluderSize, 0.0f, 0.6f); 278e5c31af7Sopenharmony_ci 279e5c31af7Sopenharmony_ci glStencilFunc (GL_ALWAYS, 1, 0xFF); 280e5c31af7Sopenharmony_ci glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE); 281e5c31af7Sopenharmony_ci 282e5c31af7Sopenharmony_ci DE_ASSERT(!occluderVertices.empty()); 283e5c31af7Sopenharmony_ci 284e5c31af7Sopenharmony_ci glEnable (GL_STENCIL_TEST); 285e5c31af7Sopenharmony_ci glUniform4f (colorUnif, STENCIL_WRITE_COLOR.x(), STENCIL_WRITE_COLOR.y(), STENCIL_WRITE_COLOR.z(), STENCIL_WRITE_COLOR.w()); 286e5c31af7Sopenharmony_ci glVertexAttribPointer (0, ELEMENTS_PER_VERTEX, GL_FLOAT, GL_FALSE, 0, &occluderVertices[0]); 287e5c31af7Sopenharmony_ci glDrawArrays (GL_TRIANGLES, 0, 3*m_numOccludersPerDraw); 288e5c31af7Sopenharmony_ci glDisable (GL_STENCIL_TEST); 289e5c31af7Sopenharmony_ci 290e5c31af7Sopenharmony_ci break; 291e5c31af7Sopenharmony_ci 292e5c31af7Sopenharmony_ci case OCCLUDER_STENCIL_CLEAR: 293e5c31af7Sopenharmony_ci { 294e5c31af7Sopenharmony_ci int scissorBoxX = m_rnd.getInt(-STENCIL_CLEAR_OFFSET, targetW); 295e5c31af7Sopenharmony_ci int scissorBoxY = m_rnd.getInt(-STENCIL_CLEAR_OFFSET, targetH); 296e5c31af7Sopenharmony_ci int scissorBoxW = m_rnd.getInt( STENCIL_CLEAR_OFFSET, targetW+STENCIL_CLEAR_OFFSET); 297e5c31af7Sopenharmony_ci int scissorBoxH = m_rnd.getInt( STENCIL_CLEAR_OFFSET, targetH+STENCIL_CLEAR_OFFSET); 298e5c31af7Sopenharmony_ci 299e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Occluder draw " << i+1 << " / " << m_numOccluderDraws << " : " << "Stencil clear" 300e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 301e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Stencil-clearing box drawn at " 302e5c31af7Sopenharmony_ci << "(" << scissorBoxX << ", " << scissorBoxY << ")" 303e5c31af7Sopenharmony_ci << ", width = " << scissorBoxW << ", height = " << scissorBoxH << "." 304e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 305e5c31af7Sopenharmony_ci 306e5c31af7Sopenharmony_ci glEnable (GL_SCISSOR_TEST); 307e5c31af7Sopenharmony_ci glScissor (scissorBoxX, scissorBoxY, scissorBoxW, scissorBoxH); 308e5c31af7Sopenharmony_ci glClearStencil (1); 309e5c31af7Sopenharmony_ci glClearColor (STENCIL_CLEAR_COLOR.x(), STENCIL_CLEAR_COLOR.y(), STENCIL_CLEAR_COLOR.z(), STENCIL_CLEAR_COLOR.w()); 310e5c31af7Sopenharmony_ci glClear (GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 311e5c31af7Sopenharmony_ci glDisable (GL_SCISSOR_TEST); 312e5c31af7Sopenharmony_ci 313e5c31af7Sopenharmony_ci break; 314e5c31af7Sopenharmony_ci } 315e5c31af7Sopenharmony_ci 316e5c31af7Sopenharmony_ci default: 317e5c31af7Sopenharmony_ci DE_ASSERT(false); 318e5c31af7Sopenharmony_ci break; 319e5c31af7Sopenharmony_ci } 320e5c31af7Sopenharmony_ci } 321e5c31af7Sopenharmony_ci 322e5c31af7Sopenharmony_ci if (m_occluderTypes & OCCLUDER_SCISSOR) 323e5c31af7Sopenharmony_ci { 324e5c31af7Sopenharmony_ci int scissorBoxX = m_rnd.getInt(-SCISSOR_OFFSET, targetW-SCISSOR_OFFSET); 325e5c31af7Sopenharmony_ci int scissorBoxY = m_rnd.getInt(-SCISSOR_OFFSET, targetH-SCISSOR_OFFSET); 326e5c31af7Sopenharmony_ci int scissorBoxW = m_rnd.getInt(SCISSOR_MINSIZE, targetW+SCISSOR_OFFSET); 327e5c31af7Sopenharmony_ci int scissorBoxH = m_rnd.getInt(SCISSOR_MINSIZE, targetH+SCISSOR_OFFSET); 328e5c31af7Sopenharmony_ci 329e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Scissor box drawn at " 330e5c31af7Sopenharmony_ci << "(" << scissorBoxX << ", " << scissorBoxY << ")" 331e5c31af7Sopenharmony_ci << ", width = " << scissorBoxW << ", height = " << scissorBoxH << "." 332e5c31af7Sopenharmony_ci << tcu::TestLog::EndMessage; 333e5c31af7Sopenharmony_ci 334e5c31af7Sopenharmony_ci glEnable (GL_SCISSOR_TEST); 335e5c31af7Sopenharmony_ci glScissor (scissorBoxX, scissorBoxY, scissorBoxW, scissorBoxH); 336e5c31af7Sopenharmony_ci } 337e5c31af7Sopenharmony_ci 338e5c31af7Sopenharmony_ci glGenQueries (1, &queryIds[0]); 339e5c31af7Sopenharmony_ci glBeginQuery (m_queryMode, queryIds[0]); 340e5c31af7Sopenharmony_ci GLU_CHECK_MSG ("Occlusion query started"); 341e5c31af7Sopenharmony_ci 342e5c31af7Sopenharmony_ci // Draw target primitives 343e5c31af7Sopenharmony_ci 344e5c31af7Sopenharmony_ci glEnable (GL_DEPTH_TEST); 345e5c31af7Sopenharmony_ci glEnable (GL_STENCIL_TEST); 346e5c31af7Sopenharmony_ci glStencilFunc (GL_EQUAL, 0, 0xFF); 347e5c31af7Sopenharmony_ci 348e5c31af7Sopenharmony_ci for (int i = 0; i < m_numTargetDraws; i++) 349e5c31af7Sopenharmony_ci { 350e5c31af7Sopenharmony_ci generateVertices(targetVertices, 2.0f, 2.0f, m_numTargetsPerDraw, 3, m_rnd, m_targetSize, 0.4f, 1.0f); // Generate vertices for target primitives 351e5c31af7Sopenharmony_ci 352e5c31af7Sopenharmony_ci if (!targetVertices.empty()) 353e5c31af7Sopenharmony_ci { 354e5c31af7Sopenharmony_ci glUniform4f (colorUnif, TARGET_COLOR.x(), TARGET_COLOR.y(), TARGET_COLOR.z(), TARGET_COLOR.w()); 355e5c31af7Sopenharmony_ci glVertexAttribPointer (0, ELEMENTS_PER_VERTEX, GL_FLOAT, GL_FALSE, 0, &targetVertices[0]); 356e5c31af7Sopenharmony_ci glDrawArrays (GL_TRIANGLES, 0, 3*m_numTargetsPerDraw); 357e5c31af7Sopenharmony_ci } 358e5c31af7Sopenharmony_ci } 359e5c31af7Sopenharmony_ci 360e5c31af7Sopenharmony_ci glEndQuery (m_queryMode); 361e5c31af7Sopenharmony_ci glFinish (); 362e5c31af7Sopenharmony_ci glDisable (GL_SCISSOR_TEST); 363e5c31af7Sopenharmony_ci glDisable (GL_STENCIL_TEST); 364e5c31af7Sopenharmony_ci glDisable (GL_DEPTH_TEST); 365e5c31af7Sopenharmony_ci 366e5c31af7Sopenharmony_ci // Check that query result is available. 367e5c31af7Sopenharmony_ci { 368e5c31af7Sopenharmony_ci deUint32 resultAvailable = GL_FALSE; 369e5c31af7Sopenharmony_ci glGetQueryObjectuiv(queryIds[0], GL_QUERY_RESULT_AVAILABLE, &resultAvailable); 370e5c31af7Sopenharmony_ci 371e5c31af7Sopenharmony_ci if (resultAvailable == GL_FALSE) 372e5c31af7Sopenharmony_ci TCU_FAIL("Occlusion query failed to return a result after glFinish()"); 373e5c31af7Sopenharmony_ci } 374e5c31af7Sopenharmony_ci 375e5c31af7Sopenharmony_ci // Read query result. 376e5c31af7Sopenharmony_ci { 377e5c31af7Sopenharmony_ci deUint32 result = 0; 378e5c31af7Sopenharmony_ci glGetQueryObjectuiv(queryIds[0], GL_QUERY_RESULT, &result); 379e5c31af7Sopenharmony_ci queryResult = (result != GL_FALSE); 380e5c31af7Sopenharmony_ci } 381e5c31af7Sopenharmony_ci 382e5c31af7Sopenharmony_ci glDeleteQueries (1, &queryIds[0]); 383e5c31af7Sopenharmony_ci GLU_CHECK_MSG ("Occlusion query finished"); 384e5c31af7Sopenharmony_ci 385e5c31af7Sopenharmony_ci // Read pixel data 386e5c31af7Sopenharmony_ci 387e5c31af7Sopenharmony_ci tcu::Surface pixels(renderTarget.getWidth(), renderTarget.getHeight()); 388e5c31af7Sopenharmony_ci glu::readPixels(m_context.getRenderContext(), 0, 0, pixels.getAccess()); 389e5c31af7Sopenharmony_ci 390e5c31af7Sopenharmony_ci { 391e5c31af7Sopenharmony_ci int width = pixels.getWidth(); 392e5c31af7Sopenharmony_ci int height = pixels.getHeight(); 393e5c31af7Sopenharmony_ci 394e5c31af7Sopenharmony_ci for (int y = 0; y < height; y++) 395e5c31af7Sopenharmony_ci { 396e5c31af7Sopenharmony_ci for (int x = 0; x < width; x++) 397e5c31af7Sopenharmony_ci { 398e5c31af7Sopenharmony_ci if (pixels.getPixel(x,y).getRed() != 0) 399e5c31af7Sopenharmony_ci { 400e5c31af7Sopenharmony_ci colorReadResult = true; 401e5c31af7Sopenharmony_ci break; 402e5c31af7Sopenharmony_ci } 403e5c31af7Sopenharmony_ci } 404e5c31af7Sopenharmony_ci if (colorReadResult) break; 405e5c31af7Sopenharmony_ci } 406e5c31af7Sopenharmony_ci } 407e5c31af7Sopenharmony_ci 408e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Occlusion query result: Target " << (queryResult ? "visible" : "invisible") << "\n" 409e5c31af7Sopenharmony_ci << "Framebuffer read result: Target " << (colorReadResult ? "visible" : "invisible") << tcu::TestLog::EndMessage; 410e5c31af7Sopenharmony_ci 411e5c31af7Sopenharmony_ci bool testOk = false; 412e5c31af7Sopenharmony_ci if (m_queryMode == GL_ANY_SAMPLES_PASSED_CONSERVATIVE) 413e5c31af7Sopenharmony_ci { 414e5c31af7Sopenharmony_ci if (queryResult || colorReadResult) 415e5c31af7Sopenharmony_ci testOk = queryResult; // Allow conservative occlusion query to return false positives. 416e5c31af7Sopenharmony_ci else 417e5c31af7Sopenharmony_ci testOk = queryResult == colorReadResult; 418e5c31af7Sopenharmony_ci } 419e5c31af7Sopenharmony_ci else 420e5c31af7Sopenharmony_ci testOk = (queryResult == colorReadResult); 421e5c31af7Sopenharmony_ci 422e5c31af7Sopenharmony_ci if (!testOk) 423e5c31af7Sopenharmony_ci { 424e5c31af7Sopenharmony_ci log << tcu::TestLog::Image("Result image", "Result image", pixels); 425e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Case FAILED!" << tcu::TestLog::EndMessage; 426e5c31af7Sopenharmony_ci 427e5c31af7Sopenharmony_ci m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Fail"); 428e5c31af7Sopenharmony_ci return STOP; 429e5c31af7Sopenharmony_ci } 430e5c31af7Sopenharmony_ci 431e5c31af7Sopenharmony_ci log << tcu::TestLog::Message << "Case passed!" << tcu::TestLog::EndMessage; 432e5c31af7Sopenharmony_ci 433e5c31af7Sopenharmony_ci return (++m_iterNdx < NUM_CASE_ITERATIONS) ? CONTINUE : STOP; 434e5c31af7Sopenharmony_ci} 435e5c31af7Sopenharmony_ci 436e5c31af7Sopenharmony_ciOcclusionQueryTests::OcclusionQueryTests (Context& context) 437e5c31af7Sopenharmony_ci : TestCaseGroup(context, "occlusion_query", "Occlusion Query Tests") 438e5c31af7Sopenharmony_ci{ 439e5c31af7Sopenharmony_ci} 440e5c31af7Sopenharmony_ci 441e5c31af7Sopenharmony_ciOcclusionQueryTests::~OcclusionQueryTests (void) 442e5c31af7Sopenharmony_ci{ 443e5c31af7Sopenharmony_ci} 444e5c31af7Sopenharmony_ci 445e5c31af7Sopenharmony_civoid OcclusionQueryTests::init (void) 446e5c31af7Sopenharmony_ci{ 447e5c31af7Sopenharmony_ci // Strict occlusion query cases 448e5c31af7Sopenharmony_ci 449e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor", "scissor", 1, 10, 1.6f, 1, 1, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR)); 450e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write", "depth_write", 8, 10, 1.6f, 1, 7, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE)); 451e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_clear", "depth_clear", 5, 10, 1.6f, 1, 5, 0.2f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_CLEAR)); 452e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "stencil_write", "stencil_write", 8, 10, 2.0f, 1, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_STENCIL_WRITE)); 453e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "stencil_clear", "stencil_clear", 5, 10, 2.0f, 1, 3, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_STENCIL_CLEAR)); 454e5c31af7Sopenharmony_ci 455e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write", "scissor_depth_write", 5, 10, 1.6f, 2, 5, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE)); 456e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_clear", "scissor_depth_clear", 7, 10, 1.6f, 2, 5, 1.0f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR)); 457e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_stencil_write", "scissor_stencil_write", 4, 10, 1.6f, 2, 5, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_STENCIL_WRITE)); 458e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_stencil_clear", "scissor_stencil_clear", 4, 10, 1.6f, 2, 5, 1.0f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_STENCIL_CLEAR)); 459e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_depth_clear", "depth_write_depth_clear", 7, 10, 1.6f, 1, 5, 0.2f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR)); 460e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_stencil_write", "depth_write_stencil_write", 8, 10, 1.6f, 1, 5, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE)); 461e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_stencil_clear", "depth_write_stencil_clear", 8, 10, 1.6f, 1, 5, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_CLEAR)); 462e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_clear_stencil_write", "depth_clear_stencil_write", 8, 10, 1.6f, 1, 5, 0.3f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 463e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_clear_stencil_clear", "depth_clear_stencil_clear", 12, 10, 1.6f, 1, 5, 0.2f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 464e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "stencil_write_stencil_clear", "stencil_write_stencil_clear", 5, 10, 2.0f, 1, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 465e5c31af7Sopenharmony_ci 466e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write_depth_clear", "scissor_depth_write_depth_clear", 5, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR)); 467e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write_stencil_write", "scissor_depth_write_stencil_write", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE)); 468e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write_stencil_clear", "scissor_depth_write_stencil_clear", 6, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_CLEAR)); 469e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_clear_stencil_write", "scissor_depth_clear_stencil_write", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 470e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_clear_stencil_clear", "scissor_depth_clear_stencil_clear", 5, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 471e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_stencil_write_stencil_clear", "scissor_stencil_write_stencil_clear", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 472e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_depth_clear_stencil_write", "depth_write_depth_clear_stencil_write", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 473e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_depth_clear_stencil_clear", "depth_write_depth_clear_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 474e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_stencil_write_stencil_clear", "depth_write_stencil_write_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 475e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_clear_stencil_write_stencil_clear", "depth_clear_stencil_write_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 476e5c31af7Sopenharmony_ci 477e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write_depth_clear_stencil_write", "scissor_depth_write_depth_clear_stencil_write", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 478e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write_depth_clear_stencil_clear", "scissor_depth_write_depth_clear_stencil_clear", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 479e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_write_stencil_write_stencil_clear", "scissor_depth_write_stencil_write_stencil_clear", 5, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 480e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "scissor_depth_clear_stencil_write_stencil_clear", "scissor_depth_clear_stencil_write_stencil_clear", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 481e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "depth_write_depth_clear_stencil_write_stencil_clear", "depth_write_depth_clear_stencil_write_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 482e5c31af7Sopenharmony_ci 483e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "all_occluders", "all_occluders", 7, 10, 1.6f, 3, 5, 0.6f, GL_ANY_SAMPLES_PASSED, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 484e5c31af7Sopenharmony_ci 485e5c31af7Sopenharmony_ci // Conservative occlusion query cases 486e5c31af7Sopenharmony_ci 487e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor", "conservative_scissor", 1, 10, 1.6f, 1, 1, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR)); 488e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write", "conservative_depth_write", 8, 10, 1.6f, 1, 7, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE)); 489e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_clear", "conservative_depth_clear", 5, 10, 1.6f, 1, 5, 0.2f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_CLEAR)); 490e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_stencil_write", "conservative_stencil_write", 8, 10, 2.0f, 1, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_STENCIL_WRITE)); 491e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_stencil_clear", "conservative_stencil_clear", 5, 10, 2.0f, 1, 3, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_STENCIL_CLEAR)); 492e5c31af7Sopenharmony_ci 493e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write", "conservative_scissor_depth_write", 5, 10, 1.6f, 2, 5, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE)); 494e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_clear", "conservative_scissor_depth_clear", 7, 10, 1.6f, 2, 5, 1.0f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR)); 495e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_stencil_write", "conservative_scissor_stencil_write", 4, 10, 1.6f, 2, 5, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_STENCIL_WRITE)); 496e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_stencil_clear", "conservative_scissor_stencil_clear", 4, 10, 1.6f, 2, 5, 1.0f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_STENCIL_CLEAR)); 497e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_depth_clear", "conservative_depth_write_depth_clear", 7, 10, 1.6f, 1, 5, 0.2f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR)); 498e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_stencil_write", "conservative_depth_write_stencil_write", 8, 10, 1.6f, 1, 5, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE)); 499e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_stencil_clear", "conservative_depth_write_stencil_clear", 8, 10, 1.6f, 1, 5, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_CLEAR)); 500e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_clear_stencil_write", "conservative_depth_clear_stencil_write", 8, 10, 1.6f, 1, 5, 0.3f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 501e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_clear_stencil_clear", "conservative_depth_clear_stencil_clear", 12, 10, 1.6f, 1, 5, 0.2f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 502e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_stencil_write_stencil_clear", "conservative_stencil_write_stencil_clear", 5, 10, 2.0f, 1, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 503e5c31af7Sopenharmony_ci 504e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write_depth_clear", "conservative_scissor_depth_write_depth_clear", 5, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR)); 505e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write_stencil_write", "conservative_scissor_depth_write_stencil_write", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE)); 506e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write_stencil_clear", "conservative_scissor_depth_write_stencil_clear", 6, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_CLEAR)); 507e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_clear_stencil_write", "conservative_scissor_depth_clear_stencil_write", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 508e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_clear_stencil_clear", "conservative_scissor_depth_clear_stencil_clear", 5, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 509e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_stencil_write_stencil_clear", "conservative_scissor_stencil_write_stencil_clear", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 510e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_depth_clear_stencil_write", "conservative_depth_write_depth_clear_stencil_write", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 511e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_depth_clear_stencil_clear", "conservative_depth_write_depth_clear_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 512e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_stencil_write_stencil_clear", "conservative_depth_write_stencil_write_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 513e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_clear_stencil_write_stencil_clear", "conservative_depth_clear_stencil_write_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 514e5c31af7Sopenharmony_ci 515e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write_depth_clear_stencil_write", "conservative_scissor_depth_write_depth_clear_stencil_write", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE)); 516e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write_depth_clear_stencil_clear", "conservative_scissor_depth_write_depth_clear_stencil_clear", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_CLEAR)); 517e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_write_stencil_write_stencil_clear", "conservative_scissor_depth_write_stencil_write_stencil_clear", 5, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 518e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_scissor_depth_clear_stencil_write_stencil_clear", "conservative_scissor_depth_clear_stencil_write_stencil_clear", 4, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 519e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_depth_write_depth_clear_stencil_write_stencil_clear", "conservative_depth_write_depth_clear_stencil_write_stencil_clear", 7, 10, 1.6f, 2, 5, 0.4f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 520e5c31af7Sopenharmony_ci 521e5c31af7Sopenharmony_ci addChild(new OcclusionQueryCase(m_context, "conservative_all_occluders", "conservative_all_occluders", 7, 10, 1.6f, 3, 5, 0.6f, GL_ANY_SAMPLES_PASSED_CONSERVATIVE, OCCLUDER_SCISSOR | OCCLUDER_DEPTH_WRITE | OCCLUDER_DEPTH_CLEAR | OCCLUDER_STENCIL_WRITE | OCCLUDER_STENCIL_CLEAR)); 522e5c31af7Sopenharmony_ci} 523e5c31af7Sopenharmony_ci 524e5c31af7Sopenharmony_ci} // Functional 525e5c31af7Sopenharmony_ci} // gles3 526e5c31af7Sopenharmony_ci} // deqp 527