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
testTearDown()28 void testTearDown() override
29 {
30 if (mQuery != 0)
31 {
32 glDeleteQueriesEXT(1, &mQuery);
33 mQuery = 0;
34 }
35 }
36
37 GLuint mQuery = 0;
38 };
39
40 // Test basic usage of sync queries
TEST_P(SyncQueriesTest,Basic)41 TEST_P(SyncQueriesTest, Basic)
42 {
43 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_CHROMIUM_sync_query"));
44
45 glGenQueriesEXT(1, &mQuery);
46 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, mQuery);
47 EXPECT_GL_NO_ERROR();
48
49 glClearColor(0.0, 0.0, 1.0, 1.0);
50 glClear(GL_COLOR_BUFFER_BIT);
51
52 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
53
54 glFlush();
55 GLuint result = 0;
56 glGetQueryObjectuivEXT(mQuery, GL_QUERY_RESULT_EXT, &result);
57 EXPECT_GL_TRUE(result);
58 EXPECT_GL_NO_ERROR();
59 }
60
61 // Test that the sync query enums are not accepted unless the extension is available
TEST_P(SyncQueriesTest,Validation)62 TEST_P(SyncQueriesTest, Validation)
63 {
64 // Need the GL_EXT_occlusion_query_boolean extension for the entry points
65 ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_occlusion_query_boolean"));
66
67 bool extensionAvailable = IsGLExtensionEnabled("GL_CHROMIUM_sync_query");
68
69 glGenQueriesEXT(1, &mQuery);
70
71 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, mQuery);
72 if (extensionAvailable)
73 {
74 EXPECT_GL_NO_ERROR();
75 }
76 else
77 {
78 EXPECT_GL_ERROR(GL_INVALID_ENUM);
79 }
80
81 glDeleteQueriesEXT(1, &mQuery);
82
83 EXPECT_GL_NO_ERROR();
84 }
85
86 // Use this to select which configurations (e.g. which renderer, which GLES major version) these
87 // tests should be run against.
88 ANGLE_INSTANTIATE_TEST_ES2_AND_ES3(SyncQueriesTest);
89
90 } // namespace angle
91