Chromium Code Reviews| Index: content/browser/gpu/gpu_process_host.cc |
| diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc |
| index 0fe67c4ab80b7683bf41fcd986079a685f5f7916..546a93c1ff89c0e9b4e1af92f150357cb5f7b9f4 100644 |
| --- a/content/browser/gpu/gpu_process_host.cc |
| +++ b/content/browser/gpu/gpu_process_host.cc |
| @@ -1151,26 +1151,32 @@ void GpuProcessHost::RecordProcessCrash() { |
| } |
| } |
| -std::string GpuProcessHost::GetShaderPrefixKey() { |
| - if (shader_prefix_key_.empty()) { |
| +std::string GpuProcessHost::GetShaderPrefixKey(const std::string& shader) { |
| + if (shader_prefix_key_info_.empty()) { |
| gpu::GPUInfo info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); |
| - std::string in_str = GetContentClient()->GetProduct() + "-" + |
| + shader_prefix_key_info_ = |
| + GetContentClient()->GetProduct() + "-" + |
| #if defined(OS_ANDROID) |
| base::android::BuildInfo::GetInstance()->android_build_fp() + "-" + |
| #endif |
| - info.gl_vendor + "-" + info.gl_renderer + "-" + |
| - info.driver_version + "-" + info.driver_vendor; |
| - |
| - base::Base64Encode(base::SHA1HashString(in_str), &shader_prefix_key_); |
| + info.gl_vendor + "-" + info.gl_renderer + "-" + info.driver_version + |
| + "-" + info.driver_vendor; |
| } |
| - return shader_prefix_key_; |
| + // The shader prefix key is a SHA1 hash of a set of per-machine info, such as |
| + // driver version and os version, as well as the shader data being cached. |
| + // This ensures both that the shader was not corrupted on disk, as well as |
| + // that the shader is correctly configured for the current hardware. |
| + std::string prefix; |
| + base::Base64Encode(base::SHA1HashString(shader_prefix_key_info_ + shader), |
| + &prefix); |
| + return prefix; |
| } |
| void GpuProcessHost::LoadedShader(const std::string& key, |
| const std::string& data) { |
| - std::string prefix = GetShaderPrefixKey(); |
| + std::string prefix = GetShaderPrefixKey(data); |
| if (!key.compare(0, prefix.length(), prefix)) |
|
jbauman
2017/01/18 01:24:05
Could you add a UMA histogram for this?
ericrk
2017/01/18 19:44:16
Done.
|
| Send(new GpuMsg_LoadedShader(data)); |
| } |
| @@ -1202,7 +1208,7 @@ void GpuProcessHost::OnCacheShader(int32_t client_id, |
| // If the cache doesn't exist then this is an off the record profile. |
| if (iter == client_id_to_shader_cache_.end()) |
| return; |
| - iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| + iter->second->Cache(GetShaderPrefixKey(shader) + ":" + key, shader); |
| } |
| } // namespace content |