| 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 "gpu/command_buffer/service/program_manager.h" | 5 #include "gpu/command_buffer/service/program_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 GLsizeiptr size = VertexShaderOutputBaseTypeToSize(varying.type); | 218 GLsizeiptr size = VertexShaderOutputBaseTypeToSize(varying.type); |
| 219 DCHECK(size); | 219 DCHECK(size); |
| 220 total = size; | 220 total = size; |
| 221 if (varying.arraySize > 1) { // array case. | 221 if (varying.arraySize > 1) { // array case. |
| 222 total *= varying.arraySize; | 222 total *= varying.arraySize; |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 return total.ValueOrDefault(std::numeric_limits<GLsizeiptr>::max()); | 225 return total.ValueOrDefault(std::numeric_limits<GLsizeiptr>::max()); |
| 226 } | 226 } |
| 227 | 227 |
| 228 // Scoped object which logs three UMA stats related to program cleanup when | |
| 229 // destructed: | |
| 230 // - GPU.DestroyProgramManagerPrograms.Elapsed - The amount of time spent | |
| 231 // destroying programs during ProgramManager::Destroy. | |
| 232 // - GPU.DestroyProgramManagerPrograms.Programs - The number of progams | |
| 233 // destroyed during ProgramManager::Destroy. | |
| 234 // - GPU.DestroyProgramManagerPrograms.ProgramsPerMs - The number of programs | |
| 235 // destroyed per millisecond during ProgramManager::Destroy. Only logged if | |
| 236 // both the number of programs and the elapsed time are greater than zero. | |
| 237 class ProgramDeletionScopedUmaTimeAndRate { | |
| 238 public: | |
| 239 ProgramDeletionScopedUmaTimeAndRate(int32_t count) | |
| 240 : count_(count), start_(base::TimeTicks::Now()) {} | |
| 241 | |
| 242 ~ProgramDeletionScopedUmaTimeAndRate() { | |
| 243 base::TimeDelta elapsed = base::TimeTicks::Now() - start_; | |
| 244 UMA_HISTOGRAM_TIMES("GPU.DestroyProgramManagerPrograms.Elapsed", elapsed); | |
| 245 UMA_HISTOGRAM_COUNTS("GPU.DestroyProgramManagerPrograms.Programs", count_); | |
| 246 | |
| 247 double elapsed_ms = elapsed.InMillisecondsF(); | |
| 248 if (count_ > 0 && elapsed_ms > 0) { | |
| 249 double rate = static_cast<double>(count_) / elapsed_ms; | |
| 250 UMA_HISTOGRAM_COUNTS("GPU.DestroyProgramManagerPrograms.ProgramsPerMs", | |
| 251 base::saturated_cast<int32_t>(rate)); | |
| 252 } | |
| 253 } | |
| 254 | |
| 255 private: | |
| 256 const int32_t count_; | |
| 257 const base::TimeTicks start_; | |
| 258 }; | |
| 259 | |
| 260 } // anonymous namespace. | 228 } // anonymous namespace. |
| 261 | 229 |
| 262 Program::UniformInfo::UniformInfo() | 230 Program::UniformInfo::UniformInfo() |
| 263 : size(0), | 231 : size(0), |
| 264 type(GL_NONE), | 232 type(GL_NONE), |
| 265 accepts_api_type(0), | 233 accepts_api_type(0), |
| 266 fake_location_base(0), | 234 fake_location_base(0), |
| 267 is_array(false) {} | 235 is_array(false) {} |
| 268 | 236 |
| 269 Program::UniformInfo::UniformInfo(const std::string& client_name, | 237 Program::UniformInfo::UniformInfo(const std::string& client_name, |
| (...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2583 feature_info_(feature_info), | 2551 feature_info_(feature_info), |
| 2584 progress_reporter_(progress_reporter) {} | 2552 progress_reporter_(progress_reporter) {} |
| 2585 | 2553 |
| 2586 ProgramManager::~ProgramManager() { | 2554 ProgramManager::~ProgramManager() { |
| 2587 DCHECK(programs_.empty()); | 2555 DCHECK(programs_.empty()); |
| 2588 } | 2556 } |
| 2589 | 2557 |
| 2590 void ProgramManager::Destroy(bool have_context) { | 2558 void ProgramManager::Destroy(bool have_context) { |
| 2591 have_context_ = have_context; | 2559 have_context_ = have_context; |
| 2592 | 2560 |
| 2593 ProgramDeletionScopedUmaTimeAndRate scoped_histogram( | |
| 2594 base::saturated_cast<int32_t>(programs_.size())); | |
| 2595 while (!programs_.empty()) { | 2561 while (!programs_.empty()) { |
| 2596 programs_.erase(programs_.begin()); | 2562 programs_.erase(programs_.begin()); |
| 2597 if (progress_reporter_) | 2563 if (progress_reporter_) |
| 2598 progress_reporter_->ReportProgress(); | 2564 progress_reporter_->ReportProgress(); |
| 2599 } | 2565 } |
| 2600 } | 2566 } |
| 2601 | 2567 |
| 2602 void ProgramManager::StartTracking(Program* /* program */) { | 2568 void ProgramManager::StartTracking(Program* /* program */) { |
| 2603 ++program_count_; | 2569 ++program_count_; |
| 2604 } | 2570 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 DCHECK(program); | 2661 DCHECK(program); |
| 2696 program->ClearUniforms(&zero_); | 2662 program->ClearUniforms(&zero_); |
| 2697 } | 2663 } |
| 2698 | 2664 |
| 2699 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { | 2665 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { |
| 2700 return index + element * 0x10000; | 2666 return index + element * 0x10000; |
| 2701 } | 2667 } |
| 2702 | 2668 |
| 2703 } // namespace gles2 | 2669 } // namespace gles2 |
| 2704 } // namespace gpu | 2670 } // namespace gpu |
| OLD | NEW |