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

Unified Diff: content/browser/gpu/gpu_process_host.cc

Issue 2638933003: Add SHA1 data checksum to on-disk shader cache (Closed)
Patch Set: nit remove braces Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698