1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // SyncQueriesTest.cpp: Tests of the GL_CHROMIUM_sync_query extension
8
9 #include "test_utils/ANGLETest.h"
10
11 namespace angle
12 {
13
14 class SyncQueriesTest : public ANGLETest
15 {
16 protected:
SyncQueriesTest()17 SyncQueriesTest()
18 {
19 setWindowWidth(128);
20 setWindowHeight(128);
21 setConfigRedBits(8);
22 setConfigGreenBits(8);
23 setConfigBlueBits(8);
24 setConfigAlphaBits(8);
25 setConfigDepthBits(24);
26 }
27
TearDown()28 void TearDown() override
29 {
30 if (mQuery != 0)
31 {
32 glDeleteQueriesEXT(1, &mQuery);
33 mQuery = 0;
34 }
35
36 ANGLETest::TearDown();
37 }
38
39 GLuint mQuery = 0;
40 };
41
42 // Test basic usage of sync queries
TEST_P(SyncQueriesTest,Basic)43 TEST_P(SyncQueriesTest, Basic)
44 {
45 if (!extensionEnabled("GL_CHROMIUM_sync_query"))
46 {
47 std::cout << "Test skipped because GL_CHROMIUM_sync_query is not available." << std::endl;
48 return;
49 }
50
51 glGenQueriesEXT(1, &mQuery);
52 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, mQuery);
53 EXPECT_GL_NO_ERROR();
54
55 glClearColor(0.0, 0.0, 1.0, 1.0);
56 glClear(GL_COLOR_BUFFER_BIT);
57
58 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
59
60 glFlush();
61 GLuint result = 0;
62 glGetQueryObjectuivEXT(mQuery, GL_QUERY_RESULT_EXT, &result);
63 EXPECT_EQ(static_cast<GLuint>(GL_TRUE), result);
64 EXPECT_GL_NO_ERROR();
65 }
66
67 // Test that the sync query enums are not accepted unless the extension is available
TEST_P(SyncQueriesTest,Validation)68 TEST_P(SyncQueriesTest, Validation)
69 {
70 // Need the GL_EXT_occlusion_query_boolean extension for the entry points
71 if (!extensionEnabled("GL_EXT_occlusion_query_boolean"))
72 {
73 std::cout << "Test skipped because GL_EXT_occlusion_query_boolean is not available."
74 << std::endl;
75 return;
76 }
77
78 bool extensionAvailable = extensionEnabled("GL_CHROMIUM_sync_query");
79
80 glGenQueriesEXT(1, &mQuery);
81
82 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, mQuery);
83 if (extensionAvailable)
84 {
85 EXPECT_GL_NO_ERROR();
86 }
87 else
88 {
89 EXPECT_GL_ERROR(GL_INVALID_ENUM);
90 }
91
92 glDeleteQueriesEXT(1, &mQuery);
93
94 EXPECT_GL_NO_ERROR();
95 }
96
97 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
98 // tests should be run against.
99 ANGLE_INSTANTIATE_TEST(SyncQueriesTest,
100 ES2_D3D9(),
101 ES2_D3D11(),
102 ES3_D3D11(),
103 ES2_OPENGL(),
104 ES3_OPENGL(),
105 ES2_OPENGLES(),
106 ES3_OPENGLES());
107
108 } // namespace angle
109