Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: gpu/command_buffer/service/memory_program_cache.cc

Issue 817653003: Update from https://crrev.com/309717 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/logger.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "gpu/command_buffer/common/constants.h" 12 #include "gpu/command_buffer/common/constants.h"
13 #include "gpu/command_buffer/service/disk_cache_proto.pb.h" 13 #include "gpu/command_buffer/service/disk_cache_proto.pb.h"
14 #include "gpu/command_buffer/service/gl_utils.h" 14 #include "gpu/command_buffer/service/gl_utils.h"
15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 15 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
16 #include "gpu/command_buffer/service/gpu_switches.h" 16 #include "gpu/command_buffer/service/gpu_switches.h"
17 #include "gpu/command_buffer/service/shader_manager.h" 17 #include "gpu/command_buffer/service/shader_manager.h"
18 #include "gpu/command_buffer/service/shader_translator.h" 18 #include "gpu/command_buffer/service/shader_translator.h"
19 #include "ui/gl/gl_bindings.h" 19 #include "ui/gl/gl_bindings.h"
20 20
21 namespace { 21 namespace {
22 22
23 size_t GetCacheSizeBytes() { 23 size_t GetCacheSizeBytes() {
24 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 24 const base::CommandLine* command_line =
25 base::CommandLine::ForCurrentProcess();
25 if (command_line->HasSwitch(switches::kGpuProgramCacheSizeKb)) { 26 if (command_line->HasSwitch(switches::kGpuProgramCacheSizeKb)) {
26 size_t size; 27 size_t size;
27 if (base::StringToSizeT( 28 if (base::StringToSizeT(
28 command_line->GetSwitchValueNative(switches::kGpuProgramCacheSizeKb), 29 command_line->GetSwitchValueNative(switches::kGpuProgramCacheSizeKb),
29 &size)) 30 &size))
30 return size * 1024; 31 return size * 1024;
31 } 32 }
32 return gpu::kDefaultMaxProgramCacheMemoryBytes; 33 return gpu::kDefaultMaxProgramCacheMemoryBytes;
33 } 34 }
34 35
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 return PROGRAM_LOAD_FAILURE; 209 return PROGRAM_LOAD_FAILURE;
209 } 210 }
210 shader_a->set_attrib_map(value->attrib_map_0()); 211 shader_a->set_attrib_map(value->attrib_map_0());
211 shader_a->set_uniform_map(value->uniform_map_0()); 212 shader_a->set_uniform_map(value->uniform_map_0());
212 shader_a->set_varying_map(value->varying_map_0()); 213 shader_a->set_varying_map(value->varying_map_0());
213 shader_b->set_attrib_map(value->attrib_map_1()); 214 shader_b->set_attrib_map(value->attrib_map_1());
214 shader_b->set_uniform_map(value->uniform_map_1()); 215 shader_b->set_uniform_map(value->uniform_map_1());
215 shader_b->set_varying_map(value->varying_map_1()); 216 shader_b->set_varying_map(value->varying_map_1());
216 217
217 if (!shader_callback.is_null() && 218 if (!shader_callback.is_null() &&
218 !CommandLine::ForCurrentProcess()->HasSwitch( 219 !base::CommandLine::ForCurrentProcess()->HasSwitch(
219 switches::kDisableGpuShaderDiskCache)) { 220 switches::kDisableGpuShaderDiskCache)) {
220 scoped_ptr<GpuProgramProto> proto( 221 scoped_ptr<GpuProgramProto> proto(
221 GpuProgramProto::default_instance().New()); 222 GpuProgramProto::default_instance().New());
222 proto->set_sha(sha, kHashLength); 223 proto->set_sha(sha, kHashLength);
223 proto->set_format(value->format()); 224 proto->set_format(value->format());
224 proto->set_program(value->data(), value->length()); 225 proto->set_program(value->data(), value->length());
225 226
226 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a); 227 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a);
227 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b); 228 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b);
228 RunShaderCallback(shader_callback, proto.get(), sha_string); 229 RunShaderCallback(shader_callback, proto.get(), sha_string);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 ProgramMRUCache::iterator existing = store_.Peek(sha_string); 278 ProgramMRUCache::iterator existing = store_.Peek(sha_string);
278 if(existing != store_.end()) 279 if(existing != store_.end())
279 store_.Erase(existing); 280 store_.Erase(existing);
280 281
281 while (curr_size_bytes_ + length > max_size_bytes_) { 282 while (curr_size_bytes_ + length > max_size_bytes_) {
282 DCHECK(!store_.empty()); 283 DCHECK(!store_.empty());
283 store_.Erase(store_.rbegin()); 284 store_.Erase(store_.rbegin());
284 } 285 }
285 286
286 if (!shader_callback.is_null() && 287 if (!shader_callback.is_null() &&
287 !CommandLine::ForCurrentProcess()->HasSwitch( 288 !base::CommandLine::ForCurrentProcess()->HasSwitch(
288 switches::kDisableGpuShaderDiskCache)) { 289 switches::kDisableGpuShaderDiskCache)) {
289 scoped_ptr<GpuProgramProto> proto( 290 scoped_ptr<GpuProgramProto> proto(
290 GpuProgramProto::default_instance().New()); 291 GpuProgramProto::default_instance().New());
291 proto->set_sha(sha, kHashLength); 292 proto->set_sha(sha, kHashLength);
292 proto->set_format(format); 293 proto->set_format(format);
293 proto->set_program(binary.get(), length); 294 proto->set_program(binary.get(), length);
294 295
295 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a); 296 FillShaderProto(proto->mutable_vertex_shader(), a_sha, shader_a);
296 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b); 297 FillShaderProto(proto->mutable_fragment_shader(), b_sha, shader_b);
297 RunShaderCallback(shader_callback, proto.get(), sha_string); 298 RunShaderCallback(shader_callback, proto.get(), sha_string);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 program_cache_->LinkedProgramCacheSuccess(program_hash); 408 program_cache_->LinkedProgramCacheSuccess(program_hash);
408 } 409 }
409 410
410 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { 411 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {
411 program_cache_->curr_size_bytes_ -= length_; 412 program_cache_->curr_size_bytes_ -= length_;
412 program_cache_->Evict(program_hash_); 413 program_cache_->Evict(program_hash_);
413 } 414 }
414 415
415 } // namespace gles2 416 } // namespace gles2
416 } // namespace gpu 417 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/logger.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698