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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 const Shader* shader_a, | 129 const Shader* shader_a, |
130 const Shader* shader_b, | 130 const Shader* shader_b, |
131 const LocationMap* bind_attrib_location_map, | 131 const LocationMap* bind_attrib_location_map, |
132 const ShaderCacheCallback& shader_callback) { | 132 const ShaderCacheCallback& shader_callback) { |
133 GLenum format; | 133 GLenum format; |
134 GLsizei length = 0; | 134 GLsizei length = 0; |
135 glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &length); | 135 glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH_OES, &length); |
136 if (length == 0 || static_cast<unsigned int>(length) > max_size_bytes_) { | 136 if (length == 0 || static_cast<unsigned int>(length) > max_size_bytes_) { |
137 return; | 137 return; |
138 } | 138 } |
139 scoped_array<char> binary(new char[length]); | 139 scoped_ptr<char[]> binary(new char[length]); |
140 glGetProgramBinary(program, | 140 glGetProgramBinary(program, |
141 length, | 141 length, |
142 NULL, | 142 NULL, |
143 &format, | 143 &format, |
144 binary.get()); | 144 binary.get()); |
145 UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.ProgramBinarySizeBytes", length); | 145 UMA_HISTOGRAM_COUNTS("GPU.ProgramCache.ProgramBinarySizeBytes", length); |
146 | 146 |
147 char a_sha[kHashLength]; | 147 char a_sha[kHashLength]; |
148 char b_sha[kHashLength]; | 148 char b_sha[kHashLength]; |
149 ComputeShaderHash(*shader_a->deferred_compilation_source(), a_sha); | 149 ComputeShaderHash(*shader_a->deferred_compilation_source(), a_sha); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 for (int i = 0; i < proto->fragment_shader().attribs_size(); i++) { | 245 for (int i = 0; i < proto->fragment_shader().attribs_size(); i++) { |
246 RetrieveShaderInfo(proto->fragment_shader().attribs(i), | 246 RetrieveShaderInfo(proto->fragment_shader().attribs(i), |
247 &fragment_attribs); | 247 &fragment_attribs); |
248 } | 248 } |
249 | 249 |
250 for (int i = 0; i < proto->fragment_shader().uniforms_size(); i++) { | 250 for (int i = 0; i < proto->fragment_shader().uniforms_size(); i++) { |
251 RetrieveShaderInfo(proto->fragment_shader().uniforms(i), | 251 RetrieveShaderInfo(proto->fragment_shader().uniforms(i), |
252 &fragment_uniforms); | 252 &fragment_uniforms); |
253 } | 253 } |
254 | 254 |
255 scoped_array<char> binary(new char[proto->program().length()]); | 255 scoped_ptr<char[]> binary(new char[proto->program().length()]); |
256 memcpy(binary.get(), proto->program().c_str(), proto->program().length()); | 256 memcpy(binary.get(), proto->program().c_str(), proto->program().length()); |
257 | 257 |
258 store_[proto->sha()] = new ProgramCacheValue(proto->program().length(), | 258 store_[proto->sha()] = new ProgramCacheValue(proto->program().length(), |
259 proto->format(), binary.release(), | 259 proto->format(), binary.release(), |
260 proto->vertex_shader().sha().c_str(), vertex_attribs, vertex_uniforms, | 260 proto->vertex_shader().sha().c_str(), vertex_attribs, vertex_uniforms, |
261 proto->fragment_shader().sha().c_str(), fragment_attribs, | 261 proto->fragment_shader().sha().c_str(), fragment_attribs, |
262 fragment_uniforms); | 262 fragment_uniforms); |
263 | 263 |
264 ShaderCompilationSucceededSha(proto->sha()); | 264 ShaderCompilationSucceededSha(proto->sha()); |
265 ShaderCompilationSucceededSha(proto->vertex_shader().sha()); | 265 ShaderCompilationSucceededSha(proto->vertex_shader().sha()); |
(...skipping 30 matching lines...) Expand all Loading... |
296 attrib_map_0(_attrib_map_0), | 296 attrib_map_0(_attrib_map_0), |
297 uniform_map_0(_uniform_map_0), | 297 uniform_map_0(_uniform_map_0), |
298 shader_1_hash(_shader_1_hash, kHashLength), | 298 shader_1_hash(_shader_1_hash, kHashLength), |
299 attrib_map_1(_attrib_map_1), | 299 attrib_map_1(_attrib_map_1), |
300 uniform_map_1(_uniform_map_1) {} | 300 uniform_map_1(_uniform_map_1) {} |
301 | 301 |
302 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} | 302 MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() {} |
303 | 303 |
304 } // namespace gles2 | 304 } // namespace gles2 |
305 } // namespace gpu | 305 } // namespace gpu |
OLD | NEW |