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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/sha1.h" | 9 #include "base/sha1.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 MemoryProgramCache::~MemoryProgramCache() {} | 40 MemoryProgramCache::~MemoryProgramCache() {} |
41 | 41 |
42 void MemoryProgramCache::ClearBackend() { | 42 void MemoryProgramCache::ClearBackend() { |
43 curr_size_bytes_ = 0; | 43 curr_size_bytes_ = 0; |
44 store_.clear(); | 44 store_.clear(); |
45 eviction_helper_.Clear(); | 45 eviction_helper_.Clear(); |
46 } | 46 } |
47 | 47 |
48 ProgramCache::ProgramLoadResult MemoryProgramCache::LoadLinkedProgram( | 48 ProgramCache::ProgramLoadResult MemoryProgramCache::LoadLinkedProgram( |
49 GLuint program, | 49 GLuint program, |
50 ShaderManager::ShaderInfo* shader_a, | 50 Shader* shader_a, |
51 ShaderManager::ShaderInfo* shader_b, | 51 Shader* shader_b, |
52 const LocationMap* bind_attrib_location_map) const { | 52 const LocationMap* bind_attrib_location_map) const { |
53 char a_sha[kHashLength]; | 53 char a_sha[kHashLength]; |
54 char b_sha[kHashLength]; | 54 char b_sha[kHashLength]; |
55 ComputeShaderHash(*shader_a->deferred_compilation_source(), a_sha); | 55 ComputeShaderHash(*shader_a->deferred_compilation_source(), a_sha); |
56 ComputeShaderHash(*shader_b->deferred_compilation_source(), b_sha); | 56 ComputeShaderHash(*shader_b->deferred_compilation_source(), b_sha); |
57 | 57 |
58 char sha[kHashLength]; | 58 char sha[kHashLength]; |
59 ComputeProgramHash(a_sha, | 59 ComputeProgramHash(a_sha, |
60 b_sha, | 60 b_sha, |
61 bind_attrib_location_map, | 61 bind_attrib_location_map, |
(...skipping 16 matching lines...) Expand all Loading... |
78 } | 78 } |
79 shader_a->set_attrib_map(value->attrib_map_0); | 79 shader_a->set_attrib_map(value->attrib_map_0); |
80 shader_a->set_uniform_map(value->uniform_map_0); | 80 shader_a->set_uniform_map(value->uniform_map_0); |
81 shader_b->set_attrib_map(value->attrib_map_1); | 81 shader_b->set_attrib_map(value->attrib_map_1); |
82 shader_b->set_uniform_map(value->uniform_map_1); | 82 shader_b->set_uniform_map(value->uniform_map_1); |
83 return PROGRAM_LOAD_SUCCESS; | 83 return PROGRAM_LOAD_SUCCESS; |
84 } | 84 } |
85 | 85 |
86 void MemoryProgramCache::SaveLinkedProgram( | 86 void MemoryProgramCache::SaveLinkedProgram( |
87 GLuint program, | 87 GLuint program, |
88 const ShaderManager::ShaderInfo* shader_a, | 88 const Shader* shader_a, |
89 const ShaderManager::ShaderInfo* shader_b, | 89 const Shader* shader_b, |
90 const LocationMap* bind_attrib_location_map) { | 90 const LocationMap* bind_attrib_location_map) { |
91 GLenum format; | 91 GLenum format; |
92 GLsizei length = 0; | 92 GLsizei length = 0; |
93 glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &length); | 93 glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &length); |
94 if (length == 0 || static_cast<unsigned int>(length) > max_size_bytes_) { | 94 if (length == 0 || static_cast<unsigned int>(length) > max_size_bytes_) { |
95 return; | 95 return; |
96 } | 96 } |
97 scoped_array<char> binary(new char[length]); | 97 scoped_array<char> binary(new char[length]); |
98 glGetProgramBinary(program, | 98 glGetProgramBinary(program, |
99 length, | 99 length, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 attrib_map_0(_attrib_map_0), | 172 attrib_map_0(_attrib_map_0), |
173 uniform_map_0(_uniform_map_0), | 173 uniform_map_0(_uniform_map_0), |
174 shader_1_hash(_shader_1_hash, kHashLength), | 174 shader_1_hash(_shader_1_hash, kHashLength), |
175 attrib_map_1(_attrib_map_1), | 175 attrib_map_1(_attrib_map_1), |
176 uniform_map_1(_uniform_map_1) {} | 176 uniform_map_1(_uniform_map_1) {} |
177 | 177 |
178 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} | 178 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} |
179 | 179 |
180 } // namespace gles2 | 180 } // namespace gles2 |
181 } // namespace gpu | 181 } // namespace gpu |
OLD | NEW |