OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/containers/small_map.h" | 8 #include "base/containers/small_map.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "gpu/perftests/measurements.h" | 13 #include "gpu/perftests/measurements.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "testing/perf/perf_test.h" | 16 #include "testing/perf/perf_test.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 #include "ui/gfx/geometry/vector2d_f.h" | 18 #include "ui/gfx/geometry/vector2d_f.h" |
19 #include "ui/gl/gl_bindings.h" | 19 #include "ui/gl/gl_bindings.h" |
20 #include "ui/gl/gl_context.h" | 20 #include "ui/gl/gl_context.h" |
21 #include "ui/gl/gl_enums.h" | 21 #include "ui/gl/gl_enums.h" |
22 #include "ui/gl/gl_surface.h" | 22 #include "ui/gl/gl_surface.h" |
23 #include "ui/gl/gl_version_info.h" | 23 #include "ui/gl/gl_version_info.h" |
24 #include "ui/gl/gpu_timing.h" | 24 #include "ui/gl/gpu_timing.h" |
25 #include "ui/gl/scoped_make_current.h" | 25 #include "ui/gl/scoped_make_current.h" |
26 | 26 |
27 #if defined(USE_OZONE) | |
28 #include "base/message_loop/message_loop.h" | |
29 #endif | |
30 | |
27 namespace gpu { | 31 namespace gpu { |
28 namespace { | 32 namespace { |
29 | 33 |
30 const int kUploadPerfWarmupRuns = 5; | 34 const int kUploadPerfWarmupRuns = 5; |
31 const int kUploadPerfTestRuns = 30; | 35 const int kUploadPerfTestRuns = 30; |
32 | 36 |
33 #define SHADER(Src) #Src | 37 #define SHADER(Src) #Src |
34 | 38 |
35 // clang-format off | 39 // clang-format off |
36 const char kVertexShader[] = | 40 const char kVertexShader[] = |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 } | 168 } |
165 | 169 |
166 // PerfTest to check costs of texture upload at different stages | 170 // PerfTest to check costs of texture upload at different stages |
167 // on different platforms. | 171 // on different platforms. |
168 class TextureUploadPerfTest : public testing::Test { | 172 class TextureUploadPerfTest : public testing::Test { |
169 public: | 173 public: |
170 TextureUploadPerfTest() : fbo_size_(1024, 1024) {} | 174 TextureUploadPerfTest() : fbo_size_(1024, 1024) {} |
171 | 175 |
172 // Overridden from testing::Test | 176 // Overridden from testing::Test |
173 void SetUp() override { | 177 void SetUp() override { |
178 #if defined(USE_OZONE) | |
179 // On Ozone, the backend initializes the event system using a UI | |
180 // thread. | |
181 base::MessageLoopForUI main_loop; | |
Daniele Castagna
2015/04/14 15:38:38
Where in the backend is this message loop used? It
vignatti (out of this project)
2015/04/14 16:39:16
A few Ozone implementations like the GBM requires
| |
182 #endif | |
174 static bool gl_initialized = gfx::GLSurface::InitializeOneOff(); | 183 static bool gl_initialized = gfx::GLSurface::InitializeOneOff(); |
175 DCHECK(gl_initialized); | 184 DCHECK(gl_initialized); |
176 // Initialize an offscreen surface and a gl context. | 185 // Initialize an offscreen surface and a gl context. |
177 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(4, 4)); | 186 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size()); |
178 gl_context_ = gfx::GLContext::CreateGLContext(NULL, // share_group | 187 gl_context_ = gfx::GLContext::CreateGLContext(NULL, // share_group |
179 surface_.get(), | 188 surface_.get(), |
180 gfx::PreferIntegratedGpu); | 189 gfx::PreferIntegratedGpu); |
181 ui::ScopedMakeCurrent smc(gl_context_.get(), surface_.get()); | 190 ui::ScopedMakeCurrent smc(gl_context_.get(), surface_.get()); |
182 glGenTextures(1, &color_texture_); | 191 glGenTextures(1, &color_texture_); |
183 glBindTexture(GL_TEXTURE_2D, color_texture_); | 192 glBindTexture(GL_TEXTURE_2D, color_texture_); |
184 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 193 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
185 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 194 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
186 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | 195 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
187 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | 196 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 gpu_timing_client_->CheckAndResetTimerErrors(); | 548 gpu_timing_client_->CheckAndResetTimerErrors(); |
540 if (!gpu_timer_errors) { | 549 if (!gpu_timer_errors) { |
541 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") | 550 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") |
542 .PrintResult("renaming"); | 551 .PrintResult("renaming"); |
543 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); | 552 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); |
544 } | 553 } |
545 } | 554 } |
546 | 555 |
547 } // namespace | 556 } // namespace |
548 } // namespace gpu | 557 } // namespace gpu |
OLD | NEW |