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

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

Issue 1066863002: TextureUploadPerfTest.renaming should output renaming status Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | no next file » | 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 <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"
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 GenerateVertexBuffer(texture_size); 497 GenerateVertexBuffer(texture_size);
498 498
499 gfx::Vector2dF positions[] = {gfx::Vector2dF(0.f, 0.f), 499 gfx::Vector2dF positions[] = {gfx::Vector2dF(0.f, 0.f),
500 gfx::Vector2dF(1.f, 0.f), 500 gfx::Vector2dF(1.f, 0.f),
501 gfx::Vector2dF(0.f, 1.f), 501 gfx::Vector2dF(0.f, 1.f),
502 gfx::Vector2dF(1.f, 1.f)}; 502 gfx::Vector2dF(1.f, 1.f)};
503 GLuint texture_id = CreateGLTexture(GL_RGBA, texture_size, true); 503 GLuint texture_id = CreateGLTexture(GL_RGBA, texture_size, true);
504 504
505 MeasurementTimers upload_and_draw_timers(gpu_timing_client_.get()); 505 MeasurementTimers upload_and_draw_timers(gpu_timing_client_.get());
506 506
507 GLint current_tex_id = -1;
508 bool is_renaming = false;
507 for (int i = 0; i < 4; ++i) { 509 for (int i = 0; i < 4; ++i) {
508 UploadTexture(texture_id, texture_size, pixels[i % 4], GL_RGBA, true); 510 UploadTexture(texture_id, texture_size, pixels[i % 4], GL_RGBA, true);
511 if (!is_renaming && current_tex_id != -1 &&
512 static_cast<GLuint>(current_tex_id) != texture_id)
513 is_renaming = true;
509 DCHECK_NE(-1, translation_location_); 514 DCHECK_NE(-1, translation_location_);
510 glUniform2f(translation_location_, positions[i % 4].x(), 515 glUniform2f(translation_location_, positions[i % 4].x(),
511 positions[i % 4].y()); 516 positions[i % 4].y());
512 // Draw the same quad multiple times to make sure that the time spent on the 517 // Draw the same quad multiple times to make sure that the time spent on the
513 // gpu is more than the cpu time. 518 // gpu is more than the cpu time.
514 for (int draw = 0; draw < 128; ++draw) { 519 for (int draw = 0; draw < 128; ++draw) {
520 glGetIntegerv(GL_TEXTURE_BINDING_2D, &current_tex_id);
Daniele Castagna 2015/04/07 16:27:08 This returns the name of the texture currently bou
patro 2015/04/08 15:19:49 You are right this patch doesn't work as intended.
Daniele Castagna 2015/04/14 16:13:15 I was thinking about this perftest to print out ra
sivag 2015/04/27 12:39:02 Daniele, Can you elaborate more on this? How this
515 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 521 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
516 } 522 }
517 } 523 }
518 524
519 upload_and_draw_timers.Record(); 525 upload_and_draw_timers.Record();
520 MeasurementTimers finish_timers(gpu_timing_client_.get()); 526 MeasurementTimers finish_timers(gpu_timing_client_.get());
521 glFinish(); 527 glFinish();
522 CheckNoGlError("glFinish"); 528 CheckNoGlError("glFinish");
523 finish_timers.Record(); 529 finish_timers.Record();
524 530
525 glDeleteTextures(1, &texture_id); 531 glDeleteTextures(1, &texture_id);
526 532
527 for (int i = 0; i < 4; ++i) { 533 for (int i = 0; i < 4; ++i) {
528 std::vector<uint8> pixels_rendered(texture_size.GetArea() * 4); 534 std::vector<uint8> pixels_rendered(texture_size.GetArea() * 4);
529 glReadPixels(texture_size.width() * positions[i].x(), 535 glReadPixels(texture_size.width() * positions[i].x(),
530 texture_size.height() * positions[i].y(), texture_size.width(), 536 texture_size.height() * positions[i].y(), texture_size.width(),
531 texture_size.height(), GL_RGBA, GL_UNSIGNED_BYTE, 537 texture_size.height(), GL_RGBA, GL_UNSIGNED_BYTE,
532 &pixels_rendered[0]); 538 &pixels_rendered[0]);
533 CheckNoGlError("glReadPixels"); 539 CheckNoGlError("glReadPixels");
534 ASSERT_EQ(pixels[i].size(), pixels_rendered.size()); 540 ASSERT_EQ(pixels[i].size(), pixels_rendered.size());
535 EXPECT_EQ(pixels[i], pixels_rendered); 541 EXPECT_EQ(pixels[i], pixels_rendered);
536 } 542 }
537 543
538 bool gpu_timer_errors = gpu_timing_client_->IsAvailable() && 544 bool gpu_timer_errors = gpu_timing_client_->IsAvailable() &&
539 gpu_timing_client_->CheckAndResetTimerErrors(); 545 gpu_timing_client_->CheckAndResetTimerErrors();
540 if (!gpu_timer_errors) { 546 if (!gpu_timer_errors) {
541 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") 547 upload_and_draw_timers.GetAsMeasurement("upload_and_draw")
542 .PrintResult("renaming"); 548 .PrintResult("renaming");
543 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); 549 finish_timers.GetAsMeasurement("finish").PrintResult("renaming");
550 if (is_renaming)
551 perf_test::PrintResult("renaming", "",
552 "Driver renames texture internally", "True", "",
553 true);
554 else
555 perf_test::PrintResult("renaming", "",
556 "Driver renames texture internally", "False", "",
557 true);
544 } 558 }
545 } 559 }
546 560
547 } // namespace 561 } // namespace
548 } // namespace gpu 562 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698