| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/sha1.h" | 13 #include "base/sha1.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "gpu/command_buffer/common/activity_flags.h" |
| 15 #include "gpu/command_buffer/common/constants.h" | 16 #include "gpu/command_buffer/common/constants.h" |
| 16 #include "gpu/command_buffer/service/disk_cache_proto.pb.h" | 17 #include "gpu/command_buffer/service/disk_cache_proto.pb.h" |
| 17 #include "gpu/command_buffer/service/gl_utils.h" | 18 #include "gpu/command_buffer/service/gl_utils.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 19 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 19 #include "gpu/command_buffer/service/gpu_preferences.h" | 20 #include "gpu/command_buffer/service/gpu_preferences.h" |
| 20 #include "gpu/command_buffer/service/shader_manager.h" | 21 #include "gpu/command_buffer/service/shader_manager.h" |
| 21 #include "ui/gl/gl_bindings.h" | 22 #include "ui/gl/gl_bindings.h" |
| 22 | 23 |
| 23 namespace gpu { | 24 namespace gpu { |
| 24 namespace gles2 { | 25 namespace gles2 { |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 transform_feedback_varyings, | 257 transform_feedback_varyings, |
| 257 transform_feedback_buffer_mode, | 258 transform_feedback_buffer_mode, |
| 258 sha); | 259 sha); |
| 259 const std::string sha_string(sha, kHashLength); | 260 const std::string sha_string(sha, kHashLength); |
| 260 | 261 |
| 261 ProgramMRUCache::iterator found = store_.Get(sha_string); | 262 ProgramMRUCache::iterator found = store_.Get(sha_string); |
| 262 if (found == store_.end()) { | 263 if (found == store_.end()) { |
| 263 return PROGRAM_LOAD_FAILURE; | 264 return PROGRAM_LOAD_FAILURE; |
| 264 } | 265 } |
| 265 const scoped_refptr<ProgramCacheValue> value = found->second; | 266 const scoped_refptr<ProgramCacheValue> value = found->second; |
| 267 GpuProcessActivityFlags::GetInstance()->SetFlag( |
| 268 ActivityFlagsBase::FLAG_LOADING_PROGRAM_BINARY); |
| 266 glProgramBinary(program, | 269 glProgramBinary(program, |
| 267 value->format(), | 270 value->format(), |
| 268 static_cast<const GLvoid*>(value->data()), | 271 static_cast<const GLvoid*>(value->data()), |
| 269 value->length()); | 272 value->length()); |
| 273 GpuProcessActivityFlags::GetInstance()->UnsetFlag( |
| 274 ActivityFlagsBase::FLAG_LOADING_PROGRAM_BINARY); |
| 270 GLint success = 0; | 275 GLint success = 0; |
| 271 glGetProgramiv(program, GL_LINK_STATUS, &success); | 276 glGetProgramiv(program, GL_LINK_STATUS, &success); |
| 272 if (success == GL_FALSE) { | 277 if (success == GL_FALSE) { |
| 273 return PROGRAM_LOAD_FAILURE; | 278 return PROGRAM_LOAD_FAILURE; |
| 274 } | 279 } |
| 275 shader_a->set_attrib_map(value->attrib_map_0()); | 280 shader_a->set_attrib_map(value->attrib_map_0()); |
| 276 shader_a->set_uniform_map(value->uniform_map_0()); | 281 shader_a->set_uniform_map(value->uniform_map_0()); |
| 277 shader_a->set_varying_map(value->varying_map_0()); | 282 shader_a->set_varying_map(value->varying_map_0()); |
| 278 shader_a->set_output_variable_list(value->output_variable_list_0()); | 283 shader_a->set_output_variable_list(value->output_variable_list_0()); |
| 279 shader_a->set_interface_block_map(value->interface_block_map_0()); | 284 shader_a->set_interface_block_map(value->interface_block_map_0()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 program_cache_->LinkedProgramCacheSuccess(program_hash); | 509 program_cache_->LinkedProgramCacheSuccess(program_hash); |
| 505 } | 510 } |
| 506 | 511 |
| 507 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { | 512 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { |
| 508 program_cache_->curr_size_bytes_ -= length_; | 513 program_cache_->curr_size_bytes_ -= length_; |
| 509 program_cache_->Evict(program_hash_); | 514 program_cache_->Evict(program_hash_); |
| 510 } | 515 } |
| 511 | 516 |
| 512 } // namespace gles2 | 517 } // namespace gles2 |
| 513 } // namespace gpu | 518 } // namespace gpu |
| OLD | NEW |