| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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); |
| 64 // Sanity check - the resulting delta is shorter than the time it took to | 64 // Sanity check - the resulting delta is shorter than the time it took to |
| 65 // run this test. | 65 // run this test. |
| 66 EXPECT_LT(result, base::TimeDelta(after - before).InMicroseconds()); | 66 EXPECT_LE(result, base::TimeDelta(after - before).InMicroseconds()); |
| 67 | 67 |
| 68 result = 0; | 68 result = 0; |
| 69 available = 0; | 69 available = 0; |
| 70 glGetQueryObjectuivEXT(error_query, | 70 glGetQueryObjectuivEXT(error_query, |
| 71 GL_QUERY_RESULT_AVAILABLE_EXT, | 71 GL_QUERY_RESULT_AVAILABLE_EXT, |
| 72 &available); | 72 &available); |
| 73 EXPECT_TRUE(available); | 73 EXPECT_TRUE(available); |
| 74 glGetQueryObjectuivEXT(error_query, GL_QUERY_RESULT_EXT, &result); | 74 glGetQueryObjectuivEXT(error_query, GL_QUERY_RESULT_EXT, &result); |
| 75 EXPECT_EQ(static_cast<uint32>(GL_INVALID_ENUM), result); | 75 EXPECT_EQ(static_cast<uint32>(GL_INVALID_ENUM), result); |
| 76 } | 76 } |
| (...skipping 68 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(); |
| 156 |
| 155 GLuint query; | 157 GLuint query; |
| 156 glGenQueriesEXT(1, &query); | 158 glGenQueriesEXT(1, &query); |
| 157 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); | 159 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); |
| 158 glClearColor(0.0, 0.0, 1.0, 1.0); | 160 glClearColor(0.0, 0.0, 1.0, 1.0); |
| 159 glClear(GL_COLOR_BUFFER_BIT); | 161 glClear(GL_COLOR_BUFFER_BIT); |
| 160 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 162 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 161 glFlush(); | 163 glFlush(); |
| 162 GLuint result = 0; | 164 GLuint result = 0; |
| 163 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &result); | 165 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &result); |
| 164 EXPECT_EQ(0u, result); | 166 |
| 167 base::TimeTicks after = base::TimeTicks::HighResNow(); |
| 168 // Sanity check - the resulting delta is shorter than the time it took to |
| 169 // run this test. |
| 170 EXPECT_LE(result, base::TimeDelta(after - before).InMicroseconds()); |
| 171 |
| 165 glDeleteQueriesEXT(1, &query); | 172 glDeleteQueriesEXT(1, &query); |
| 166 GLTestHelper::CheckGLError("no errors", __LINE__); | 173 GLTestHelper::CheckGLError("no errors", __LINE__); |
| 167 } | 174 } |
| 168 | 175 |
| 169 TEST_F(QueryTest, CommandsCompletedWithFinish) { | 176 TEST_F(QueryTest, CommandsCompletedWithFinish) { |
| 170 if (!GLTestHelper::HasExtension("GL_CHROMIUM_sync_query")) { | 177 if (!GLTestHelper::HasExtension("GL_CHROMIUM_sync_query")) { |
| 171 LOG(INFO) << "GL_CHROMIUM_sync_query not supported. Skipping test..."; | 178 LOG(INFO) << "GL_CHROMIUM_sync_query not supported. Skipping test..."; |
| 172 return; | 179 return; |
| 173 } | 180 } |
| 174 | 181 |
| 175 GLuint query; | 182 GLuint query; |
| 176 glGenQueriesEXT(1, &query); | 183 glGenQueriesEXT(1, &query); |
| 177 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); | 184 glBeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, query); |
| 178 glClearColor(0.0, 0.0, 1.0, 1.0); | 185 glClearColor(0.0, 0.0, 1.0, 1.0); |
| 179 glClear(GL_COLOR_BUFFER_BIT); | 186 glClear(GL_COLOR_BUFFER_BIT); |
| 180 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); | 187 glEndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); |
| 181 glFinish(); | 188 glFinish(); |
| 182 GLuint result = 0; | 189 GLuint result = 0; |
| 183 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &result); | 190 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &result); |
| 184 EXPECT_EQ(1u, result); | 191 EXPECT_EQ(1u, result); |
| 185 glDeleteQueriesEXT(1, &query); | 192 glDeleteQueriesEXT(1, &query); |
| 186 GLTestHelper::CheckGLError("no errors", __LINE__); | 193 GLTestHelper::CheckGLError("no errors", __LINE__); |
| 187 } | 194 } |
| 188 | 195 |
| 189 } // namespace gpu | 196 } // namespace gpu |
| 190 | 197 |
| 191 | 198 |
| OLD | NEW |