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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 glGetProgramiv(program, GL_LINK_STATUS, &success); | 135 glGetProgramiv(program, GL_LINK_STATUS, &success); |
136 if (success == GL_FALSE) { | 136 if (success == GL_FALSE) { |
137 return PROGRAM_LOAD_FAILURE; | 137 return PROGRAM_LOAD_FAILURE; |
138 } | 138 } |
139 shader_a->set_attrib_map(value->attrib_map_0); | 139 shader_a->set_attrib_map(value->attrib_map_0); |
140 shader_a->set_uniform_map(value->uniform_map_0); | 140 shader_a->set_uniform_map(value->uniform_map_0); |
141 shader_b->set_attrib_map(value->attrib_map_1); | 141 shader_b->set_attrib_map(value->attrib_map_1); |
142 shader_b->set_uniform_map(value->uniform_map_1); | 142 shader_b->set_uniform_map(value->uniform_map_1); |
143 | 143 |
144 if (!shader_callback.is_null() && | 144 if (!shader_callback.is_null() && |
145 !CommandLine::ForCurrentProcess()->HasSwitch( | 145 CommandLine::ForCurrentProcess()->HasSwitch( |
146 switches::kDisableGpuShaderDiskCache)) { | 146 switches::kEnableGpuShaderDiskCache)) { |
147 GpuProgramProto* proto = GpuProgramProto::default_instance().New(); | 147 GpuProgramProto* proto = GpuProgramProto::default_instance().New(); |
148 proto->set_sha(sha, kHashLength); | 148 proto->set_sha(sha, kHashLength); |
149 proto->set_format(value->format); | 149 proto->set_format(value->format); |
150 proto->set_program(value->data.get(), value->length); | 150 proto->set_program(value->data.get(), value->length); |
151 | 151 |
152 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a); | 152 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a); |
153 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b); | 153 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b); |
154 RunShaderCallback(shader_callback, proto, sha_string); | 154 RunShaderCallback(shader_callback, proto, sha_string); |
155 } | 155 } |
156 | 156 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 const std::string* program = eviction_helper_.PeekKey(); | 205 const std::string* program = eviction_helper_.PeekKey(); |
206 const StoreMap::iterator found = store_.find(*program); | 206 const StoreMap::iterator found = store_.find(*program); |
207 const ProgramCacheValue* evicting = found->second.get(); | 207 const ProgramCacheValue* evicting = found->second.get(); |
208 curr_size_bytes_ -= evicting->length; | 208 curr_size_bytes_ -= evicting->length; |
209 Evict(*program, evicting->shader_0_hash, evicting->shader_1_hash); | 209 Evict(*program, evicting->shader_0_hash, evicting->shader_1_hash); |
210 store_.erase(found); | 210 store_.erase(found); |
211 eviction_helper_.PopKey(); | 211 eviction_helper_.PopKey(); |
212 } | 212 } |
213 | 213 |
214 if (!shader_callback.is_null() && | 214 if (!shader_callback.is_null() && |
215 !CommandLine::ForCurrentProcess()->HasSwitch( | 215 CommandLine::ForCurrentProcess()->HasSwitch( |
216 switches::kDisableGpuShaderDiskCache)) { | 216 switches::kEnableGpuShaderDiskCache)) { |
217 GpuProgramProto* proto = GpuProgramProto::default_instance().New(); | 217 GpuProgramProto* proto = GpuProgramProto::default_instance().New(); |
218 proto->set_sha(sha, kHashLength); | 218 proto->set_sha(sha, kHashLength); |
219 proto->set_format(format); | 219 proto->set_format(format); |
220 proto->set_program(binary.get(), length); | 220 proto->set_program(binary.get(), length); |
221 | 221 |
222 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a); | 222 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a); |
223 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b); | 223 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b); |
224 RunShaderCallback(shader_callback, proto, sha_string); | 224 RunShaderCallback(shader_callback, proto, sha_string); |
225 } | 225 } |
226 | 226 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 attrib_map_0(_attrib_map_0), | 315 attrib_map_0(_attrib_map_0), |
316 uniform_map_0(_uniform_map_0), | 316 uniform_map_0(_uniform_map_0), |
317 shader_1_hash(_shader_1_hash, kHashLength), | 317 shader_1_hash(_shader_1_hash, kHashLength), |
318 attrib_map_1(_attrib_map_1), | 318 attrib_map_1(_attrib_map_1), |
319 uniform_map_1(_uniform_map_1) {} | 319 uniform_map_1(_uniform_map_1) {} |
320 | 320 |
321 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} | 321 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} |
322 | 322 |
323 } // namespace gles2 | 323 } // namespace gles2 |
324 } // namespace gpu | 324 } // namespace gpu |
OLD | NEW |