| 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/memory_program_cache.h" | 5 #include "gpu/command_buffer/service/memory_program_cache.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ProgramCache::ProgramLoadResult MemoryProgramCache::LoadLinkedProgram( | 123 ProgramCache::ProgramLoadResult MemoryProgramCache::LoadLinkedProgram( |
| 124 GLuint program, | 124 GLuint program, |
| 125 Shader* shader_a, | 125 Shader* shader_a, |
| 126 const ShaderTranslatorInterface* translator_a, | 126 const ShaderTranslatorInterface* translator_a, |
| 127 Shader* shader_b, | 127 Shader* shader_b, |
| 128 const ShaderTranslatorInterface* translator_b, | 128 const ShaderTranslatorInterface* translator_b, |
| 129 const LocationMap* bind_attrib_location_map, | 129 const LocationMap* bind_attrib_location_map, |
| 130 const ShaderCacheCallback& shader_callback) { | 130 const ShaderCacheCallback& shader_callback) { |
| 131 char a_sha[kHashLength]; | 131 char a_sha[kHashLength]; |
| 132 char b_sha[kHashLength]; | 132 char b_sha[kHashLength]; |
| 133 DCHECK(shader_a && shader_a->signature_source() && | 133 DCHECK(shader_a && !shader_a->signature_source().empty() && |
| 134 shader_b && shader_b->signature_source()); | 134 shader_b && !shader_b->signature_source().empty()); |
| 135 ComputeShaderHash( | 135 ComputeShaderHash( |
| 136 *shader_a->signature_source(), translator_a, a_sha); | 136 shader_a->signature_source(), translator_a, a_sha); |
| 137 ComputeShaderHash( | 137 ComputeShaderHash( |
| 138 *shader_b->signature_source(), translator_b, b_sha); | 138 shader_b->signature_source(), translator_b, b_sha); |
| 139 | 139 |
| 140 char sha[kHashLength]; | 140 char sha[kHashLength]; |
| 141 ComputeProgramHash(a_sha, | 141 ComputeProgramHash(a_sha, |
| 142 b_sha, | 142 b_sha, |
| 143 bind_attrib_location_map, | 143 bind_attrib_location_map, |
| 144 sha); | 144 sha); |
| 145 const std::string sha_string(sha, kHashLength); | 145 const std::string sha_string(sha, kHashLength); |
| 146 | 146 |
| 147 ProgramMRUCache::iterator found = store_.Get(sha_string); | 147 ProgramMRUCache::iterator found = store_.Get(sha_string); |
| 148 if (found == store_.end()) { | 148 if (found == store_.end()) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 scoped_ptr<char[]> binary(new char[length]); | 199 scoped_ptr<char[]> binary(new char[length]); |
| 200 glGetProgramBinary(program, | 200 glGetProgramBinary(program, |
| 201 length, | 201 length, |
| 202 NULL, | 202 NULL, |
| 203 &format, | 203 &format, |
| 204 binary.get()); | 204 binary.get()); |
| 205 UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.ProgramBinarySizeBytes", length); | 205 UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.ProgramBinarySizeBytes", length); |
| 206 | 206 |
| 207 char a_sha[kHashLength]; | 207 char a_sha[kHashLength]; |
| 208 char b_sha[kHashLength]; | 208 char b_sha[kHashLength]; |
| 209 DCHECK(shader_a && shader_a->signature_source() && | 209 DCHECK(shader_a && !shader_a->signature_source().empty() && |
| 210 shader_b && shader_b->signature_source()); | 210 shader_b && !shader_b->signature_source().empty()); |
| 211 ComputeShaderHash( | 211 ComputeShaderHash( |
| 212 *shader_a->signature_source(), translator_a, a_sha); | 212 shader_a->signature_source(), translator_a, a_sha); |
| 213 ComputeShaderHash( | 213 ComputeShaderHash( |
| 214 *shader_b->signature_source(), translator_b, b_sha); | 214 shader_b->signature_source(), translator_b, b_sha); |
| 215 | 215 |
| 216 char sha[kHashLength]; | 216 char sha[kHashLength]; |
| 217 ComputeProgramHash(a_sha, | 217 ComputeProgramHash(a_sha, |
| 218 b_sha, | 218 b_sha, |
| 219 bind_attrib_location_map, | 219 bind_attrib_location_map, |
| 220 sha); | 220 sha); |
| 221 const std::string sha_string(sha, sizeof(sha)); | 221 const std::string sha_string(sha, sizeof(sha)); |
| 222 | 222 |
| 223 UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.MemorySizeBeforeKb", | 223 UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.MemorySizeBeforeKb", |
| 224 curr_size_bytes_ / 1024); | 224 curr_size_bytes_ / 1024); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 program_cache_->LinkedProgramCacheSuccess(program_hash); | 361 program_cache_->LinkedProgramCacheSuccess(program_hash); |
| 362 } | 362 } |
| 363 | 363 |
| 364 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { | 364 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { |
| 365 program_cache_->curr_size_bytes_ -= length_; | 365 program_cache_->curr_size_bytes_ -= length_; |
| 366 program_cache_->Evict(program_hash_); | 366 program_cache_->Evict(program_hash_); |
| 367 } | 367 } |
| 368 | 368 |
| 369 } // namespace gles2 | 369 } // namespace gles2 |
| 370 } // namespace gpu | 370 } // namespace gpu |
| OLD | NEW |