Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| 11 #include "gpu/command_buffer/tests/gl_test_utils.h" | 11 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace gpu { | 15 namespace gpu { |
| 16 | 16 |
| 17 class QueryTest : public testing::Test { | 17 class QueryTest : public testing::Test { |
| 18 protected: | 18 protected: |
| 19 virtual void SetUp() { | 19 virtual void SetUp() { |
| 20 gl_.Initialize(GLManager::Options()); | 20 gl_.Initialize(GLManager::Options()); |
| 21 } | 21 } |
| 22 | 22 |
| 23 virtual void TearDown() { | 23 virtual void TearDown() { |
| 24 gl_.Destroy(); | 24 gl_.Destroy(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 GLManager gl_; | 27 GLManager gl_; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 TEST_F(QueryTest, MultipleQueries) { | |
| 31 EXPECT_TRUE(GLTestHelper::HasExtension("GL_CHROMIUM_get_error_query")); | |
| 32 EXPECT_TRUE(GLTestHelper::HasExtension( | |
| 33 "GL_CHROMIUM_command_buffer_latency_query")); | |
| 34 | |
| 35 GLuint error_query = 0; | |
| 36 GLuint latency_query = 0; | |
| 37 glGenQueriesEXT(1, &error_query); | |
| 38 glGenQueriesEXT(1, &latency_query); | |
| 39 | |
| 40 GLuint query_status; | |
| 41 GLuint available; | |
| 42 | |
| 43 // Begin two queries of different types | |
| 44 glBeginQueryEXT(GL_LATENCY_QUERY_CHROMIUM, latency_query); | |
| 45 glBeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, error_query); | |
| 46 | |
| 47 glEnable(GL_TEXTURE_2D); // Generates an INVALID_ENUM error | |
| 48 | |
| 49 // End the two queries | |
| 50 glEndQueryEXT(GL_LATENCY_QUERY_CHROMIUM); | |
| 51 glEndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); | |
| 52 | |
| 53 glFinish(); | |
| 54 | |
| 55 // Check that we got result on both queries. | |
| 56 | |
| 57 available = 0; | |
| 58 glGetQueryObjectuivEXT(latency_query, | |
| 59 GL_QUERY_RESULT_AVAILABLE_EXT, | |
| 60 &available); | |
| 61 EXPECT_TRUE(available); | |
| 62 // TODO(jadahl): Check latency result whenever latency test is enabled | |
|
reveman
2014/01/02 15:38:12
Would it be better to use a GL_COMMANDS_ISSUED_CHR
| |
| 63 | |
| 64 query_status = 0; | |
| 65 available = 0; | |
| 66 glGetQueryObjectuivEXT(error_query, | |
| 67 GL_QUERY_RESULT_AVAILABLE_EXT, | |
| 68 &available); | |
| 69 EXPECT_TRUE(available); | |
| 70 glGetQueryObjectuivEXT(error_query, GL_QUERY_RESULT_EXT, &query_status); | |
| 71 EXPECT_EQ(static_cast<uint32>(GL_INVALID_ENUM), query_status); | |
| 72 } | |
| 73 | |
| 30 TEST_F(QueryTest, GetErrorBasic) { | 74 TEST_F(QueryTest, GetErrorBasic) { |
| 31 EXPECT_TRUE(GLTestHelper::HasExtension("GL_CHROMIUM_get_error_query")); | 75 EXPECT_TRUE(GLTestHelper::HasExtension("GL_CHROMIUM_get_error_query")); |
| 32 | 76 |
| 33 GLuint query = 0; | 77 GLuint query = 0; |
| 34 glGenQueriesEXT(1, &query); | 78 glGenQueriesEXT(1, &query); |
| 35 | 79 |
| 36 GLuint query_status = 0; | 80 GLuint query_status = 0; |
| 37 GLuint result = 0; | 81 GLuint result = 0; |
| 38 | 82 |
| 39 glBeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, query); | 83 glBeginQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM, query); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | 138 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
| 95 EXPECT_TRUE(available); | 139 EXPECT_TRUE(available); |
| 96 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &query_result); | 140 glGetQueryObjectuivEXT(query, GL_QUERY_RESULT_EXT, &query_result); |
| 97 | 141 |
| 98 EXPECT_LE(query_result, kTimePrecisionMicroseconds); | 142 EXPECT_LE(query_result, kTimePrecisionMicroseconds); |
| 99 } | 143 } |
| 100 | 144 |
| 101 } // namespace gpu | 145 } // namespace gpu |
| 102 | 146 |
| 103 | 147 |
| OLD | NEW |