Chromium Code Reviews| 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" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 // time elapsed in milliseconds. | 342 // time elapsed in milliseconds. |
| 343 std::vector<Measurement> UploadAndDraw(GLuint texture_id, | 343 std::vector<Measurement> UploadAndDraw(GLuint texture_id, |
| 344 const gfx::Size& size, | 344 const gfx::Size& size, |
| 345 const std::vector<uint8>& pixels, | 345 const std::vector<uint8>& pixels, |
| 346 const GLenum format, | 346 const GLenum format, |
| 347 const bool subimage) { | 347 const bool subimage) { |
| 348 MeasurementTimers tex_timers(gpu_timing_client_.get()); | 348 MeasurementTimers tex_timers(gpu_timing_client_.get()); |
| 349 UploadTexture(texture_id, size, pixels, format, subimage); | 349 UploadTexture(texture_id, size, pixels, format, subimage); |
| 350 tex_timers.Record(); | 350 tex_timers.Record(); |
| 351 | 351 |
| 352 MeasurementTimers first_draw_timers(gpu_timing_client_.get()); | |
| 353 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | |
| 354 first_draw_timers.Record(); | |
| 355 | |
| 352 MeasurementTimers draw_timers(gpu_timing_client_.get()); | 356 MeasurementTimers draw_timers(gpu_timing_client_.get()); |
| 353 | |
| 354 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); | 357 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); |
| 355 draw_timers.Record(); | 358 draw_timers.Record(); |
| 356 | 359 |
| 357 MeasurementTimers finish_timers(gpu_timing_client_.get()); | 360 MeasurementTimers finish_timers(gpu_timing_client_.get()); |
| 358 glFinish(); | 361 glFinish(); |
| 359 CheckNoGlError("glFinish"); | 362 CheckNoGlError("glFinish"); |
| 360 finish_timers.Record(); | 363 finish_timers.Record(); |
| 361 | 364 |
| 362 std::vector<uint8> pixels_rendered(size.GetArea() * 4); | 365 std::vector<uint8> pixels_rendered(size.GetArea() * 4); |
| 363 glReadPixels(0, 0, size.width(), size.height(), GL_RGBA, GL_UNSIGNED_BYTE, | 366 glReadPixels(0, 0, size.width(), size.height(), GL_RGBA, GL_UNSIGNED_BYTE, |
| 364 &pixels_rendered[0]); | 367 &pixels_rendered[0]); |
| 365 CheckNoGlError("glReadPixels"); | 368 CheckNoGlError("glReadPixels"); |
| 366 EXPECT_TRUE( | 369 EXPECT_TRUE( |
| 367 CompareBufferToRGBABuffer(format, size, pixels, pixels_rendered)) | 370 CompareBufferToRGBABuffer(format, size, pixels, pixels_rendered)) |
| 368 << "Format is: " << gfx::GLEnums::GetStringEnum(format); | 371 << "Format is: " << gfx::GLEnums::GetStringEnum(format); |
| 369 | 372 |
| 370 std::vector<Measurement> measurements; | 373 std::vector<Measurement> measurements; |
| 371 bool gpu_timer_errors = | 374 bool gpu_timer_errors = |
| 372 gpu_timing_client_->IsAvailable() && | 375 gpu_timing_client_->IsAvailable() && |
| 373 gpu_timing_client_->CheckAndResetTimerErrors(); | 376 gpu_timing_client_->CheckAndResetTimerErrors(); |
| 374 if (!gpu_timer_errors) { | 377 if (!gpu_timer_errors) { |
| 375 measurements.push_back(tex_timers.GetAsMeasurement( | 378 measurements.push_back(tex_timers.GetAsMeasurement( |
| 376 subimage ? "texsubimage2d" : "teximage2d")); | 379 subimage ? "texsubimage2d" : "teximage2d")); |
| 380 measurements.push_back( | |
| 381 first_draw_timers.GetAsMeasurement("firstdrawarrayscost")); | |
|
Daniele Castagna
2015/03/24 17:30:09
nit: I'd remove the suffix "cost". Every measureme
| |
| 377 measurements.push_back(draw_timers.GetAsMeasurement("drawarrays")); | 382 measurements.push_back(draw_timers.GetAsMeasurement("drawarrays")); |
| 378 measurements.push_back(finish_timers.GetAsMeasurement("finish")); | 383 measurements.push_back(finish_timers.GetAsMeasurement("finish")); |
| 379 } | 384 } |
| 380 return measurements; | 385 return measurements; |
| 381 } | 386 } |
| 382 | 387 |
| 383 void RunUploadAndDrawMultipleTimes(const gfx::Size& size, | 388 void RunUploadAndDrawMultipleTimes(const gfx::Size& size, |
| 384 const GLenum format, | 389 const GLenum format, |
| 385 const bool subimage) { | 390 const bool subimage) { |
| 386 std::vector<uint8> pixels; | 391 std::vector<uint8> pixels; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 534 gpu_timing_client_->CheckAndResetTimerErrors(); | 539 gpu_timing_client_->CheckAndResetTimerErrors(); |
| 535 if (!gpu_timer_errors) { | 540 if (!gpu_timer_errors) { |
| 536 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") | 541 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") |
| 537 .PrintResult("renaming"); | 542 .PrintResult("renaming"); |
| 538 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); | 543 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); |
| 539 } | 544 } |
| 540 } | 545 } |
| 541 | 546 |
| 542 } // namespace | 547 } // namespace |
| 543 } // namespace gpu | 548 } // namespace gpu |
| OLD | NEW |