Hash :
0d3683c4
Author :
Date :
2014-10-23T11:08:16
Update ANGLE_platform_angle to allow requesting of Renderer versions. Added enums to allow users to request major and minor versions of the underlying API and if a WARP device is used. BUG=angle:490 Change-Id: I0bfb2ac8d327da28a47cc8e6346300e47ab9538c Reviewed-on: https://chromium-review.googlesource.com/225081 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Geoff Lang <geofflang@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
#include "ANGLETest.h"
// Needed for Sleep()
#include <Windows.h>
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_TYPED_TEST_CASE(OcclusionQueriesTest, ES2_D3D9, ES2_D3D11);
template<typename T>
class OcclusionQueriesTest : public ANGLETest
{
protected:
OcclusionQueriesTest() : ANGLETest(T::GetGlesMajorVersion(), T::GetPlatform())
{
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;
};
TYPED_TEST(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)
{
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_EQ(result, GL_FALSE);
}
TYPED_TEST(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_EQ(result, GL_TRUE);
}
TYPED_TEST(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_EQ(glGetError(), 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();
}