| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
| 6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
| 7 #include <GLES2/gl2extchromium.h> | 7 #include <GLES2/gl2extchromium.h> |
| 8 | 8 |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "gpu/command_buffer/tests/gl_manager.h" | 10 #include "gpu/command_buffer/tests/gl_manager.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 "GL_CHROMIUM_command_buffer_latency_query")); | 29 "GL_CHROMIUM_command_buffer_latency_query")); |
| 30 | 30 |
| 31 GLuint error_query = 0; | 31 GLuint error_query = 0; |
| 32 GLuint commands_issue_query = 0; | 32 GLuint commands_issue_query = 0; |
| 33 glGenQueriesEXT(1, &error_query); | 33 glGenQueriesEXT(1, &error_query); |
| 34 glGenQueriesEXT(1, &commands_issue_query); | 34 glGenQueriesEXT(1, &commands_issue_query); |
| 35 | 35 |
| 36 GLuint available; | 36 GLuint available; |
| 37 GLuint result; | 37 GLuint result; |
| 38 | 38 |
| 39 base::TimeTicks before = base::TimeTicks::HighResNow(); | 39 base::TimeTicks before = base::TimeTicks::Now(); |
| 40 | 40 |
| 41 // Begin two queries of different types | 41 // Begin two queries of different types |
| 42 glBeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, commands_issue_query); | 42 glBeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, commands_issue_query); |
| 43 glBeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, error_query); | 43 glBeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, error_query); |
| 44 | 44 |
| 45 glEnable(GL_TEXTURE_2D); // Generates an INVALID_ENUM error | 45 glEnable(GL_TEXTURE_2D); // Generates an INVALID_ENUM error |
| 46 | 46 |
| 47 // End the two queries | 47 // End the two queries |
| 48 glEndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | 48 glEndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
| 49 glEndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); | 49 glEndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); |
| 50 | 50 |
| 51 glFinish(); | 51 glFinish(); |
| 52 | 52 |
| 53 base::TimeTicks after = base::TimeTicks::HighResNow(); | 53 base::TimeTicks after = base::TimeTicks::Now(); |
| 54 | 54 |
| 55 // Check that we got result on both queries. | 55 // Check that we got result on both queries. |
| 56 | 56 |
| 57 available = 0; | 57 available = 0; |
| 58 result = 0; | 58 result = 0; |
| 59 glGetQueryObjectuivEXT(commands_issue_query, | 59 glGetQueryObjectuivEXT(commands_issue_query, |
| 60 GL_QUERY_RESULT_AVAILABLE_EXT, | 60 GL_QUERY_RESULT_AVAILABLE_EXT, |
| 61 &available); | 61 &available); |
| 62 EXPECT_TRUE(available); | 62 EXPECT_TRUE(available); |
| 63 glGetQueryObjectuivEXT(commands_issue_query, GL_QUERY_RESULT_EXT, &result); | 63 glGetQueryObjectuivEXT(commands_issue_query, GL_QUERY_RESULT_EXT, &result); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 EXPECT_LE(query_result, kTimePrecisionMicroseconds); | 146 EXPECT_LE(query_result, kTimePrecisionMicroseconds); |
| 147 } | 147 } |
| 148 | 148 |
| 149 TEST_F(QueryTest, CommandsCompleted) { | 149 TEST_F(QueryTest, CommandsCompleted) { |
| 150 if (!GLTestHelper::HasExtension("GL_CHROMIUM_sync_query")) { | 150 if (!GLTestHelper::HasExtension("GL_CHROMIUM_sync_query")) { |
| 151 LOG(INFO) << "GL_CHROMIUM_sync_query not supported. Skipping test..."; | 151 LOG(INFO) << "GL_CHROMIUM_sync_query not supported. Skipping test..."; |
| 152 return; | 152 return; |
| 153 } | 153 } |
| 154 | 154 |
| 155 base::TimeTicks before = base::TimeTicks::HighResNow(); | 155 base::TimeTicks before = base::TimeTicks::Now(); |
| 156 | 156 |
| 157 GLuint query; | 157 GLuint query; |
| 158 glGenQueriesEXT(1, &query); | 158 glGenQueriesEXT(1, &query); |
| 159 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); | 159 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); |
| 160 glClearColor(0.0, 0.0, 1.0, 1.0); | 160 glClearColor(0.0, 0.0, 1.0, 1.0); |
| 161 glClear(GL_COLOR_BUFFER_BIT); | 161 glClear(GL_COLOR_BUFFER_BIT); |
| 162 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 162 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 163 glFlush(); | 163 glFlush(); |
| 164 GLuint result = 0; | 164 GLuint result = 0; |
| 165 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &result); | 165 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &result); |
| 166 | 166 |
| 167 base::TimeTicks after = base::TimeTicks::HighResNow(); | 167 base::TimeTicks after = base::TimeTicks::Now(); |
| 168 // Sanity check - the resulting delta is shorter than the time it took to | 168 // Sanity check - the resulting delta is shorter than the time it took to |
| 169 // run this test. | 169 // run this test. |
| 170 EXPECT_LE(result, base::TimeDelta(after - before).InMicroseconds()); | 170 EXPECT_LE(result, base::TimeDelta(after - before).InMicroseconds()); |
| 171 | 171 |
| 172 glDeleteQueriesEXT(1, &query); | 172 glDeleteQueriesEXT(1, &query); |
| 173 GLTestHelper::CheckGLError("no errors", __LINE__); | 173 GLTestHelper::CheckGLError("no errors", __LINE__); |
| 174 } | 174 } |
| 175 | 175 |
| 176 TEST_F(QueryTest, CommandsCompletedWithFinish) { | 176 TEST_F(QueryTest, CommandsCompletedWithFinish) { |
| 177 if (!GLTestHelper::HasExtension("GL_CHROMIUM_sync_query")) { | 177 if (!GLTestHelper::HasExtension("GL_CHROMIUM_sync_query")) { |
| 178 LOG(INFO) << "GL_CHROMIUM_sync_query not supported. Skipping test..."; | 178 LOG(INFO) << "GL_CHROMIUM_sync_query not supported. Skipping test..."; |
| 179 return; | 179 return; |
| 180 } | 180 } |
| 181 | 181 |
| 182 GLuint query; | 182 GLuint query; |
| 183 glGenQueriesEXT(1, &query); | 183 glGenQueriesEXT(1, &query); |
| 184 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); | 184 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); |
| 185 glClearColor(0.0, 0.0, 1.0, 1.0); | 185 glClearColor(0.0, 0.0, 1.0, 1.0); |
| 186 glClear(GL_COLOR_BUFFER_BIT); | 186 glClear(GL_COLOR_BUFFER_BIT); |
| 187 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 187 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 188 glFinish(); | 188 glFinish(); |
| 189 GLuint result = 0; | 189 GLuint result = 0; |
| 190 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &result); | 190 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &result); |
| 191 EXPECT_EQ(1u, result); | 191 EXPECT_EQ(1u, result); |
| 192 glDeleteQueriesEXT(1, &query); | 192 glDeleteQueriesEXT(1, &query); |
| 193 GLTestHelper::CheckGLError("no errors", __LINE__); | 193 GLTestHelper::CheckGLError("no errors", __LINE__); |
| 194 } | 194 } |
| 195 | 195 |
| 196 } // namespace gpu | 196 } // namespace gpu |
| 197 | |
| 198 | |
| OLD | NEW |