Hash :
322653bf
Author :
Date :
2015-06-17T18:33:56
Fix Chromium build of angle_end2end_tests BUG=angleproject:892 Change-Id: I9922046fc9e4d82d7034405f5952263f982c6529 Reviewed-on: https://chromium-review.googlesource.com/278159 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "system_utils.h"
#include "test_utils/ANGLETest.h"
using namespace angle;
class OcclusionQueriesTest : public ANGLETest
{
protected:
OcclusionQueriesTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setConfigDepthBits(24);
mProgram = 0;
}
virtual void SetUp()
{
ANGLETest::SetUp();
const std::string passthroughVS = SHADER_SOURCE
(
attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
const std::string passthroughPS = SHADER_SOURCE
(
precision highp float;
void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
}
);
mProgram = CompileProgram(passthroughVS, passthroughPS);
if (mProgram == 0)
{
FAIL() << "shader compilation failed.";
}
}
virtual void TearDown()
{
glDeleteProgram(mProgram);
ANGLETest::TearDown();
}
GLuint mProgram;
};
TEST_P(OcclusionQueriesTest, IsOccluded)
{
glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// draw a quad at depth 0.3
glEnable(GL_DEPTH_TEST);
glUseProgram(mProgram);
drawQuad(mProgram, "position", 0.3f);
glUseProgram(0);
EXPECT_GL_NO_ERROR();
GLuint query = 0;
glGenQueriesEXT(1, &query);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query);
drawQuad(mProgram, "position", 0.8f); // this quad should be occluded by first quad
glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
EXPECT_GL_NO_ERROR();
swapBuffers();
GLuint ready = GL_FALSE;
while (ready == GL_FALSE)
{
angle::Sleep(0);
glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &ready);
}
GLuint result = GL_TRUE;
glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &result);
EXPECT_GL_NO_ERROR();
glDeleteQueriesEXT(1, &query);
EXPECT_GLENUM_EQ(GL_FALSE, result);
}
TEST_P(OcclusionQueriesTest, IsNotOccluded)
{
glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
GLuint query = 0;
glGenQueriesEXT(1, &query);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query);
drawQuad(mProgram, "position", 0.8f); // this quad should not be occluded
glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
EXPECT_GL_NO_ERROR();
swapBuffers();
GLuint result = GL_TRUE;
glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &result); // will block waiting for result
EXPECT_GL_NO_ERROR();
glDeleteQueriesEXT(1, &query);
EXPECT_GLENUM_EQ(GL_TRUE, result);
}
TEST_P(OcclusionQueriesTest, Errors)
{
glDepthMask(GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
GLuint query = 0;
GLuint query2 = 0;
glGenQueriesEXT(1, &query);
EXPECT_EQ(glIsQueryEXT(query), GL_FALSE);
EXPECT_EQ(glIsQueryEXT(query2), GL_FALSE);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, 0); // can't pass 0 as query id
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, query);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, query2); // can't initiate a query while one's already active
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
EXPECT_EQ(glIsQueryEXT(query), GL_TRUE);
EXPECT_EQ(glIsQueryEXT(query2), GL_FALSE); // have not called begin
drawQuad(mProgram, "position", 0.8f); // this quad should not be occluded
glEndQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT); // no active query for this target
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
glEndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, query); // can't begin a query as a different type than previously used
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, query2); // have to call genqueries first
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
glGenQueriesEXT(1, &query2);
glBeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, query2); // should be ok now
EXPECT_EQ(glIsQueryEXT(query2), GL_TRUE);
drawQuad(mProgram, "position", 0.3f); // this should draw in front of other quad
glDeleteQueriesEXT(1, &query2); // should delete when query becomes inactive
glEndQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT); // should not incur error; should delete query + 1 at end of execution.
EXPECT_GL_NO_ERROR();
swapBuffers();
EXPECT_GL_NO_ERROR();
GLuint ready = GL_FALSE;
glGetQueryObjectuivEXT(query2, GL_QUERY_RESULT_AVAILABLE_EXT, &ready); // this query is now deleted
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
EXPECT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(OcclusionQueriesTest, ES2_D3D9(), ES2_D3D11());