Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Side by Side Diff: gpu/perftests/texture_upload_perftest.cc

Issue 1998723002: Move code in ui/gl/* from gfx:: to gl:: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/perftests/measurements.cc ('k') | mash/test/mash_test_suite.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // On Ozone, the backend initializes the event system using a UI 183 // On Ozone, the backend initializes the event system using a UI
184 // thread. 184 // thread.
185 base::MessageLoopForUI main_loop; 185 base::MessageLoopForUI main_loop;
186 #endif 186 #endif
187 static bool gl_initialized = gl::init::InitializeGLOneOff(); 187 static bool gl_initialized = gl::init::InitializeGLOneOff();
188 DCHECK(gl_initialized); 188 DCHECK(gl_initialized);
189 // Initialize an offscreen surface and a gl context. 189 // Initialize an offscreen surface and a gl context.
190 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size()); 190 surface_ = gl::init::CreateOffscreenGLSurface(gfx::Size());
191 gl_context_ = 191 gl_context_ =
192 gl::init::CreateGLContext(nullptr, // share_group 192 gl::init::CreateGLContext(nullptr, // share_group
193 surface_.get(), gfx::PreferIntegratedGpu); 193 surface_.get(), gl::PreferIntegratedGpu);
194 ui::ScopedMakeCurrent smc(gl_context_.get(), surface_.get()); 194 ui::ScopedMakeCurrent smc(gl_context_.get(), surface_.get());
195 glGenTextures(1, &color_texture_); 195 glGenTextures(1, &color_texture_);
196 glBindTexture(GL_TEXTURE_2D, color_texture_); 196 glBindTexture(GL_TEXTURE_2D, color_texture_);
197 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 197 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
198 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 198 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
199 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 199 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
201 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fbo_size_.width(), 201 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, fbo_size_.width(),
202 fbo_size_.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); 202 fbo_size_.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
203 203
(...skipping 11 matching lines...) Expand all
215 if (gpu_timing_client_->IsAvailable()) { 215 if (gpu_timing_client_->IsAvailable()) {
216 LOG(INFO) << "Gpu timing initialized with timer type: " 216 LOG(INFO) << "Gpu timing initialized with timer type: "
217 << gpu_timing_client_->GetTimerTypeName(); 217 << gpu_timing_client_->GetTimerTypeName();
218 } else { 218 } else {
219 LOG(WARNING) << "Can't initialize gpu timing"; 219 LOG(WARNING) << "Can't initialize gpu timing";
220 } 220 }
221 // Prepare a simple program and a vertex buffer that will be 221 // Prepare a simple program and a vertex buffer that will be
222 // used to draw a quad on the offscreen surface. 222 // used to draw a quad on the offscreen surface.
223 vertex_shader_ = LoadShader(GL_VERTEX_SHADER, kVertexShader); 223 vertex_shader_ = LoadShader(GL_VERTEX_SHADER, kVertexShader);
224 224
225 bool is_gles = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2; 225 bool is_gles = gl::GetGLImplementation() == gl::kGLImplementationEGLGLES2;
226 fragment_shader_ = LoadShader( 226 fragment_shader_ = LoadShader(
227 GL_FRAGMENT_SHADER, 227 GL_FRAGMENT_SHADER,
228 base::StringPrintf("%s%s", is_gles ? kShaderDefaultFloatPrecision : "", 228 base::StringPrintf("%s%s", is_gles ? kShaderDefaultFloatPrecision : "",
229 kFragmentShader).c_str()); 229 kFragmentShader).c_str());
230 program_object_ = glCreateProgram(); 230 program_object_ = glCreateProgram();
231 CHECK_NE(0u, program_object_); 231 CHECK_NE(0u, program_object_);
232 232
233 glAttachShader(program_object_, vertex_shader_); 233 glAttachShader(program_object_, vertex_shader_);
234 glAttachShader(program_object_, fragment_shader_); 234 glAttachShader(program_object_, fragment_shader_);
235 glBindAttribLocation(program_object_, 0, "a_position"); 235 glBindAttribLocation(program_object_, 0, "a_position");
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 glFinish(); 373 glFinish();
374 CheckNoGlError("glFinish"); 374 CheckNoGlError("glFinish");
375 finish_timers.Record(); 375 finish_timers.Record();
376 376
377 std::vector<uint8_t> pixels_rendered(size.GetArea() * 4); 377 std::vector<uint8_t> pixels_rendered(size.GetArea() * 4);
378 glReadPixels(0, 0, size.width(), size.height(), GL_RGBA, GL_UNSIGNED_BYTE, 378 glReadPixels(0, 0, size.width(), size.height(), GL_RGBA, GL_UNSIGNED_BYTE,
379 &pixels_rendered[0]); 379 &pixels_rendered[0]);
380 CheckNoGlError("glReadPixels"); 380 CheckNoGlError("glReadPixels");
381 EXPECT_TRUE( 381 EXPECT_TRUE(
382 CompareBufferToRGBABuffer(format, size, pixels, pixels_rendered)) 382 CompareBufferToRGBABuffer(format, size, pixels, pixels_rendered))
383 << "Format is: " << gfx::GLEnums::GetStringEnum(format); 383 << "Format is: " << gl::GLEnums::GetStringEnum(format);
384 384
385 std::vector<Measurement> measurements; 385 std::vector<Measurement> measurements;
386 bool gpu_timer_errors = 386 bool gpu_timer_errors =
387 gpu_timing_client_->IsAvailable() && 387 gpu_timing_client_->IsAvailable() &&
388 gpu_timing_client_->CheckAndResetTimerErrors(); 388 gpu_timing_client_->CheckAndResetTimerErrors();
389 if (!gpu_timer_errors) { 389 if (!gpu_timer_errors) {
390 measurements.push_back(tex_timers.GetAsMeasurement( 390 measurements.push_back(tex_timers.GetAsMeasurement(
391 subimage ? "texsubimage2d" : "teximage2d")); 391 subimage ? "texsubimage2d" : "teximage2d"));
392 measurements.push_back( 392 measurements.push_back(
393 first_draw_timers.GetAsMeasurement("firstdrawarrays")); 393 first_draw_timers.GetAsMeasurement("firstdrawarrays"));
(...skipping 20 matching lines...) Expand all
414 successful_runs++; 414 successful_runs++;
415 for (const Measurement& measurement : run) { 415 for (const Measurement& measurement : run) {
416 auto& aggregate = aggregates[measurement.name]; 416 auto& aggregate = aggregates[measurement.name];
417 aggregate.name = measurement.name; 417 aggregate.name = measurement.name;
418 aggregate.Increment(measurement); 418 aggregate.Increment(measurement);
419 } 419 }
420 } 420 }
421 glDeleteTextures(1, &texture_id); 421 glDeleteTextures(1, &texture_id);
422 422
423 std::string graph_name = base::StringPrintf( 423 std::string graph_name = base::StringPrintf(
424 "%d_%s", size.width(), gfx::GLEnums::GetStringEnum(format).c_str()); 424 "%d_%s", size.width(), gl::GLEnums::GetStringEnum(format).c_str());
425 if (subimage) { 425 if (subimage) {
426 graph_name += "_sub"; 426 graph_name += "_sub";
427 } 427 }
428 428
429 if (successful_runs) { 429 if (successful_runs) {
430 for (const auto& entry : aggregates) { 430 for (const auto& entry : aggregates) {
431 const auto m = entry.second.Divide(successful_runs); 431 const auto m = entry.second.Divide(successful_runs);
432 m.PrintResult(graph_name); 432 m.PrintResult(graph_name);
433 } 433 }
434 } 434 }
435 perf_test::PrintResult("sample_runs", "", graph_name, 435 perf_test::PrintResult("sample_runs", "", graph_name,
436 static_cast<size_t>(successful_runs), "laps", true); 436 static_cast<size_t>(successful_runs), "laps", true);
437 } 437 }
438 438
439 const gfx::Size fbo_size_; // for the fbo 439 const gfx::Size fbo_size_; // for the fbo
440 scoped_refptr<gfx::GLContext> gl_context_; 440 scoped_refptr<gl::GLContext> gl_context_;
441 scoped_refptr<gfx::GLSurface> surface_; 441 scoped_refptr<gl::GLSurface> surface_;
442 scoped_refptr<gfx::GPUTimingClient> gpu_timing_client_; 442 scoped_refptr<gl::GPUTimingClient> gpu_timing_client_;
443 443
444 GLuint color_texture_ = 0; 444 GLuint color_texture_ = 0;
445 GLuint framebuffer_object_ = 0; 445 GLuint framebuffer_object_ = 0;
446 GLuint vertex_shader_ = 0; 446 GLuint vertex_shader_ = 0;
447 GLuint fragment_shader_ = 0; 447 GLuint fragment_shader_ = 0;
448 GLuint program_object_ = 0; 448 GLuint program_object_ = 0;
449 GLint sampler_location_ = -1; 449 GLint sampler_location_ = -1;
450 GLint translation_location_ = -1; 450 GLint translation_location_ = -1;
451 GLuint vertex_buffer_ = 0; 451 GLuint vertex_buffer_ = 0;
452 452
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 gpu_timing_client_->CheckAndResetTimerErrors(); 551 gpu_timing_client_->CheckAndResetTimerErrors();
552 if (!gpu_timer_errors) { 552 if (!gpu_timer_errors) {
553 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") 553 upload_and_draw_timers.GetAsMeasurement("upload_and_draw")
554 .PrintResult("renaming"); 554 .PrintResult("renaming");
555 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); 555 finish_timers.GetAsMeasurement("finish").PrintResult("renaming");
556 } 556 }
557 } 557 }
558 558
559 } // namespace 559 } // namespace
560 } // namespace gpu 560 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/perftests/measurements.cc ('k') | mash/test/mash_test_suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698