Chromium Code Reviews| 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 "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1144 // The GPU process is too unstable to use. Disable it for current | 1144 // The GPU process is too unstable to use. Disable it for current |
| 1145 // session. | 1145 // session. |
| 1146 hardware_gpu_enabled_ = false; | 1146 hardware_gpu_enabled_ = false; |
| 1147 GpuDataManagerImpl::GetInstance()->DisableHardwareAcceleration(); | 1147 GpuDataManagerImpl::GetInstance()->DisableHardwareAcceleration(); |
| 1148 #endif | 1148 #endif |
| 1149 } | 1149 } |
| 1150 } | 1150 } |
| 1151 } | 1151 } |
| 1152 } | 1152 } |
| 1153 | 1153 |
| 1154 std::string GpuProcessHost::GetShaderPrefixKey() { | 1154 std::string GpuProcessHost::GetShaderPrefixKey(const std::string& shader) { |
| 1155 if (shader_prefix_key_.empty()) { | 1155 if (shader_prefix_key_info_.empty()) { |
| 1156 gpu::GPUInfo info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); | 1156 gpu::GPUInfo info = GpuDataManagerImpl::GetInstance()->GetGPUInfo(); |
| 1157 | 1157 |
| 1158 std::string in_str = GetContentClient()->GetProduct() + "-" + | 1158 shader_prefix_key_info_ = |
| 1159 GetContentClient()->GetProduct() + "-" + | |
| 1159 #if defined(OS_ANDROID) | 1160 #if defined(OS_ANDROID) |
| 1160 base::android::BuildInfo::GetInstance()->android_build_fp() + "-" + | 1161 base::android::BuildInfo::GetInstance()->android_build_fp() + "-" + |
| 1161 #endif | 1162 #endif |
| 1162 info.gl_vendor + "-" + info.gl_renderer + "-" + | 1163 info.gl_vendor + "-" + info.gl_renderer + "-" + info.driver_version + |
| 1163 info.driver_version + "-" + info.driver_vendor; | 1164 "-" + info.driver_vendor; |
| 1164 | |
| 1165 base::Base64Encode(base::SHA1HashString(in_str), &shader_prefix_key_); | |
| 1166 } | 1165 } |
| 1167 | 1166 |
| 1168 return shader_prefix_key_; | 1167 // The shader prefix key is a SHA1 hash of a set of per-machine info, such as |
| 1168 // driver version and os version, as well as the shader data being cached. | |
| 1169 // This ensures both that the shader was not corrupted on disk, as well as | |
| 1170 // that the shader is correctly configured for the current hardware. | |
| 1171 std::string prefix; | |
| 1172 base::Base64Encode(base::SHA1HashString(shader_prefix_key_info_ + shader), | |
| 1173 &prefix); | |
| 1174 return prefix; | |
| 1169 } | 1175 } |
| 1170 | 1176 |
| 1171 void GpuProcessHost::LoadedShader(const std::string& key, | 1177 void GpuProcessHost::LoadedShader(const std::string& key, |
| 1172 const std::string& data) { | 1178 const std::string& data) { |
| 1173 std::string prefix = GetShaderPrefixKey(); | 1179 std::string prefix = GetShaderPrefixKey(data); |
| 1174 if (!key.compare(0, prefix.length(), prefix)) | 1180 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.
| |
| 1175 Send(new GpuMsg_LoadedShader(data)); | 1181 Send(new GpuMsg_LoadedShader(data)); |
| 1176 } | 1182 } |
| 1177 | 1183 |
| 1178 void GpuProcessHost::CreateChannelCache(int32_t client_id) { | 1184 void GpuProcessHost::CreateChannelCache(int32_t client_id) { |
| 1179 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); | 1185 TRACE_EVENT0("gpu", "GpuProcessHost::CreateChannelCache"); |
| 1180 | 1186 |
| 1181 scoped_refptr<gpu::ShaderDiskCache> cache = | 1187 scoped_refptr<gpu::ShaderDiskCache> cache = |
| 1182 GetShaderCacheFactorySingleton()->Get(client_id); | 1188 GetShaderCacheFactorySingleton()->Get(client_id); |
| 1183 if (!cache.get()) | 1189 if (!cache.get()) |
| 1184 return; | 1190 return; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1195 | 1201 |
| 1196 void GpuProcessHost::OnCacheShader(int32_t client_id, | 1202 void GpuProcessHost::OnCacheShader(int32_t client_id, |
| 1197 const std::string& key, | 1203 const std::string& key, |
| 1198 const std::string& shader) { | 1204 const std::string& shader) { |
| 1199 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1205 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1200 ClientIdToShaderCacheMap::iterator iter = | 1206 ClientIdToShaderCacheMap::iterator iter = |
| 1201 client_id_to_shader_cache_.find(client_id); | 1207 client_id_to_shader_cache_.find(client_id); |
| 1202 // If the cache doesn't exist then this is an off the record profile. | 1208 // If the cache doesn't exist then this is an off the record profile. |
| 1203 if (iter == client_id_to_shader_cache_.end()) | 1209 if (iter == client_id_to_shader_cache_.end()) |
| 1204 return; | 1210 return; |
| 1205 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1211 iter->second->Cache(GetShaderPrefixKey(shader) + ":" + key, shader); |
| 1206 } | 1212 } |
| 1207 | 1213 |
| 1208 } // namespace content | 1214 } // namespace content |
| OLD | NEW |